aboutsummaryrefslogtreecommitdiffstats
path: root/rust/fatcat-openapi
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-09-19 00:38:00 -0700
committerBryan Newbold <bnewbold@robocracy.org>2020-05-10 13:08:45 -0700
commita9b23947c49275a11765c8a752c154b98c69b531 (patch)
tree0c8bef53cfb66b81996721fcab92d90ec1c4376c /rust/fatcat-openapi
parent228a9245ea3680e11164f58367310406402d306b (diff)
downloadfatcat-a9b23947c49275a11765c8a752c154b98c69b531.tar.gz
fatcat-a9b23947c49275a11765c8a752c154b98c69b531.zip
WIP: update rust codegen script
Only Cargo.toml project metadata updated.
Diffstat (limited to 'rust/fatcat-openapi')
-rw-r--r--rust/fatcat-openapi/Cargo.toml86
-rw-r--r--rust/fatcat-openapi/README.md294
-rw-r--r--rust/fatcat-openapi/docs/AuthOidc.md13
-rw-r--r--rust/fatcat-openapi/docs/AuthOidcResult.md11
-rw-r--r--rust/fatcat-openapi/docs/AuthTokenResult.md10
-rw-r--r--rust/fatcat-openapi/docs/ChangelogEntry.md13
-rw-r--r--rust/fatcat-openapi/docs/ContainerAutoBatch.md11
-rw-r--r--rust/fatcat-openapi/docs/ContainerEntity.md20
-rw-r--r--rust/fatcat-openapi/docs/CreatorAutoBatch.md11
-rw-r--r--rust/fatcat-openapi/docs/CreatorEntity.md20
-rw-r--r--rust/fatcat-openapi/docs/Editgroup.md19
-rw-r--r--rust/fatcat-openapi/docs/EditgroupAnnotation.md16
-rw-r--r--rust/fatcat-openapi/docs/EditgroupEdits.md16
-rw-r--r--rust/fatcat-openapi/docs/Editor.md14
-rw-r--r--rust/fatcat-openapi/docs/EntityEdit.md16
-rw-r--r--rust/fatcat-openapi/docs/EntityHistoryEntry.md12
-rw-r--r--rust/fatcat-openapi/docs/ErrorResponse.md12
-rw-r--r--rust/fatcat-openapi/docs/FileAutoBatch.md11
-rw-r--r--rust/fatcat-openapi/docs/FileEntity.md23
-rw-r--r--rust/fatcat-openapi/docs/FileUrl.md11
-rw-r--r--rust/fatcat-openapi/docs/FilesetAutoBatch.md11
-rw-r--r--rust/fatcat-openapi/docs/FilesetEntity.md19
-rw-r--r--rust/fatcat-openapi/docs/FilesetFile.md15
-rw-r--r--rust/fatcat-openapi/docs/FilesetUrl.md11
-rw-r--r--rust/fatcat-openapi/docs/ReleaseAbstract.md13
-rw-r--r--rust/fatcat-openapi/docs/ReleaseAutoBatch.md11
-rw-r--r--rust/fatcat-openapi/docs/ReleaseContrib.md18
-rw-r--r--rust/fatcat-openapi/docs/ReleaseEntity.md43
-rw-r--r--rust/fatcat-openapi/docs/ReleaseExtIds.md19
-rw-r--r--rust/fatcat-openapi/docs/ReleaseRef.md17
-rw-r--r--rust/fatcat-openapi/docs/Success.md11
-rw-r--r--rust/fatcat-openapi/docs/WebcaptureAutoBatch.md11
-rw-r--r--rust/fatcat-openapi/docs/WebcaptureCdxLine.md17
-rw-r--r--rust/fatcat-openapi/docs/WebcaptureEntity.md21
-rw-r--r--rust/fatcat-openapi/docs/WebcaptureUrl.md11
-rw-r--r--rust/fatcat-openapi/docs/WorkAutoBatch.md11
-rw-r--r--rust/fatcat-openapi/docs/WorkEntity.md15
-rw-r--r--rust/fatcat-openapi/docs/default_api.md3016
-rw-r--r--rust/fatcat-openapi/examples/client.rs691
-rw-r--r--rust/fatcat-openapi/examples/client/main.rs1139
-rw-r--r--rust/fatcat-openapi/examples/server.rs59
-rw-r--r--rust/fatcat-openapi/examples/server/main.rs25
-rw-r--r--rust/fatcat-openapi/examples/server/server.rs1691
-rw-r--r--rust/fatcat-openapi/examples/server_lib/mod.rs14
-rw-r--r--rust/fatcat-openapi/examples/server_lib/server.rs1081
-rw-r--r--rust/fatcat-openapi/rustfmt.toml5
-rw-r--r--rust/fatcat-openapi/src/client.rs7758
-rw-r--r--rust/fatcat-openapi/src/client/mod.rs19689
-rw-r--r--rust/fatcat-openapi/src/context.rs135
-rw-r--r--rust/fatcat-openapi/src/header.rs197
-rw-r--r--rust/fatcat-openapi/src/lib.rs3137
-rw-r--r--rust/fatcat-openapi/src/mimetypes.rs1993
-rw-r--r--rust/fatcat-openapi/src/models.rs6815
-rw-r--r--rust/fatcat-openapi/src/server.rs10980
-rw-r--r--rust/fatcat-openapi/src/server/mod.rs15022
55 files changed, 50398 insertions, 23962 deletions
diff --git a/rust/fatcat-openapi/Cargo.toml b/rust/fatcat-openapi/Cargo.toml
index 3f25b4c3..b6513a4a 100644
--- a/rust/fatcat-openapi/Cargo.toml
+++ b/rust/fatcat-openapi/Cargo.toml
@@ -9,41 +9,69 @@ repository = "https://github.com/internetarchive/fatcat"
license = "CC0-1.0"
[features]
-# Need to disable all openssl due to Xenial/Bionic dependency friction. Easiest
-# way seems to be entirely disabling 'client' option, and removing
-# 'hyper-openssl' below (which should be optional)
-#client = ["serde_json", "serde_ignored", "hyper", "hyper-openssl", "uuid"]
-default = ["server"]
-server = ["serde_json", "serde_ignored", "hyper", "iron", "router", "bodyparser", "urlencoded", "uuid"]
+default = ["client", "server"]
+client = [
+ "hyper", "hyper-openssl", "native-tls", "openssl", "url"
+]
+server = [
+ "serde_ignored", "hyper", "regex", "percent-encoding", "url", "lazy_static"
+]
+conversion = ["frunk", "frunk_derives", "frunk_core", "frunk-enum-core", "frunk-enum-derive"]
+
+[target.'cfg(any(target_os = "macos", target_os = "windows", target_os = "ios"))'.dependencies]
+native-tls = { version = "0.2", optional = true }
+
+[target.'cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))'.dependencies]
+hyper-openssl = { version = "0.7.1", optional = true }
+openssl = {version = "0.10", optional = true }
[dependencies]
-# Required by example server.
-#
+# Common
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"
+swagger = "4.0"
+log = "0.4.0"
+mime = "0.3"
+
+serde = { version = "1.0", features = ["derive"]}
+serde_json = "1.0"
+
+# Crates included if required by the API definition
+
+# Common between server and client features
+hyper = {version = "0.12", optional = true}
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
+url = {version = "1.5", optional = true}
+# Client-specific
+
+# Server, and client callback-specific
+lazy_static = { version = "1.4", optional = true }
+percent-encoding = {version = "1.0.0", optional = true}
+regex = {version = "0.2", optional = true}
+
+# Conversion
+frunk = { version = "0.3.0", optional = true }
+frunk_derives = { version = "0.3.0", optional = true }
+frunk_core = { version = "0.3.0", optional = true }
+frunk-enum-derive = { version = "0.2.0", optional = true }
+frunk-enum-core = { version = "0.2.0", optional = true }
[dev-dependencies]
clap = "2.25"
-error-chain = "0.11"
+error-chain = "0.12"
+env_logger = "0.6"
+tokio = "0.1.17"
+uuid = {version = "0.7", features = ["serde", "v4"]}
+
+[target.'cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))'.dev-dependencies]
+tokio-openssl = "0.3"
+openssl = "0.10"
+
+[[example]]
+name = "client"
+required-features = ["client"]
+
+[[example]]
+name = "server"
+required-features = ["server"]
diff --git a/rust/fatcat-openapi/README.md b/rust/fatcat-openapi/README.md
index 1e02e033..c78f9201 100644
--- a/rust/fatcat-openapi/README.md
+++ b/rust/fatcat-openapi/README.md
@@ -1,37 +1,43 @@
-# Rust API for fatcat
+# Rust API for fatcat-openapi
+
+Fatcat is a scalable, versioned, API-oriented catalog of bibliographic
+entities and file metadata.
-Fatcat is a scalable, versioned, API-oriented catalog of bibliographic entities and file metadata. <!-- STARTLONGDESCRIPTION --> These API reference documents, along with client software libraries, are generated automatically from an OpenAPI 2.0 (\"Swagger\") definition file. ## Introduction A higher-level introduction to the API, as well as a description of the fatcat data model, are available in [\"The Fatcat Guide\"](https://guide.fatcat.wiki/). The guide also includes a [Cookbook](https://guide.fatcat.wiki/cookbook.html) section demonstrating end-to-end tasks like creating entities as part of editgroups, or safely merging duplicate entities. ### Expectations and Best Practices A test/staging QA API instance of fatcat is available at <https://api.qa.fatcat.wiki/v0>. The database backing this instance is separate from the production interface, and is periodically rebuilt from snapshots of the full production database, meaning that edits on the QA server will *NOT* persist, and that semantics like the changelog index monotonically increasing *MAY* be broken. Developers are expexcted to test their scripts and tools against the QA instance before running against production. Fatcat is made available as a gratis (no cost) and libre (freedom preserving) service to the public, with limited funding and resources. We welcome new and unforseen uses and contributions, but may need to impose restrictions (like rate-limits) to keep the service functional for other users, and in extreme cases reserve the option to block accounts and IP ranges if necessary to keep the service operational. The Internet Archive owns and operates it's own server equipment and data centers, and operations are optimized for low-cost, not high-availability. Users and partners should expect some downtime on the fatcat API, on the order of hours a month. Periodic metadata exports are available for batch processing, and database snapshots can be used to create locally-hosted mirrors of the service for more intensive and reliable querying. ### Other Nitty Gritties Cross-origin requests are allowed for the API service, to enable third parties to bulid in-browser applications. A metadata search service is available at <https://search.fatcat.wiki> (and <https://search.qa.fatcat.wiki>). The API is currently the raw elasticsearch API, with only GET (read) requests allowed. This public service is experimental and may be removed or limited in the future. ## Authentication The API allows basic read-only \"GET\" HTTP requests with no authentication. Proposing changes to the metadata, or other mutating requests (\"PUT\", \"POST\", \"DELETE\") all require authentication, and some operations require additional account permissions. End-user account creation and login happens through the web interface. From a logged-in editor profile page, you can generate a API token. Tokens are \"macaroons\", similar to JWT tokens, and are used for all API authentication. The web interface includes macaroons in browser cookies and passes them through to the API to authenticate editor actions. <!-- ReDoc-Inject: <security-definitions> --> <!-- ENDLONGDESCRIPTION -->
## 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.
--
+
+This client/server was generated by the [openapi-generator]
+(https://openapi-generator.tech) 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)
+[README]((https://openapi-generator.tech))
- API version: 0.3.1
-- Build date: 2019-09-19T00:21:33.977Z
+- Build date: 2020-05-10T12:57:11.979702-07:00[America/Los_Angeles]
+
For more information, please visit [https://fatcat.wiki](https://fatcat.wiki)
-This autogenerated project defines an API crate `fatcat` which contains:
+This autogenerated project defines an API crate `fatcat-openapi` 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.
+It also contains an example server and client which make use of `fatcat-openapi`:
+
+* The example server starts up a web server using the `fatcat-openapi`
+ 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-openapi` 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:
@@ -46,81 +52,63 @@ To pass in arguments to the examples, put them after `--`, for example:
cargo run --example client -- --help
```
-### Running the server
+### Running the example server
To run the server, follow these simple steps:
```
cargo run --example server
```
-### Running a client
+### Running the example client
To run a client, follow one of the following simple steps:
```
+cargo run --example client AcceptEditgroup
cargo run --example client AuthCheck
-cargo run --example client AuthOidc
cargo run --example client CreateAuthToken
-cargo run --example client GetChangelog
-cargo run --example client GetChangelogEntry
-cargo run --example client CreateContainer
-cargo run --example client CreateContainerAutoBatch
cargo run --example client DeleteContainer
cargo run --example client DeleteContainerEdit
+cargo run --example client DeleteCreator
+cargo run --example client DeleteCreatorEdit
+cargo run --example client DeleteFile
+cargo run --example client DeleteFileEdit
+cargo run --example client DeleteFileset
+cargo run --example client DeleteFilesetEdit
+cargo run --example client DeleteRelease
+cargo run --example client DeleteReleaseEdit
+cargo run --example client DeleteWebcapture
+cargo run --example client DeleteWebcaptureEdit
+cargo run --example client DeleteWork
+cargo run --example client DeleteWorkEdit
+cargo run --example client GetChangelog
+cargo run --example client GetChangelogEntry
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 AcceptEditgroup
-cargo run --example client CreateEditgroup
-cargo run --example client CreateEditgroupAnnotation
cargo run --example client GetEditgroup
cargo run --example client GetEditgroupAnnotations
cargo run --example client GetEditgroupsReviewable
-cargo run --example client UpdateEditgroup
cargo run --example client GetEditor
cargo run --example client GetEditorAnnotations
cargo run --example client GetEditorEditgroups
-cargo run --example client UpdateEditor
-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 DeleteRelease
-cargo run --example client DeleteReleaseEdit
cargo run --example client GetRelease
cargo run --example client GetReleaseEdit
cargo run --example client GetReleaseFiles
@@ -129,29 +117,21 @@ 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 CreateWork
-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
+cargo run --example client LookupContainer
+cargo run --example client LookupCreator
+cargo run --example client LookupFile
+cargo run --example client LookupRelease
```
### HTTPS
@@ -161,40 +141,176 @@ The examples can be run in HTTPS mode by passing in the flag `--https`, for exam
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`.
+This will use the keys/certificates from the examples directory. Note that the
+server chain is signed with `CN=localhost`.
+## Using the generated library
-## Writing a server
+The generated library has a few optional features that can be activated through Cargo.
-The server example is designed to form the basis for implementing your own server. Simply follow these steps.
+* `server`
+ * This defaults to enabled and creates the basic skeleton of a server implementation based on hyper
+ * To create the server stack you'll need to provide an implementation of the API trait to provide the server function.
+* `client`
+ * This defaults to enabled and creates the basic skeleton of a client implementation based on hyper
+ * The constructed client implements the API trait by making remote API call.
+* `conversions`
+ * This defaults to disabled and creates extra derives on models to allow "transmogrification" between objects of structurally similar types.
-* 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.1", 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.
+See https://doc.rust-lang.org/cargo/reference/manifest.html#the-features-section for how to use features in your `Cargo.toml`.
+
+## Documentation for API Endpoints
+
+All URIs are relative to *https://api.fatcat.wiki/v0*
+
+Method | HTTP request | Description
+------------- | ------------- | -------------
+[**accept_editgroup**](docs/default_api.md#accept_editgroup) | **POST** /editgroup/{editgroup_id}/accept |
+[**auth_check**](docs/default_api.md#auth_check) | **GET** /auth/check |
+[**auth_oidc**](docs/default_api.md#auth_oidc) | **POST** /auth/oidc |
+[**create_auth_token**](docs/default_api.md#create_auth_token) | **POST** /auth/token/{editor_id} |
+[**create_container**](docs/default_api.md#create_container) | **POST** /editgroup/{editgroup_id}/container |
+[**create_container_auto_batch**](docs/default_api.md#create_container_auto_batch) | **POST** /editgroup/auto/container/batch |
+[**create_creator**](docs/default_api.md#create_creator) | **POST** /editgroup/{editgroup_id}/creator |
+[**create_creator_auto_batch**](docs/default_api.md#create_creator_auto_batch) | **POST** /editgroup/auto/creator/batch |
+[**create_editgroup**](docs/default_api.md#create_editgroup) | **POST** /editgroup |
+[**create_editgroup_annotation**](docs/default_api.md#create_editgroup_annotation) | **POST** /editgroup/{editgroup_id}/annotation |
+[**create_file**](docs/default_api.md#create_file) | **POST** /editgroup/{editgroup_id}/file |
+[**create_file_auto_batch**](docs/default_api.md#create_file_auto_batch) | **POST** /editgroup/auto/file/batch |
+[**create_fileset**](docs/default_api.md#create_fileset) | **POST** /editgroup/{editgroup_id}/fileset |
+[**create_fileset_auto_batch**](docs/default_api.md#create_fileset_auto_batch) | **POST** /editgroup/auto/fileset/batch |
+[**create_release**](docs/default_api.md#create_release) | **POST** /editgroup/{editgroup_id}/release |
+[**create_release_auto_batch**](docs/default_api.md#create_release_auto_batch) | **POST** /editgroup/auto/release/batch |
+[**create_webcapture**](docs/default_api.md#create_webcapture) | **POST** /editgroup/{editgroup_id}/webcapture |
+[**create_webcapture_auto_batch**](docs/default_api.md#create_webcapture_auto_batch) | **POST** /editgroup/auto/webcapture/batch |
+[**create_work**](docs/default_api.md#create_work) | **POST** /editgroup/{editgroup_id}/work |
+[**create_work_auto_batch**](docs/default_api.md#create_work_auto_batch) | **POST** /editgroup/auto/work/batch |
+[**delete_container**](docs/default_api.md#delete_container) | **DELETE** /editgroup/{editgroup_id}/container/{ident} |
+[**delete_container_edit**](docs/default_api.md#delete_container_edit) | **DELETE** /editgroup/{editgroup_id}/container/edit/{edit_id} |
+[**delete_creator**](docs/default_api.md#delete_creator) | **DELETE** /editgroup/{editgroup_id}/creator/{ident} |
+[**delete_creator_edit**](docs/default_api.md#delete_creator_edit) | **DELETE** /editgroup/{editgroup_id}/creator/edit/{edit_id} |
+[**delete_file**](docs/default_api.md#delete_file) | **DELETE** /editgroup/{editgroup_id}/file/{ident} |
+[**delete_file_edit**](docs/default_api.md#delete_file_edit) | **DELETE** /editgroup/{editgroup_id}/file/edit/{edit_id} |
+[**delete_fileset**](docs/default_api.md#delete_fileset) | **DELETE** /editgroup/{editgroup_id}/fileset/{ident} |
+[**delete_fileset_edit**](docs/default_api.md#delete_fileset_edit) | **DELETE** /editgroup/{editgroup_id}/fileset/edit/{edit_id} |
+[**delete_release**](docs/default_api.md#delete_release) | **DELETE** /editgroup/{editgroup_id}/release/{ident} |
+[**delete_release_edit**](docs/default_api.md#delete_release_edit) | **DELETE** /editgroup/{editgroup_id}/release/edit/{edit_id} |
+[**delete_webcapture**](docs/default_api.md#delete_webcapture) | **DELETE** /editgroup/{editgroup_id}/webcapture/{ident} |
+[**delete_webcapture_edit**](docs/default_api.md#delete_webcapture_edit) | **DELETE** /editgroup/{editgroup_id}/webcapture/edit/{edit_id} |
+[**delete_work**](docs/default_api.md#delete_work) | **DELETE** /editgroup/{editgroup_id}/work/{ident} |
+[**delete_work_edit**](docs/default_api.md#delete_work_edit) | **DELETE** /editgroup/{editgroup_id}/work/edit/{edit_id} |
+[**get_changelog**](docs/default_api.md#get_changelog) | **GET** /changelog |
+[**get_changelog_entry**](docs/default_api.md#get_changelog_entry) | **GET** /changelog/{index} |
+[**get_container**](docs/default_api.md#get_container) | **GET** /container/{ident} |
+[**get_container_edit**](docs/default_api.md#get_container_edit) | **GET** /container/edit/{edit_id} |
+[**get_container_history**](docs/default_api.md#get_container_history) | **GET** /container/{ident}/history |
+[**get_container_redirects**](docs/default_api.md#get_container_redirects) | **GET** /container/{ident}/redirects |
+[**get_container_revision**](docs/default_api.md#get_container_revision) | **GET** /container/rev/{rev_id} |
+[**get_creator**](docs/default_api.md#get_creator) | **GET** /creator/{ident} |
+[**get_creator_edit**](docs/default_api.md#get_creator_edit) | **GET** /creator/edit/{edit_id} |
+[**get_creator_history**](docs/default_api.md#get_creator_history) | **GET** /creator/{ident}/history |
+[**get_creator_redirects**](docs/default_api.md#get_creator_redirects) | **GET** /creator/{ident}/redirects |
+[**get_creator_releases**](docs/default_api.md#get_creator_releases) | **GET** /creator/{ident}/releases |
+[**get_creator_revision**](docs/default_api.md#get_creator_revision) | **GET** /creator/rev/{rev_id} |
+[**get_editgroup**](docs/default_api.md#get_editgroup) | **GET** /editgroup/{editgroup_id} |
+[**get_editgroup_annotations**](docs/default_api.md#get_editgroup_annotations) | **GET** /editgroup/{editgroup_id}/annotations |
+[**get_editgroups_reviewable**](docs/default_api.md#get_editgroups_reviewable) | **GET** /editgroup/reviewable |
+[**get_editor**](docs/default_api.md#get_editor) | **GET** /editor/{editor_id} |
+[**get_editor_annotations**](docs/default_api.md#get_editor_annotations) | **GET** /editor/{editor_id}/annotations |
+[**get_editor_editgroups**](docs/default_api.md#get_editor_editgroups) | **GET** /editor/{editor_id}/editgroups |
+[**get_file**](docs/default_api.md#get_file) | **GET** /file/{ident} |
+[**get_file_edit**](docs/default_api.md#get_file_edit) | **GET** /file/edit/{edit_id} |
+[**get_file_history**](docs/default_api.md#get_file_history) | **GET** /file/{ident}/history |
+[**get_file_redirects**](docs/default_api.md#get_file_redirects) | **GET** /file/{ident}/redirects |
+[**get_file_revision**](docs/default_api.md#get_file_revision) | **GET** /file/rev/{rev_id} |
+[**get_fileset**](docs/default_api.md#get_fileset) | **GET** /fileset/{ident} |
+[**get_fileset_edit**](docs/default_api.md#get_fileset_edit) | **GET** /fileset/edit/{edit_id} |
+[**get_fileset_history**](docs/default_api.md#get_fileset_history) | **GET** /fileset/{ident}/history |
+[**get_fileset_redirects**](docs/default_api.md#get_fileset_redirects) | **GET** /fileset/{ident}/redirects |
+[**get_fileset_revision**](docs/default_api.md#get_fileset_revision) | **GET** /fileset/rev/{rev_id} |
+[**get_release**](docs/default_api.md#get_release) | **GET** /release/{ident} |
+[**get_release_edit**](docs/default_api.md#get_release_edit) | **GET** /release/edit/{edit_id} |
+[**get_release_files**](docs/default_api.md#get_release_files) | **GET** /release/{ident}/files |
+[**get_release_filesets**](docs/default_api.md#get_release_filesets) | **GET** /release/{ident}/filesets |
+[**get_release_history**](docs/default_api.md#get_release_history) | **GET** /release/{ident}/history |
+[**get_release_redirects**](docs/default_api.md#get_release_redirects) | **GET** /release/{ident}/redirects |
+[**get_release_revision**](docs/default_api.md#get_release_revision) | **GET** /release/rev/{rev_id} |
+[**get_release_webcaptures**](docs/default_api.md#get_release_webcaptures) | **GET** /release/{ident}/webcaptures |
+[**get_webcapture**](docs/default_api.md#get_webcapture) | **GET** /webcapture/{ident} |
+[**get_webcapture_edit**](docs/default_api.md#get_webcapture_edit) | **GET** /webcapture/edit/{edit_id} |
+[**get_webcapture_history**](docs/default_api.md#get_webcapture_history) | **GET** /webcapture/{ident}/history |
+[**get_webcapture_redirects**](docs/default_api.md#get_webcapture_redirects) | **GET** /webcapture/{ident}/redirects |
+[**get_webcapture_revision**](docs/default_api.md#get_webcapture_revision) | **GET** /webcapture/rev/{rev_id} |
+[**get_work**](docs/default_api.md#get_work) | **GET** /work/{ident} |
+[**get_work_edit**](docs/default_api.md#get_work_edit) | **GET** /work/edit/{edit_id} |
+[**get_work_history**](docs/default_api.md#get_work_history) | **GET** /work/{ident}/history |
+[**get_work_redirects**](docs/default_api.md#get_work_redirects) | **GET** /work/{ident}/redirects |
+[**get_work_releases**](docs/default_api.md#get_work_releases) | **GET** /work/{ident}/releases |
+[**get_work_revision**](docs/default_api.md#get_work_revision) | **GET** /work/rev/{rev_id} |
+[**lookup_container**](docs/default_api.md#lookup_container) | **GET** /container/lookup |
+[**lookup_creator**](docs/default_api.md#lookup_creator) | **GET** /creator/lookup |
+[**lookup_file**](docs/default_api.md#lookup_file) | **GET** /file/lookup |
+[**lookup_release**](docs/default_api.md#lookup_release) | **GET** /release/lookup |
+[**update_container**](docs/default_api.md#update_container) | **PUT** /editgroup/{editgroup_id}/container/{ident} |
+[**update_creator**](docs/default_api.md#update_creator) | **PUT** /editgroup/{editgroup_id}/creator/{ident} |
+[**update_editgroup**](docs/default_api.md#update_editgroup) | **PUT** /editgroup/{editgroup_id} |
+[**update_editor**](docs/default_api.md#update_editor) | **PUT** /editor/{editor_id} |
+[**update_file**](docs/default_api.md#update_file) | **PUT** /editgroup/{editgroup_id}/file/{ident} |
+[**update_fileset**](docs/default_api.md#update_fileset) | **PUT** /editgroup/{editgroup_id}/fileset/{ident} |
+[**update_release**](docs/default_api.md#update_release) | **PUT** /editgroup/{editgroup_id}/release/{ident} |
+[**update_webcapture**](docs/default_api.md#update_webcapture) | **PUT** /editgroup/{editgroup_id}/webcapture/{ident} |
+[**update_work**](docs/default_api.md#update_work) | **PUT** /editgroup/{editgroup_id}/work/{ident} |
-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
+## Documentation For Models
-* 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).
+ - [AuthOidc](docs/AuthOidc.md)
+ - [AuthOidcResult](docs/AuthOidcResult.md)
+ - [AuthTokenResult](docs/AuthTokenResult.md)
+ - [ChangelogEntry](docs/ChangelogEntry.md)
+ - [ContainerAutoBatch](docs/ContainerAutoBatch.md)
+ - [ContainerEntity](docs/ContainerEntity.md)
+ - [CreatorAutoBatch](docs/CreatorAutoBatch.md)
+ - [CreatorEntity](docs/CreatorEntity.md)
+ - [Editgroup](docs/Editgroup.md)
+ - [EditgroupAnnotation](docs/EditgroupAnnotation.md)
+ - [EditgroupEdits](docs/EditgroupEdits.md)
+ - [Editor](docs/Editor.md)
+ - [EntityEdit](docs/EntityEdit.md)
+ - [EntityHistoryEntry](docs/EntityHistoryEntry.md)
+ - [ErrorResponse](docs/ErrorResponse.md)
+ - [FileAutoBatch](docs/FileAutoBatch.md)
+ - [FileEntity](docs/FileEntity.md)
+ - [FileUrl](docs/FileUrl.md)
+ - [FilesetAutoBatch](docs/FilesetAutoBatch.md)
+ - [FilesetEntity](docs/FilesetEntity.md)
+ - [FilesetFile](docs/FilesetFile.md)
+ - [FilesetUrl](docs/FilesetUrl.md)
+ - [ReleaseAbstract](docs/ReleaseAbstract.md)
+ - [ReleaseAutoBatch](docs/ReleaseAutoBatch.md)
+ - [ReleaseContrib](docs/ReleaseContrib.md)
+ - [ReleaseEntity](docs/ReleaseEntity.md)
+ - [ReleaseExtIds](docs/ReleaseExtIds.md)
+ - [ReleaseRef](docs/ReleaseRef.md)
+ - [Success](docs/Success.md)
+ - [WebcaptureAutoBatch](docs/WebcaptureAutoBatch.md)
+ - [WebcaptureCdxLine](docs/WebcaptureCdxLine.md)
+ - [WebcaptureEntity](docs/WebcaptureEntity.md)
+ - [WebcaptureUrl](docs/WebcaptureUrl.md)
+ - [WorkAutoBatch](docs/WorkAutoBatch.md)
+ - [WorkEntity](docs/WorkEntity.md)
+
+
+## Documentation For Authorization
+
+## Bearer
+- **Type**: API key
+
+Example
+```
+```
-Now replace the implementations in `src/server.rs` with your own code as required.
+## Author
-## Updating your server to track API changes
+webservices@archive.org
-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-openapi/docs/AuthOidc.md b/rust/fatcat-openapi/docs/AuthOidc.md
new file mode 100644
index 00000000..de80baa3
--- /dev/null
+++ b/rust/fatcat-openapi/docs/AuthOidc.md
@@ -0,0 +1,13 @@
+# AuthOidc
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**provider** | **String** | Fatcat-specific short name (slug) for remote service being used for authentication. |
+**sub** | **String** | `SUB` from OIDC protocol. Usually a URL. |
+**iss** | **String** | `ISS` from OIDC protocol. Usually a stable account username, number, or identifier. |
+**preferred_username** | **String** | What it sounds like; returned by OIDC, and used as a hint when creating new editor accounts. Fatcat usernames are usually this string with the `provider` slug as a suffix, though some munging may occur. |
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/rust/fatcat-openapi/docs/AuthOidcResult.md b/rust/fatcat-openapi/docs/AuthOidcResult.md
new file mode 100644
index 00000000..3418bea8
--- /dev/null
+++ b/rust/fatcat-openapi/docs/AuthOidcResult.md
@@ -0,0 +1,11 @@
+# AuthOidcResult
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**editor** | [***models::Editor**](editor.md) | |
+**token** | **String** | |
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/rust/fatcat-openapi/docs/AuthTokenResult.md b/rust/fatcat-openapi/docs/AuthTokenResult.md
new file mode 100644
index 00000000..2bb3dd70
--- /dev/null
+++ b/rust/fatcat-openapi/docs/AuthTokenResult.md
@@ -0,0 +1,10 @@
+# AuthTokenResult
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**token** | **String** | |
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/rust/fatcat-openapi/docs/ChangelogEntry.md b/rust/fatcat-openapi/docs/ChangelogEntry.md
new file mode 100644
index 00000000..3f62f704
--- /dev/null
+++ b/rust/fatcat-openapi/docs/ChangelogEntry.md
@@ -0,0 +1,13 @@
+# ChangelogEntry
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**index** | **i64** | Monotonically increasing sequence number of this changelog entry. |
+**editgroup_id** | **String** | Identifier of editgroup accepted/merged in this changelog entry. |
+**timestamp** | [**chrono::DateTime::<chrono::Utc>**](DateTime.md) | Date and time when the editgroup was accpeted. |
+**editgroup** | [***models::Editgroup**](editgroup.md) | | [optional] [default to None]
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/rust/fatcat-openapi/docs/ContainerAutoBatch.md b/rust/fatcat-openapi/docs/ContainerAutoBatch.md
new file mode 100644
index 00000000..0413aac7
--- /dev/null
+++ b/rust/fatcat-openapi/docs/ContainerAutoBatch.md
@@ -0,0 +1,11 @@
+# ContainerAutoBatch
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**editgroup** | [***models::Editgroup**](editgroup.md) | |
+**entity_list** | [**Vec<models::ContainerEntity>**](container_entity.md) | |
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/rust/fatcat-openapi/docs/ContainerEntity.md b/rust/fatcat-openapi/docs/ContainerEntity.md
new file mode 100644
index 00000000..62695616
--- /dev/null
+++ b/rust/fatcat-openapi/docs/ContainerEntity.md
@@ -0,0 +1,20 @@
+# ContainerEntity
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**state** | **String** | | [optional] [default to None]
+**ident** | **String** | base32-encoded unique identifier | [optional] [default to None]
+**revision** | **String** | UUID (lower-case, dash-separated, hex-encoded 128-bit) | [optional] [default to None]
+**redirect** | **String** | base32-encoded unique identifier | [optional] [default to None]
+**extra** | [**std::collections::HashMap<String, serde_json::Value>**](object.md) | Free-form JSON metadata that will be stored with the other entity metadata. See guide for (unenforced) schema conventions. | [optional] [default to None]
+**edit_extra** | [**std::collections::HashMap<String, serde_json::Value>**](object.md) | Free-form JSON metadata that will be stored with specific entity edits (eg, creation/update/delete). | [optional] [default to None]
+**name** | **String** | Name of the container (eg, Journal title). Required for entity creation. | [optional] [default to None]
+**container_type** | **String** | Type of container, eg 'journal' or 'proceedings'. See Guide for list of valid types. | [optional] [default to None]
+**publisher** | **String** | Name of the organization or entity responsible for publication. Not the complete imprint/brand. | [optional] [default to None]
+**issnl** | **String** | Linking ISSN number (ISSN-L). Should be valid and registered with issn.org | [optional] [default to None]
+**wikidata_qid** | **String** | | [optional] [default to None]
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/rust/fatcat-openapi/docs/CreatorAutoBatch.md b/rust/fatcat-openapi/docs/CreatorAutoBatch.md
new file mode 100644
index 00000000..b30375cc
--- /dev/null
+++ b/rust/fatcat-openapi/docs/CreatorAutoBatch.md
@@ -0,0 +1,11 @@
+# CreatorAutoBatch
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**editgroup** | [***models::Editgroup**](editgroup.md) | |
+**entity_list** | [**Vec<models::CreatorEntity>**](creator_entity.md) | |
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/rust/fatcat-openapi/docs/CreatorEntity.md b/rust/fatcat-openapi/docs/CreatorEntity.md
new file mode 100644
index 00000000..70d81a77
--- /dev/null
+++ b/rust/fatcat-openapi/docs/CreatorEntity.md
@@ -0,0 +1,20 @@
+# CreatorEntity
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**state** | **String** | | [optional] [default to None]
+**ident** | **String** | base32-encoded unique identifier | [optional] [default to None]
+**revision** | **String** | UUID (lower-case, dash-separated, hex-encoded 128-bit) | [optional] [default to None]
+**redirect** | **String** | base32-encoded unique identifier | [optional] [default to None]
+**extra** | [**std::collections::HashMap<String, serde_json::Value>**](object.md) | Free-form JSON metadata that will be stored with the other entity metadata. See guide for (unenforced) schema conventions. | [optional] [default to None]
+**edit_extra** | [**std::collections::HashMap<String, serde_json::Value>**](object.md) | Free-form JSON metadata that will be stored with specific entity edits (eg, creation/update/delete). | [optional] [default to None]
+**display_name** | **String** | Name as should be displayed in web interface or in author lists (not index/sorted). Required for valid entities. | [optional] [default to None]
+**given_name** | **String** | In English commonly the first name, but ordering is context and culture specific. | [optional] [default to None]
+**surname** | **String** | In English commonly the last, or family name, but ordering is context and culture specific. | [optional] [default to None]
+**orcid** | **String** | ORCiD (https://orcid.org) identifier | [optional] [default to None]
+**wikidata_qid** | **String** | Wikidata entity QID | [optional] [default to None]
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/rust/fatcat-openapi/docs/Editgroup.md b/rust/fatcat-openapi/docs/Editgroup.md
new file mode 100644
index 00000000..e07b2975
--- /dev/null
+++ b/rust/fatcat-openapi/docs/Editgroup.md
@@ -0,0 +1,19 @@
+# Editgroup
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**editgroup_id** | **String** | Fatcat identifier for this editgroup. Assigned on creation. | [optional] [default to None]
+**editor_id** | **String** | Fatcat identifer of editor that created this editgroup. | [optional] [default to None]
+**editor** | [***models::Editor**](editor.md) | | [optional] [default to None]
+**changelog_index** | **i64** | For accepted/merged editgroups, the changelog index that the accept occured at. WARNING: not populated in all contexts that an editgroup could be included in a response. | [optional] [default to None]
+**created** | [**chrono::DateTime::<chrono::Utc>**](DateTime.md) | Timestamp when this editgroup was first created. | [optional] [default to None]
+**submitted** | [**chrono::DateTime::<chrono::Utc>**](DateTime.md) | Timestamp when this editgroup was most recently submitted for review. If withdrawn, or never submitted, will be `null`. | [optional] [default to None]
+**description** | **String** | Comment describing the changes in this editgroup. Can be updated with PUT request. | [optional] [default to None]
+**extra** | [**std::collections::HashMap<String, serde_json::Value>**](object.md) | Free-form JSON metadata attached to this editgroup. Eg, metadata provenance, or script user-agent details. See guide for (unenforced) schema norms. | [optional] [default to None]
+**annotations** | [**Vec<models::EditgroupAnnotation>**](editgroup_annotation.md) | Only included in GET responses, and not in all contexts. Do not include this field in PUT or POST requests. | [optional] [default to None]
+**edits** | [***models::EditgroupEdits**](editgroup_edits.md) | | [optional] [default to None]
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/rust/fatcat-openapi/docs/EditgroupAnnotation.md b/rust/fatcat-openapi/docs/EditgroupAnnotation.md
new file mode 100644
index 00000000..277fa83f
--- /dev/null
+++ b/rust/fatcat-openapi/docs/EditgroupAnnotation.md
@@ -0,0 +1,16 @@
+# EditgroupAnnotation
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**annotation_id** | **String** | UUID (lower-case, dash-separated, hex-encoded 128-bit) | [optional] [default to None]
+**editgroup_id** | **String** | Editgroup that this annotation applies to. Set automatically in creations based on URL parameter. | [optional] [default to None]
+**editor_id** | **String** | Defaults to editor created the annotation via POST request. | [optional] [default to None]
+**editor** | [***models::Editor**](editor.md) | | [optional] [default to None]
+**created** | [**chrono::DateTime::<chrono::Utc>**](DateTime.md) | Timestamp when annotation was first created. | [optional] [default to None]
+**comment_markdown** | **String** | | [optional] [default to None]
+**extra** | [**std::collections::HashMap<String, serde_json::Value>**](object.md) | Additional free-form JSON metadata that can be included as part of the annotation (or even as the primary annotation itself). See guide for details. | [optional] [default to None]
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/rust/fatcat-openapi/docs/EditgroupEdits.md b/rust/fatcat-openapi/docs/EditgroupEdits.md
new file mode 100644
index 00000000..cb3cd821
--- /dev/null
+++ b/rust/fatcat-openapi/docs/EditgroupEdits.md
@@ -0,0 +1,16 @@
+# EditgroupEdits
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**containers** | [**Vec<models::EntityEdit>**](entity_edit.md) | | [optional] [default to None]
+**creators** | [**Vec<models::EntityEdit>**](entity_edit.md) | | [optional] [default to None]
+**files** | [**Vec<models::EntityEdit>**](entity_edit.md) | | [optional] [default to None]
+**filesets** | [**Vec<models::EntityEdit>**](entity_edit.md) | | [optional] [default to None]
+**webcaptures** | [**Vec<models::EntityEdit>**](entity_edit.md) | | [optional] [default to None]
+**releases** | [**Vec<models::EntityEdit>**](entity_edit.md) | | [optional] [default to None]
+**works** | [**Vec<models::EntityEdit>**](entity_edit.md) | | [optional] [default to None]
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/rust/fatcat-openapi/docs/Editor.md b/rust/fatcat-openapi/docs/Editor.md
new file mode 100644
index 00000000..4cf495fc
--- /dev/null
+++ b/rust/fatcat-openapi/docs/Editor.md
@@ -0,0 +1,14 @@
+# Editor
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**editor_id** | **String** | Fatcat identifier for the editor. Can not be changed. | [optional] [default to None]
+**username** | **String** | Username/handle (short slug-like string) to identify this editor. May be changed at any time by the editor; use the `editor_id` as a persistend identifer. |
+**is_admin** | **bool** | Whether this editor has the `admin` role. | [optional] [default to None]
+**is_bot** | **bool** | Whether this editor is a bot (as opposed to a human making manual edits) | [optional] [default to None]
+**is_active** | **bool** | Whether this editor's account is enabled (if not API tokens and web logins will not work). | [optional] [default to None]
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/rust/fatcat-openapi/docs/EntityEdit.md b/rust/fatcat-openapi/docs/EntityEdit.md
new file mode 100644
index 00000000..56e85816
--- /dev/null
+++ b/rust/fatcat-openapi/docs/EntityEdit.md
@@ -0,0 +1,16 @@
+# EntityEdit
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**edit_id** | **String** | Unique UUID for this specific edit object. |
+**ident** | **String** | Fatcat identifier of the entity this edit is mutating. |
+**revision** | **String** | Entity revision that this edit will set the entity to. May be `null` in the case of deletions. | [optional] [default to None]
+**prev_revision** | **String** | Revision of entity just before this edit. May be used in the future to prevent edit race conditions. | [optional] [default to None]
+**redirect_ident** | **String** | When an edit is to merge entities (redirect one to another), this is the entity fatcat identifier for the target entity. | [optional] [default to None]
+**editgroup_id** | **String** | Editgroup identifier that this edit is part of. |
+**extra** | [**std::collections::HashMap<String, serde_json::Value>**](object.md) | | [optional] [default to None]
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/rust/fatcat-openapi/docs/EntityHistoryEntry.md b/rust/fatcat-openapi/docs/EntityHistoryEntry.md
new file mode 100644
index 00000000..4df6b5f6
--- /dev/null
+++ b/rust/fatcat-openapi/docs/EntityHistoryEntry.md
@@ -0,0 +1,12 @@
+# EntityHistoryEntry
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**edit** | [***models::EntityEdit**](entity_edit.md) | |
+**editgroup** | [***models::Editgroup**](editgroup.md) | |
+**changelog_entry** | [***models::ChangelogEntry**](changelog_entry.md) | |
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/rust/fatcat-openapi/docs/ErrorResponse.md b/rust/fatcat-openapi/docs/ErrorResponse.md
new file mode 100644
index 00000000..89008f1e
--- /dev/null
+++ b/rust/fatcat-openapi/docs/ErrorResponse.md
@@ -0,0 +1,12 @@
+# ErrorResponse
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**success** | **bool** | |
+**error** | **String** | |
+**message** | **String** | |
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/rust/fatcat-openapi/docs/FileAutoBatch.md b/rust/fatcat-openapi/docs/FileAutoBatch.md
new file mode 100644
index 00000000..d45685ea
--- /dev/null
+++ b/rust/fatcat-openapi/docs/FileAutoBatch.md
@@ -0,0 +1,11 @@
+# FileAutoBatch
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**editgroup** | [***models::Editgroup**](editgroup.md) | |
+**entity_list** | [**Vec<models::FileEntity>**](file_entity.md) | |
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/rust/fatcat-openapi/docs/FileEntity.md b/rust/fatcat-openapi/docs/FileEntity.md
new file mode 100644
index 00000000..f65f342d
--- /dev/null
+++ b/rust/fatcat-openapi/docs/FileEntity.md
@@ -0,0 +1,23 @@
+# FileEntity
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**state** | **String** | | [optional] [default to None]
+**ident** | **String** | base32-encoded unique identifier | [optional] [default to None]
+**revision** | **String** | UUID (lower-case, dash-separated, hex-encoded 128-bit) | [optional] [default to None]
+**redirect** | **String** | base32-encoded unique identifier | [optional] [default to None]
+**extra** | [**std::collections::HashMap<String, serde_json::Value>**](object.md) | Free-form JSON metadata that will be stored with the other entity metadata. See guide for (unenforced) schema conventions. | [optional] [default to None]
+**edit_extra** | [**std::collections::HashMap<String, serde_json::Value>**](object.md) | Free-form JSON metadata that will be stored with specific entity edits (eg, creation/update/delete). | [optional] [default to None]
+**size** | **i64** | Size of file in bytes. Non-zero. | [optional] [default to None]
+**md5** | **String** | MD5 hash of data, in hex encoding | [optional] [default to None]
+**sha1** | **String** | SHA-1 hash of data, in hex encoding | [optional] [default to None]
+**sha256** | **String** | SHA-256 hash of data, in hex encoding | [optional] [default to None]
+**urls** | [**Vec<models::FileUrl>**](file_url.md) | | [optional] [default to None]
+**mimetype** | **String** | | [optional] [default to None]
+**release_ids** | **Vec<String>** | Set of identifier of release entities this file represents a full manifestation of. Usually a single release, but some files contain content of multiple full releases (eg, an issue of a journal). | [optional] [default to None]
+**releases** | [**Vec<models::ReleaseEntity>**](release_entity.md) | Full release entities, included in GET responses when `releases` included in `expand` parameter. Ignored if included in PUT or POST requests. | [optional] [default to None]
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/rust/fatcat-openapi/docs/FileUrl.md b/rust/fatcat-openapi/docs/FileUrl.md
new file mode 100644
index 00000000..89a832e1
--- /dev/null
+++ b/rust/fatcat-openapi/docs/FileUrl.md
@@ -0,0 +1,11 @@
+# FileUrl
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**url** | **String** | URL/URI pointing directly to a machine retrievable copy of this exact file. |
+**rel** | **String** | Indicates type of host this URL points to. Eg, \"publisher\", \"repository\", \"webarchive\". See guide for list of acceptable values. |
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/rust/fatcat-openapi/docs/FilesetAutoBatch.md b/rust/fatcat-openapi/docs/FilesetAutoBatch.md
new file mode 100644
index 00000000..df41e6ba
--- /dev/null
+++ b/rust/fatcat-openapi/docs/FilesetAutoBatch.md
@@ -0,0 +1,11 @@
+# FilesetAutoBatch
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**editgroup** | [***models::Editgroup**](editgroup.md) | |
+**entity_list** | [**Vec<models::FilesetEntity>**](fileset_entity.md) | |
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/rust/fatcat-openapi/docs/FilesetEntity.md b/rust/fatcat-openapi/docs/FilesetEntity.md
new file mode 100644
index 00000000..15fde4d6
--- /dev/null
+++ b/rust/fatcat-openapi/docs/FilesetEntity.md
@@ -0,0 +1,19 @@
+# FilesetEntity
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**state** | **String** | | [optional] [default to None]
+**ident** | **String** | base32-encoded unique identifier | [optional] [default to None]
+**revision** | **String** | UUID (lower-case, dash-separated, hex-encoded 128-bit) | [optional] [default to None]
+**redirect** | **String** | base32-encoded unique identifier | [optional] [default to None]
+**extra** | [**std::collections::HashMap<String, serde_json::Value>**](object.md) | Free-form JSON metadata that will be stored with the other entity metadata. See guide for (unenforced) schema conventions. | [optional] [default to None]
+**edit_extra** | [**std::collections::HashMap<String, serde_json::Value>**](object.md) | Free-form JSON metadata that will be stored with specific entity edits (eg, creation/update/delete). | [optional] [default to None]
+**manifest** | [**Vec<models::FilesetFile>**](fileset_file.md) | | [optional] [default to None]
+**urls** | [**Vec<models::FilesetUrl>**](fileset_url.md) | | [optional] [default to None]
+**release_ids** | **Vec<String>** | Set of identifier of release entities this fileset represents a full manifestation of. Usually a single release. | [optional] [default to None]
+**releases** | [**Vec<models::ReleaseEntity>**](release_entity.md) | Full release entities, included in GET responses when `releases` included in `expand` parameter. Ignored if included in PUT or POST requests. | [optional] [default to None]
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/rust/fatcat-openapi/docs/FilesetFile.md b/rust/fatcat-openapi/docs/FilesetFile.md
new file mode 100644
index 00000000..9f2a4a49
--- /dev/null
+++ b/rust/fatcat-openapi/docs/FilesetFile.md
@@ -0,0 +1,15 @@
+# FilesetFile
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**path** | **String** | Path name of file within this fileset (eg, directory) |
+**size** | **i64** | File size in bytes |
+**md5** | **String** | MD5 hash of data, in hex encoding | [optional] [default to None]
+**sha1** | **String** | SHA-1 hash of data, in hex encoding | [optional] [default to None]
+**sha256** | **String** | SHA-256 hash of data, in hex encoding | [optional] [default to None]
+**extra** | [**std::collections::HashMap<String, serde_json::Value>**](object.md) | Free-form additional metadata about this specific file in the set. Eg, `mimetype`. See guide for nomative (but unenforced) schema fields. | [optional] [default to None]
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/rust/fatcat-openapi/docs/FilesetUrl.md b/rust/fatcat-openapi/docs/FilesetUrl.md
new file mode 100644
index 00000000..2c38760c
--- /dev/null
+++ b/rust/fatcat-openapi/docs/FilesetUrl.md
@@ -0,0 +1,11 @@
+# FilesetUrl
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**url** | **String** | |
+**rel** | **String** | Indicates type of host this URL points to. See guide for list of acceptable values. |
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/rust/fatcat-openapi/docs/ReleaseAbstract.md b/rust/fatcat-openapi/docs/ReleaseAbstract.md
new file mode 100644
index 00000000..32f9bdc6
--- /dev/null
+++ b/rust/fatcat-openapi/docs/ReleaseAbstract.md
@@ -0,0 +1,13 @@
+# ReleaseAbstract
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**sha1** | **String** | SHA-1 hash of data, in hex encoding | [optional] [default to None]
+**content** | **String** | Abstract content. May be encoded, as per `mimetype` field, but only string/text content may be included. | [optional] [default to None]
+**mimetype** | **String** | Mimetype of abstract contents. `text/plain` is the default if content isn't encoded. | [optional] [default to None]
+**lang** | **String** | ISO language code of the abstract. Same semantics as release `language` field. | [optional] [default to None]
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/rust/fatcat-openapi/docs/ReleaseAutoBatch.md b/rust/fatcat-openapi/docs/ReleaseAutoBatch.md
new file mode 100644
index 00000000..8f60344d
--- /dev/null
+++ b/rust/fatcat-openapi/docs/ReleaseAutoBatch.md
@@ -0,0 +1,11 @@
+# ReleaseAutoBatch
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**editgroup** | [***models::Editgroup**](editgroup.md) | |
+**entity_list** | [**Vec<models::ReleaseEntity>**](release_entity.md) | |
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/rust/fatcat-openapi/docs/ReleaseContrib.md b/rust/fatcat-openapi/docs/ReleaseContrib.md
new file mode 100644
index 00000000..3d9b43f8
--- /dev/null
+++ b/rust/fatcat-openapi/docs/ReleaseContrib.md
@@ -0,0 +1,18 @@
+# ReleaseContrib
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**index** | **i64** | Internally assigned zero-indexed sequence number of contribution. Authors should come first; this encodes the order of attriubtion. | [optional] [default to None]
+**creator_id** | **String** | If known, indicates the creator entity this contribution was made by. | [optional] [default to None]
+**creator** | [***models::CreatorEntity**](creator_entity.md) | | [optional] [default to None]
+**raw_name** | **String** | Full name of the contributor as typeset in the release. | [optional] [default to None]
+**given_name** | **String** | In English commonly the first name, but ordering is context and culture specific. | [optional] [default to None]
+**surname** | **String** | In English commonly the last, or family name, but ordering is context and culture specific. | [optional] [default to None]
+**role** | **String** | Short string (slug) indicating type of contribution (eg, \"author\", \"translator\"). See guide for list of accpeted values. | [optional] [default to None]
+**raw_affiliation** | **String** | Raw affiliation string as displayed in text | [optional] [default to None]
+**extra** | [**std::collections::HashMap<String, serde_json::Value>**](object.md) | Additional free-form JSON metadata about this contributor/contribution. See guide for normative schema. | [optional] [default to None]
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/rust/fatcat-openapi/docs/ReleaseEntity.md b/rust/fatcat-openapi/docs/ReleaseEntity.md
new file mode 100644
index 00000000..883441f0
--- /dev/null
+++ b/rust/fatcat-openapi/docs/ReleaseEntity.md
@@ -0,0 +1,43 @@
+# ReleaseEntity
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**state** | **String** | | [optional] [default to None]
+**ident** | **String** | base32-encoded unique identifier | [optional] [default to None]
+**revision** | **String** | UUID (lower-case, dash-separated, hex-encoded 128-bit) | [optional] [default to None]
+**redirect** | **String** | base32-encoded unique identifier | [optional] [default to None]
+**extra** | [**std::collections::HashMap<String, serde_json::Value>**](object.md) | Free-form JSON metadata that will be stored with the other entity metadata. See guide for (unenforced) schema conventions. | [optional] [default to None]
+**edit_extra** | [**std::collections::HashMap<String, serde_json::Value>**](object.md) | Free-form JSON metadata that will be stored with specific entity edits (eg, creation/update/delete). | [optional] [default to None]
+**title** | **String** | Required for valid entities. The title used in citations and for display. Sometimes the English translation of title e even if release content is not English. | [optional] [default to None]
+**subtitle** | **String** | Subtitle of release. In many cases, better to merge with title than include as separate field (unless combined title would be very long). See guide for details. | [optional] [default to None]
+**original_title** | **String** | Title in original language if `title` field has been translated. See guide for details. | [optional] [default to None]
+**work_id** | **String** | Identifier of work this release is part of. In creation (POST) requests, a work entity will be created automatically if this field is not set. | [optional] [default to None]
+**container** | [***models::ContainerEntity**](container_entity.md) | | [optional] [default to None]
+**files** | [**Vec<models::FileEntity>**](file_entity.md) | Complete file entities identified by `file_ids` field. Only included in GET responses when `files` included in `expand` parameter; ignored in PUT or POST requests. | [optional] [default to None]
+**filesets** | [**Vec<models::FilesetEntity>**](fileset_entity.md) | Complete file entities identified by `filesets_ids` field. Only included in GET responses when `filesets` included in `expand` parameter; ignored in PUT or POST requests. | [optional] [default to None]
+**webcaptures** | [**Vec<models::WebcaptureEntity>**](webcapture_entity.md) | Complete webcapture entities identified by `webcapture_ids` field. Only included in GET responses when `webcaptures` included in `expand` parameter; ignored in PUT or POST requests. | [optional] [default to None]
+**container_id** | **String** | Used to link this release to a container entity that the release was published as part of. | [optional] [default to None]
+**release_type** | **String** | \"Type\" or \"medium\" that this release is published as. See guide for valid values. | [optional] [default to None]
+**release_stage** | **String** | The stage of publication of this specific release. See guide for valid values and semantics. | [optional] [default to None]
+**release_date** | [***chrono::DateTime::<chrono::Utc>**](date.md) | Full date when this release was formally published. ISO format, like `2019-03-05`. See guide for semantics. | [optional] [default to None]
+**release_year** | **i64** | Year when this release was formally published. Must match `release_date` if that field is set; this field exists because sometimes only the year is known. | [optional] [default to None]
+**withdrawn_status** | **String** | Type of withdrawl or retraction of this release, if applicable. If release has not been withdrawn, should be `null` (aka, not set, not the string \"null\" or an empty string). | [optional] [default to None]
+**withdrawn_date** | [***chrono::DateTime::<chrono::Utc>**](date.md) | Full date when this release was formally withdrawn (if applicable). ISO format, like `release_date`. | [optional] [default to None]
+**withdrawn_year** | **i64** | Year corresponding with `withdrawn_date` like `release_year`/`release_date`. | [optional] [default to None]
+**ext_ids** | [***models::ReleaseExtIds**](release_ext_ids.md) | |
+**volume** | **String** | Volume number of container that this release was published in. Often corresponds to the \"Nth\" year of publication, but can be any string. See guide. | [optional] [default to None]
+**issue** | **String** | Issue number of volume/container that this release was published in. Sometimes coresponds to a month number in the year, but can be any string. See guide. | [optional] [default to None]
+**pages** | **String** | Either a single page number (\"first page\") or a range of pages separated by a dash (\"-\"). See guide for details. | [optional] [default to None]
+**number** | **String** | For, eg, technical reports, which are published in series or assigned some other institutional or container-specific identifier. | [optional] [default to None]
+**version** | **String** | For, eg, updated technical reports or software packages, where the version string may be the only field disambiguating between releases. | [optional] [default to None]
+**publisher** | **String** | Name, usually English, of the entity or institution responsible for publication of this release. Not necessarily the imprint/brand. See guide. | [optional] [default to None]
+**language** | **String** | Primary language of the content of the full release. Two-letter RFC1766/ISO639-1 language code, with some custom extensions/additions. See guide. | [optional] [default to None]
+**license_slug** | **String** | Short string (slug) name of license under which release is openly published (if applicable). | [optional] [default to None]
+**contribs** | [**Vec<models::ReleaseContrib>**](release_contrib.md) | | [optional] [default to None]
+**refs** | [**Vec<models::ReleaseRef>**](release_ref.md) | | [optional] [default to None]
+**abstracts** | [**Vec<models::ReleaseAbstract>**](release_abstract.md) | | [optional] [default to None]
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/rust/fatcat-openapi/docs/ReleaseExtIds.md b/rust/fatcat-openapi/docs/ReleaseExtIds.md
new file mode 100644
index 00000000..e790c9a7
--- /dev/null
+++ b/rust/fatcat-openapi/docs/ReleaseExtIds.md
@@ -0,0 +1,19 @@
+# ReleaseExtIds
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**doi** | **String** | Digital Object Identifier (DOI), mostly for published papers and datasets. Should be registered and resolvable via https://doi.org/ | [optional] [default to None]
+**wikidata_qid** | **String** | Wikidata entity QID | [optional] [default to None]
+**isbn13** | **String** | ISBN-13, for books. Usually not set for chapters. ISBN-10 should be converted to ISBN-13. | [optional] [default to None]
+**pmid** | **String** | PubMed Identifier | [optional] [default to None]
+**pmcid** | **String** | PubMed Central Identifier | [optional] [default to None]
+**core** | **String** | CORE (https://core.ac.uk) identifier | [optional] [default to None]
+**arxiv** | **String** | arXiv (https://arxiv.org) identifier; must include version | [optional] [default to None]
+**jstor** | **String** | JSTOR work identifier | [optional] [default to None]
+**ark** | **String** | ARK identifier | [optional] [default to None]
+**mag** | **String** | Microsoft Academic Graph identifier | [optional] [default to None]
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/rust/fatcat-openapi/docs/ReleaseRef.md b/rust/fatcat-openapi/docs/ReleaseRef.md
new file mode 100644
index 00000000..18f0b1b2
--- /dev/null
+++ b/rust/fatcat-openapi/docs/ReleaseRef.md
@@ -0,0 +1,17 @@
+# ReleaseRef
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**index** | **i64** | Zero-indexed sequence number of this reference in the list of references. Assigned automatically and used internally; don't confuse with `key`. | [optional] [default to None]
+**target_release_id** | **String** | Optional, fatcat identifier of release entity that this reference is citing. | [optional] [default to None]
+**extra** | [**std::collections::HashMap<String, serde_json::Value>**](object.md) | Additional free-form JSON metadata about this citation. Generally follows Citation Style Language (CSL) JSON schema. See guide for details. | [optional] [default to None]
+**key** | **String** | Short string used to indicate this reference from within the release text; or numbering of references as typeset in the release itself. Optional; don't confuse with `index` field. | [optional] [default to None]
+**year** | **i64** | Year that the cited work was published in. | [optional] [default to None]
+**container_name** | **String** | Name of the container (eg, journal) that the citation work was published as part of. May be an acronym or full name. | [optional] [default to None]
+**title** | **String** | Name of the work being cited. | [optional] [default to None]
+**locator** | **String** | Page number or other indicator of the specific subset of a work being cited. Not to be confused with the first page (or page range) of an entire paper or chapter being cited. | [optional] [default to None]
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/rust/fatcat-openapi/docs/Success.md b/rust/fatcat-openapi/docs/Success.md
new file mode 100644
index 00000000..1264ddb5
--- /dev/null
+++ b/rust/fatcat-openapi/docs/Success.md
@@ -0,0 +1,11 @@
+# Success
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**success** | **bool** | |
+**message** | **String** | |
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/rust/fatcat-openapi/docs/WebcaptureAutoBatch.md b/rust/fatcat-openapi/docs/WebcaptureAutoBatch.md
new file mode 100644
index 00000000..94bfbb20
--- /dev/null
+++ b/rust/fatcat-openapi/docs/WebcaptureAutoBatch.md
@@ -0,0 +1,11 @@
+# WebcaptureAutoBatch
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**editgroup** | [***models::Editgroup**](editgroup.md) | |
+**entity_list** | [**Vec<models::WebcaptureEntity>**](webcapture_entity.md) | |
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/rust/fatcat-openapi/docs/WebcaptureCdxLine.md b/rust/fatcat-openapi/docs/WebcaptureCdxLine.md
new file mode 100644
index 00000000..9f1ef490
--- /dev/null
+++ b/rust/fatcat-openapi/docs/WebcaptureCdxLine.md
@@ -0,0 +1,17 @@
+# WebcaptureCdxLine
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**surt** | **String** | \"Sortable URL\" format. See guide for details. |
+**timestamp** | [**chrono::DateTime::<chrono::Utc>**](DateTime.md) | Date and time of capture, in ISO format. UTC, 'Z'-terminated, second (or better) precision. |
+**url** | **String** | Full URL/URI of resource captured. |
+**mimetype** | **String** | Mimetype of the resource at this URL. May be the Content-Type header, or the actually sniffed file type. | [optional] [default to None]
+**status_code** | **i64** | HTTP status code. Should generally be 200, especially for the primary resource, but may be 3xx (redirect) or even error codes if embedded resources can not be fetched successfully. | [optional] [default to None]
+**size** | **i64** | Resource (file) size in bytes | [optional] [default to None]
+**sha1** | **String** | SHA-1 hash of data, in hex encoding |
+**sha256** | **String** | SHA-256 hash of data, in hex encoding | [optional] [default to None]
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/rust/fatcat-openapi/docs/WebcaptureEntity.md b/rust/fatcat-openapi/docs/WebcaptureEntity.md
new file mode 100644
index 00000000..1d5eeff1
--- /dev/null
+++ b/rust/fatcat-openapi/docs/WebcaptureEntity.md
@@ -0,0 +1,21 @@
+# WebcaptureEntity
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**state** | **String** | | [optional] [default to None]
+**ident** | **String** | base32-encoded unique identifier | [optional] [default to None]
+**revision** | **String** | UUID (lower-case, dash-separated, hex-encoded 128-bit) | [optional] [default to None]
+**redirect** | **String** | base32-encoded unique identifier | [optional] [default to None]
+**extra** | [**std::collections::HashMap<String, serde_json::Value>**](object.md) | Free-form JSON metadata that will be stored with the other entity metadata. See guide for (unenforced) schema conventions. | [optional] [default to None]
+**edit_extra** | [**std::collections::HashMap<String, serde_json::Value>**](object.md) | Free-form JSON metadata that will be stored with specific entity edits (eg, creation/update/delete). | [optional] [default to None]
+**cdx** | [**Vec<models::WebcaptureCdxLine>**](webcapture_cdx_line.md) | | [optional] [default to None]
+**archive_urls** | [**Vec<models::WebcaptureUrl>**](webcapture_url.md) | | [optional] [default to None]
+**original_url** | **String** | Base URL of the primary resource this is a capture of | [optional] [default to None]
+**timestamp** | [**chrono::DateTime::<chrono::Utc>**](DateTime.md) | Same format as CDX line timestamp (UTC, etc). Corresponds to the overall capture timestamp. Should generally be the timestamp of capture of the primary resource URL. | [optional] [default to None]
+**release_ids** | **Vec<String>** | Set of identifier of release entities this fileset represents a full manifestation of. Usually a single release. | [optional] [default to None]
+**releases** | [**Vec<models::ReleaseEntity>**](release_entity.md) | Full release entities, included in GET responses when `releases` included in `expand` parameter. Ignored if included in PUT or POST requests. | [optional] [default to None]
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/rust/fatcat-openapi/docs/WebcaptureUrl.md b/rust/fatcat-openapi/docs/WebcaptureUrl.md
new file mode 100644
index 00000000..fd21e928
--- /dev/null
+++ b/rust/fatcat-openapi/docs/WebcaptureUrl.md
@@ -0,0 +1,11 @@
+# WebcaptureUrl
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**url** | **String** | URL/URI pointing to archive of this web resource. |
+**rel** | **String** | Type of archive endpoint. Usually `wayback` (WBM replay of primary resource), or `warc` (direct URL to a WARC file containing all resources of the capture). See guide for full list. |
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/rust/fatcat-openapi/docs/WorkAutoBatch.md b/rust/fatcat-openapi/docs/WorkAutoBatch.md
new file mode 100644
index 00000000..a508d1db
--- /dev/null
+++ b/rust/fatcat-openapi/docs/WorkAutoBatch.md
@@ -0,0 +1,11 @@
+# WorkAutoBatch
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**editgroup** | [***models::Editgroup**](editgroup.md) | |
+**entity_list** | [**Vec<models::WorkEntity>**](work_entity.md) | |
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/rust/fatcat-openapi/docs/WorkEntity.md b/rust/fatcat-openapi/docs/WorkEntity.md
new file mode 100644
index 00000000..83bfb45d
--- /dev/null
+++ b/rust/fatcat-openapi/docs/WorkEntity.md
@@ -0,0 +1,15 @@
+# WorkEntity
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**state** | **String** | | [optional] [default to None]
+**ident** | **String** | base32-encoded unique identifier | [optional] [default to None]
+**revision** | **String** | UUID (lower-case, dash-separated, hex-encoded 128-bit) | [optional] [default to None]
+**redirect** | **String** | base32-encoded unique identifier | [optional] [default to None]
+**extra** | [**std::collections::HashMap<String, serde_json::Value>**](object.md) | Free-form JSON metadata that will be stored with the other entity metadata. See guide for (unenforced) schema conventions. | [optional] [default to None]
+**edit_extra** | [**std::collections::HashMap<String, serde_json::Value>**](object.md) | Free-form JSON metadata that will be stored with specific entity edits (eg, creation/update/delete). | [optional] [default to None]
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/rust/fatcat-openapi/docs/default_api.md b/rust/fatcat-openapi/docs/default_api.md
new file mode 100644
index 00000000..a1ce60ee
--- /dev/null
+++ b/rust/fatcat-openapi/docs/default_api.md
@@ -0,0 +1,3016 @@
+# default_api
+
+All URIs are relative to *https://api.fatcat.wiki/v0*
+
+Method | HTTP request | Description
+------------- | ------------- | -------------
+**accept_editgroup**](default_api.md#accept_editgroup) | **POST** /editgroup/{editgroup_id}/accept |
+**auth_check**](default_api.md#auth_check) | **GET** /auth/check |
+**auth_oidc**](default_api.md#auth_oidc) | **POST** /auth/oidc |
+**create_auth_token**](default_api.md#create_auth_token) | **POST** /auth/token/{editor_id} |
+**create_container**](default_api.md#create_container) | **POST** /editgroup/{editgroup_id}/container |
+**create_container_auto_batch**](default_api.md#create_container_auto_batch) | **POST** /editgroup/auto/container/batch |
+**create_creator**](default_api.md#create_creator) | **POST** /editgroup/{editgroup_id}/creator |
+**create_creator_auto_batch**](default_api.md#create_creator_auto_batch) | **POST** /editgroup/auto/creator/batch |
+**create_editgroup**](default_api.md#create_editgroup) | **POST** /editgroup |
+**create_editgroup_annotation**](default_api.md#create_editgroup_annotation) | **POST** /editgroup/{editgroup_id}/annotation |
+**create_file**](default_api.md#create_file) | **POST** /editgroup/{editgroup_id}/file |
+**create_file_auto_batch**](default_api.md#create_file_auto_batch) | **POST** /editgroup/auto/file/batch |
+**create_fileset**](default_api.md#create_fileset) | **POST** /editgroup/{editgroup_id}/fileset |
+**create_fileset_auto_batch**](default_api.md#create_fileset_auto_batch) | **POST** /editgroup/auto/fileset/batch |
+**create_release**](default_api.md#create_release) | **POST** /editgroup/{editgroup_id}/release |
+**create_release_auto_batch**](default_api.md#create_release_auto_batch) | **POST** /editgroup/auto/release/batch |
+**create_webcapture**](default_api.md#create_webcapture) | **POST** /editgroup/{editgroup_id}/webcapture |
+**create_webcapture_auto_batch**](default_api.md#create_webcapture_auto_batch) | **POST** /editgroup/auto/webcapture/batch |
+**create_work**](default_api.md#create_work) | **POST** /editgroup/{editgroup_id}/work |
+**create_work_auto_batch**](default_api.md#create_work_auto_batch) | **POST** /editgroup/auto/work/batch |
+**delete_container**](default_api.md#delete_container) | **DELETE** /editgroup/{editgroup_id}/container/{ident} |
+**delete_container_edit**](default_api.md#delete_container_edit) | **DELETE** /editgroup/{editgroup_id}/container/edit/{edit_id} |
+**delete_creator**](default_api.md#delete_creator) | **DELETE** /editgroup/{editgroup_id}/creator/{ident} |
+**delete_creator_edit**](default_api.md#delete_creator_edit) | **DELETE** /editgroup/{editgroup_id}/creator/edit/{edit_id} |
+**delete_file**](default_api.md#delete_file) | **DELETE** /editgroup/{editgroup_id}/file/{ident} |
+**delete_file_edit**](default_api.md#delete_file_edit) | **DELETE** /editgroup/{editgroup_id}/file/edit/{edit_id} |
+**delete_fileset**](default_api.md#delete_fileset) | **DELETE** /editgroup/{editgroup_id}/fileset/{ident} |
+**delete_fileset_edit**](default_api.md#delete_fileset_edit) | **DELETE** /editgroup/{editgroup_id}/fileset/edit/{edit_id} |
+**delete_release**](default_api.md#delete_release) | **DELETE** /editgroup/{editgroup_id}/release/{ident} |
+**delete_release_edit**](default_api.md#delete_release_edit) | **DELETE** /editgroup/{editgroup_id}/release/edit/{edit_id} |
+**delete_webcapture**](default_api.md#delete_webcapture) | **DELETE** /editgroup/{editgroup_id}/webcapture/{ident} |
+**delete_webcapture_edit**](default_api.md#delete_webcapture_edit) | **DELETE** /editgroup/{editgroup_id}/webcapture/edit/{edit_id} |
+**delete_work**](default_api.md#delete_work) | **DELETE** /editgroup/{editgroup_id}/work/{ident} |
+**delete_work_edit**](default_api.md#delete_work_edit) | **DELETE** /editgroup/{editgroup_id}/work/edit/{edit_id} |
+**get_changelog**](default_api.md#get_changelog) | **GET** /changelog |
+**get_changelog_entry**](default_api.md#get_changelog_entry) | **GET** /changelog/{index} |
+**get_container**](default_api.md#get_container) | **GET** /container/{ident} |
+**get_container_edit**](default_api.md#get_container_edit) | **GET** /container/edit/{edit_id} |
+**get_container_history**](default_api.md#get_container_history) | **GET** /container/{ident}/history |
+**get_container_redirects**](default_api.md#get_container_redirects) | **GET** /container/{ident}/redirects |
+**get_container_revision**](default_api.md#get_container_revision) | **GET** /container/rev/{rev_id} |
+**get_creator**](default_api.md#get_creator) | **GET** /creator/{ident} |
+**get_creator_edit**](default_api.md#get_creator_edit) | **GET** /creator/edit/{edit_id} |
+**get_creator_history**](default_api.md#get_creator_history) | **GET** /creator/{ident}/history |
+**get_creator_redirects**](default_api.md#get_creator_redirects) | **GET** /creator/{ident}/redirects |
+**get_creator_releases**](default_api.md#get_creator_releases) | **GET** /creator/{ident}/releases |
+**get_creator_revision**](default_api.md#get_creator_revision) | **GET** /creator/rev/{rev_id} |
+**get_editgroup**](default_api.md#get_editgroup) | **GET** /editgroup/{editgroup_id} |
+**get_editgroup_annotations**](default_api.md#get_editgroup_annotations) | **GET** /editgroup/{editgroup_id}/annotations |
+**get_editgroups_reviewable**](default_api.md#get_editgroups_reviewable) | **GET** /editgroup/reviewable |
+**get_editor**](default_api.md#get_editor) | **GET** /editor/{editor_id} |
+**get_editor_annotations**](default_api.md#get_editor_annotations) | **GET** /editor/{editor_id}/annotations |
+**get_editor_editgroups**](default_api.md#get_editor_editgroups) | **GET** /editor/{editor_id}/editgroups |
+**get_file**](default_api.md#get_file) | **GET** /file/{ident} |
+**get_file_edit**](default_api.md#get_file_edit) | **GET** /file/edit/{edit_id} |
+**get_file_history**](default_api.md#get_file_history) | **GET** /file/{ident}/history |
+**get_file_redirects**](default_api.md#get_file_redirects) | **GET** /file/{ident}/redirects |
+**get_file_revision**](default_api.md#get_file_revision) | **GET** /file/rev/{rev_id} |
+**get_fileset**](default_api.md#get_fileset) | **GET** /fileset/{ident} |
+**get_fileset_edit**](default_api.md#get_fileset_edit) | **GET** /fileset/edit/{edit_id} |
+**get_fileset_history**](default_api.md#get_fileset_history) | **GET** /fileset/{ident}/history |
+**get_fileset_redirects**](default_api.md#get_fileset_redirects) | **GET** /fileset/{ident}/redirects |
+**get_fileset_revision**](default_api.md#get_fileset_revision) | **GET** /fileset/rev/{rev_id} |
+**get_release**](default_api.md#get_release) | **GET** /release/{ident} |
+**get_release_edit**](default_api.md#get_release_edit) | **GET** /release/edit/{edit_id} |
+**get_release_files**](default_api.md#get_release_files) | **GET** /release/{ident}/files |
+**get_release_filesets**](default_api.md#get_release_filesets) | **GET** /release/{ident}/filesets |
+**get_release_history**](default_api.md#get_release_history) | **GET** /release/{ident}/history |
+**get_release_redirects**](default_api.md#get_release_redirects) | **GET** /release/{ident}/redirects |
+**get_release_revision**](default_api.md#get_release_revision) | **GET** /release/rev/{rev_id} |
+**get_release_webcaptures**](default_api.md#get_release_webcaptures) | **GET** /release/{ident}/webcaptures |
+**get_webcapture**](default_api.md#get_webcapture) | **GET** /webcapture/{ident} |
+**get_webcapture_edit**](default_api.md#get_webcapture_edit) | **GET** /webcapture/edit/{edit_id} |
+**get_webcapture_history**](default_api.md#get_webcapture_history) | **GET** /webcapture/{ident}/history |
+**get_webcapture_redirects**](default_api.md#get_webcapture_redirects) | **GET** /webcapture/{ident}/redirects |
+**get_webcapture_revision**](default_api.md#get_webcapture_revision) | **GET** /webcapture/rev/{rev_id} |
+**get_work**](default_api.md#get_work) | **GET** /work/{ident} |
+**get_work_edit**](default_api.md#get_work_edit) | **GET** /work/edit/{edit_id} |
+**get_work_history**](default_api.md#get_work_history) | **GET** /work/{ident}/history |
+**get_work_redirects**](default_api.md#get_work_redirects) | **GET** /work/{ident}/redirects |
+**get_work_releases**](default_api.md#get_work_releases) | **GET** /work/{ident}/releases |
+**get_work_revision**](default_api.md#get_work_revision) | **GET** /work/rev/{rev_id} |
+**lookup_container**](default_api.md#lookup_container) | **GET** /container/lookup |
+**lookup_creator**](default_api.md#lookup_creator) | **GET** /creator/lookup |
+**lookup_file**](default_api.md#lookup_file) | **GET** /file/lookup |
+**lookup_release**](default_api.md#lookup_release) | **GET** /release/lookup |
+**update_container**](default_api.md#update_container) | **PUT** /editgroup/{editgroup_id}/container/{ident} |
+**update_creator**](default_api.md#update_creator) | **PUT** /editgroup/{editgroup_id}/creator/{ident} |
+**update_editgroup**](default_api.md#update_editgroup) | **PUT** /editgroup/{editgroup_id} |
+**update_editor**](default_api.md#update_editor) | **PUT** /editor/{editor_id} |
+**update_file**](default_api.md#update_file) | **PUT** /editgroup/{editgroup_id}/file/{ident} |
+**update_fileset**](default_api.md#update_fileset) | **PUT** /editgroup/{editgroup_id}/fileset/{ident} |
+**update_release**](default_api.md#update_release) | **PUT** /editgroup/{editgroup_id}/release/{ident} |
+**update_webcapture**](default_api.md#update_webcapture) | **PUT** /editgroup/{editgroup_id}/webcapture/{ident} |
+**update_work**](default_api.md#update_work) | **PUT** /editgroup/{editgroup_id}/work/{ident} |
+
+
+# **accept_editgroup**
+> models::Success accept_editgroup(ctx, editgroup_id)
+
+
+Accept (\"merge\") the given editgroup into the catalog. The editgroup must be open (not already accepted), and the editor making this request must have the `admin` role.
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **editgroup_id** | **String**| base32-encoded unique identifier |
+
+### Return type
+
+[**models::Success**](success.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **auth_check**
+> models::Success auth_check(ctx, optional)
+
+
+Verify that authentication (API token) is working as expected. The optional `role` parameter can be used to verify that the current account (editor) has permissions for the given role.
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **optional** | **map[string]interface{}** | optional parameters | nil if no parameters
+
+### Optional Parameters
+Optional parameters are passed through a map[string]interface{}.
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **role** | **String**| |
+
+### Return type
+
+[**models::Success**](success.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **auth_oidc**
+> models::AuthOidcResult auth_oidc(ctx, oidc_params)
+
+
+Login or create editor account using OIDC metadata (internal method). This method is used by privileged front-end tools (like the web interface service) to process editor logins using OpenID Connect (OIDC) and/or OAuth. Most accounts (including tool and bot accounts) do not have sufficient privileges to call this method, which requires the `admin` role. The method returns an API token; the HTTP status code indicates whether an existing account was logged in, or a new account was created.
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **oidc_params** | [**AuthOidc**](AuthOidc.md)| |
+
+### Return type
+
+[**models::AuthOidcResult**](auth_oidc_result.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: application/json
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **create_auth_token**
+> models::AuthTokenResult create_auth_token(ctx, editor_id, optional)
+
+
+Generate a new auth token for a given editor (internal method). This method is used by the web interface to generate API tokens for users. It can not be called by editors (human or bot) to generate new tokens for themselves, at least at this time.
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **editor_id** | **String**| |
+ **optional** | **map[string]interface{}** | optional parameters | nil if no parameters
+
+### Optional Parameters
+Optional parameters are passed through a map[string]interface{}.
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **editor_id** | **String**| |
+ **duration_seconds** | **i32**| How long API token should be valid for (in seconds) |
+
+### Return type
+
+[**models::AuthTokenResult**](auth_token_result.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **create_container**
+> models::EntityEdit create_container(ctx, editgroup_id, entity)
+
+
+Create a single Container entity as part of an existing editgroup. Editgroup must be mutable (aka, not accepted) and editor must have permission (aka, have created the editgroup or have `admin` role).
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **editgroup_id** | **String**| |
+ **entity** | [**ContainerEntity**](ContainerEntity.md)| |
+
+### Return type
+
+[**models::EntityEdit**](entity_edit.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: application/json
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **create_container_auto_batch**
+> models::Editgroup create_container_auto_batch(ctx, auto_batch)
+
+
+Create a set of Container entities as part of a new editgroup, and accept that editgroup in the same atomic request. This method is mostly useful for bulk import of new entities by carefully written bots. This method is more efficient than creating an editgroup, several entities, then accepting the editgroup, both in terms of API requests required and database load. Requires `admin` role.
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **auto_batch** | [**ContainerAutoBatch**](ContainerAutoBatch.md)| |
+
+### Return type
+
+[**models::Editgroup**](editgroup.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: application/json
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **create_creator**
+> models::EntityEdit create_creator(ctx, editgroup_id, entity)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **editgroup_id** | **String**| |
+ **entity** | [**CreatorEntity**](CreatorEntity.md)| |
+
+### Return type
+
+[**models::EntityEdit**](entity_edit.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: application/json
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **create_creator_auto_batch**
+> models::Editgroup create_creator_auto_batch(ctx, auto_batch)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **auto_batch** | [**CreatorAutoBatch**](CreatorAutoBatch.md)| |
+
+### Return type
+
+[**models::Editgroup**](editgroup.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: application/json
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **create_editgroup**
+> models::Editgroup create_editgroup(ctx, editgroup)
+
+
+Creates a new editgroup. By default the editor making this request will be the author of the editgroup.
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **editgroup** | [**Editgroup**](Editgroup.md)| |
+
+### Return type
+
+[**models::Editgroup**](editgroup.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: application/json
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **create_editgroup_annotation**
+> models::EditgroupAnnotation create_editgroup_annotation(ctx, editgroup_id, annotation)
+
+
+Submits a new annotation to the specified editgroup. The editgroup must be open (not already accepted). The annotation will automatically have authorship of the editor making this request.
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **editgroup_id** | **String**| base32-encoded unique identifier |
+ **annotation** | [**EditgroupAnnotation**](EditgroupAnnotation.md)| |
+
+### Return type
+
+[**models::EditgroupAnnotation**](editgroup_annotation.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: application/json
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **create_file**
+> models::EntityEdit create_file(ctx, editgroup_id, entity)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **editgroup_id** | **String**| |
+ **entity** | [**FileEntity**](FileEntity.md)| |
+
+### Return type
+
+[**models::EntityEdit**](entity_edit.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: application/json
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **create_file_auto_batch**
+> models::Editgroup create_file_auto_batch(ctx, auto_batch)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **auto_batch** | [**FileAutoBatch**](FileAutoBatch.md)| |
+
+### Return type
+
+[**models::Editgroup**](editgroup.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: application/json
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **create_fileset**
+> models::EntityEdit create_fileset(ctx, editgroup_id, entity)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **editgroup_id** | **String**| |
+ **entity** | [**FilesetEntity**](FilesetEntity.md)| |
+
+### Return type
+
+[**models::EntityEdit**](entity_edit.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: application/json
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **create_fileset_auto_batch**
+> models::Editgroup create_fileset_auto_batch(ctx, auto_batch)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **auto_batch** | [**FilesetAutoBatch**](FilesetAutoBatch.md)| |
+
+### Return type
+
+[**models::Editgroup**](editgroup.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: application/json
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **create_release**
+> models::EntityEdit create_release(ctx, editgroup_id, entity)
+
+
+Create a single Release entity as part of an existing editgroup. If the `work_id` field is not set, a work entity will be created automatically and this field set pointing to the new work. Editgroup must be mutable (aka, not accepted) and editor must have permission (aka, have created the editgrou p or have `admin` role).
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **editgroup_id** | **String**| |
+ **entity** | [**ReleaseEntity**](ReleaseEntity.md)| |
+
+### Return type
+
+[**models::EntityEdit**](entity_edit.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: application/json
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **create_release_auto_batch**
+> models::Editgroup create_release_auto_batch(ctx, auto_batch)
+
+
+Create a set of Release entities as part of a new editgroup, and accept that editgroup in the same atomic request. This method is mostly useful for bulk import of new entities by carefully written bots. This method is more efficient than creating an editgroup, several entities, then accepting the editgroup, both in terms of API requests required and database load. Requires `admin` role.
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **auto_batch** | [**ReleaseAutoBatch**](ReleaseAutoBatch.md)| |
+
+### Return type
+
+[**models::Editgroup**](editgroup.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: application/json
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **create_webcapture**
+> models::EntityEdit create_webcapture(ctx, editgroup_id, entity)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **editgroup_id** | **String**| |
+ **entity** | [**WebcaptureEntity**](WebcaptureEntity.md)| |
+
+### Return type
+
+[**models::EntityEdit**](entity_edit.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: application/json
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **create_webcapture_auto_batch**
+> models::Editgroup create_webcapture_auto_batch(ctx, auto_batch)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **auto_batch** | [**WebcaptureAutoBatch**](WebcaptureAutoBatch.md)| |
+
+### Return type
+
+[**models::Editgroup**](editgroup.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: application/json
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **create_work**
+> models::EntityEdit create_work(ctx, editgroup_id, entity)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **editgroup_id** | **String**| |
+ **entity** | [**WorkEntity**](WorkEntity.md)| |
+
+### Return type
+
+[**models::EntityEdit**](entity_edit.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: application/json
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **create_work_auto_batch**
+> models::Editgroup create_work_auto_batch(ctx, auto_batch)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **auto_batch** | [**WorkAutoBatch**](WorkAutoBatch.md)| |
+
+### Return type
+
+[**models::Editgroup**](editgroup.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: application/json
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **delete_container**
+> models::EntityEdit delete_container(ctx, editgroup_id, ident)
+
+
+Creates a new \"deletion\" edit for a specific entity as part of an existing editgroup. This is not the method to use to remove an edit from an editgroup; for that use `delete_container_edit`.
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **editgroup_id** | **String**| |
+ **ident** | **String**| |
+
+### Return type
+
+[**models::EntityEdit**](entity_edit.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **delete_container_edit**
+> models::Success delete_container_edit(ctx, editgroup_id, edit_id)
+
+
+Removes a single edit from the specified editgroup. The editgroup must be mutable (aka, not accepted/merged), and the editor making this request must have permission (aka, have created the editgroup or hold the `admin` role). Not to be confused with the `delete_container` method, which *creates* a new edit in the given editgroup.
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **editgroup_id** | **String**| |
+ **edit_id** | **String**| UUID (lower-case, dash-separated, hex-encoded 128-bit) |
+
+### Return type
+
+[**models::Success**](success.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **delete_creator**
+> models::EntityEdit delete_creator(ctx, editgroup_id, ident)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **editgroup_id** | **String**| |
+ **ident** | **String**| |
+
+### Return type
+
+[**models::EntityEdit**](entity_edit.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **delete_creator_edit**
+> models::Success delete_creator_edit(ctx, editgroup_id, edit_id)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **editgroup_id** | **String**| |
+ **edit_id** | **String**| UUID (lower-case, dash-separated, hex-encoded 128-bit) |
+
+### Return type
+
+[**models::Success**](success.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **delete_file**
+> models::EntityEdit delete_file(ctx, editgroup_id, ident)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **editgroup_id** | **String**| |
+ **ident** | **String**| |
+
+### Return type
+
+[**models::EntityEdit**](entity_edit.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **delete_file_edit**
+> models::Success delete_file_edit(ctx, editgroup_id, edit_id)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **editgroup_id** | **String**| |
+ **edit_id** | **String**| UUID (lower-case, dash-separated, hex-encoded 128-bit) |
+
+### Return type
+
+[**models::Success**](success.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **delete_fileset**
+> models::EntityEdit delete_fileset(ctx, editgroup_id, ident)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **editgroup_id** | **String**| |
+ **ident** | **String**| |
+
+### Return type
+
+[**models::EntityEdit**](entity_edit.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **delete_fileset_edit**
+> models::Success delete_fileset_edit(ctx, editgroup_id, edit_id)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **editgroup_id** | **String**| |
+ **edit_id** | **String**| UUID (lower-case, dash-separated, hex-encoded 128-bit) |
+
+### Return type
+
+[**models::Success**](success.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **delete_release**
+> models::EntityEdit delete_release(ctx, editgroup_id, ident)
+
+
+Creates a new \"deletion\" edit for a specific entity as part of an existing editgroup. This is not the method to use to remove an edit from an editgroup; for that use `delete_release_edit`.
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **editgroup_id** | **String**| |
+ **ident** | **String**| |
+
+### Return type
+
+[**models::EntityEdit**](entity_edit.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **delete_release_edit**
+> models::Success delete_release_edit(ctx, editgroup_id, edit_id)
+
+
+Removes a single edit from the specified editgroup. The editgroup must be mutable (aka, not accepted/merged), and the editor making this request must have permission (aka, have created the editgroup or hold the `admin` role). Not to be confused with the `delete_container` method, which *creates* a new edit in the given editgroup.
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **editgroup_id** | **String**| |
+ **edit_id** | **String**| UUID (lower-case, dash-separated, hex-encoded 128-bit) |
+
+### Return type
+
+[**models::Success**](success.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **delete_webcapture**
+> models::EntityEdit delete_webcapture(ctx, editgroup_id, ident)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **editgroup_id** | **String**| |
+ **ident** | **String**| |
+
+### Return type
+
+[**models::EntityEdit**](entity_edit.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **delete_webcapture_edit**
+> models::Success delete_webcapture_edit(ctx, editgroup_id, edit_id)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **editgroup_id** | **String**| |
+ **edit_id** | **String**| UUID (lower-case, dash-separated, hex-encoded 128-bit) |
+
+### Return type
+
+[**models::Success**](success.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **delete_work**
+> models::EntityEdit delete_work(ctx, editgroup_id, ident)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **editgroup_id** | **String**| |
+ **ident** | **String**| |
+
+### Return type
+
+[**models::EntityEdit**](entity_edit.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **delete_work_edit**
+> models::Success delete_work_edit(ctx, editgroup_id, edit_id)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **editgroup_id** | **String**| |
+ **edit_id** | **String**| UUID (lower-case, dash-separated, hex-encoded 128-bit) |
+
+### Return type
+
+[**models::Success**](success.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_changelog**
+> Vec<models::ChangelogEntry> get_changelog(optional)
+
+
+Returns a list of the most recent changelog entries accepted (merged) into the catalog. List is sorted by changelog index in descending order. Note that the accepted timestamp roughly corresponds to order, but not strictly; there exist out-of-order timestamps on the order of several seconds. As a known database issue, it is technically possible for there to be a gap in changelog index numbers (aka, a missing changelog entry). There are no currently known gaps and this is considered a bug that will be addressed. There are millions of entries; to paginate through all of them, use this method to discover the highest existing entry number, then request the entries using `get_changelog_entry` one at a time.
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **optional** | **map[string]interface{}** | optional parameters | nil if no parameters
+
+### Optional Parameters
+Optional parameters are passed through a map[string]interface{}.
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **limit** | **i64**| Maximum count of changelog entries to return in response |
+
+### Return type
+
+[**Vec<models::ChangelogEntry>**](changelog_entry.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_changelog_entry**
+> models::ChangelogEntry get_changelog_entry(index)
+
+
+Returns a single changelog entry. As a known database issue, it is technically possible for there to be a gap in changelog index numbers (aka, a missing changelog entry). There are no currently known gaps and this is considered a bug that will be addressed.
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **index** | **i64**| Changelog index of entry to return |
+
+### Return type
+
+[**models::ChangelogEntry**](changelog_entry.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_container**
+> models::ContainerEntity get_container(ident, optional)
+
+
+Fetches a single container entity from the catalog.
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+ **optional** | **map[string]interface{}** | optional parameters | nil if no parameters
+
+### Optional Parameters
+Optional parameters are passed through a map[string]interface{}.
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+ **expand** | **String**| List of sub-entities to expand in response. For containers, none accepted (yet). |
+ **hide** | **String**| List of entity fields to elide in response. For containers, none accepted (yet). |
+
+### Return type
+
+[**models::ContainerEntity**](container_entity.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_container_edit**
+> models::EntityEdit get_container_edit(edit_id)
+
+
+Returns the entity edit object with the given identifier. This method is expected to be used rarely.
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **edit_id** | **String**| UUID (lower-case, dash-separated, hex-encoded 128-bit) |
+
+### Return type
+
+[**models::EntityEdit**](entity_edit.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_container_history**
+> Vec<models::EntityHistoryEntry> get_container_history(ident, optional)
+
+
+Fetches the history of accepted edits (changelog entries) for a specific entity fatcat identifier.
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+ **optional** | **map[string]interface{}** | optional parameters | nil if no parameters
+
+### Optional Parameters
+Optional parameters are passed through a map[string]interface{}.
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+ **limit** | **i64**| Maximum number of changelog entries to return |
+
+### Return type
+
+[**Vec<models::EntityHistoryEntry>**](entity_history_entry.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_container_redirects**
+> Vec<String> get_container_redirects(ident)
+
+
+Returns the set of entity identifiers which currently redirect to this identifier.
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+
+### Return type
+
+[**Vec<String>**](string.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_container_revision**
+> models::ContainerEntity get_container_revision(rev_id, optional)
+
+
+Fetches a specific entity revision. Note that the returned revision will not be associated with any particular fatcat identifier (even if one or more identifiers do currently point to this revision). The revision may even be part of an un-merged editgroup. Revisions are immutable and can not be deleted or updated.
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **rev_id** | **String**| UUID (lower-case, dash-separated, hex-encoded 128-bit) |
+ **optional** | **map[string]interface{}** | optional parameters | nil if no parameters
+
+### Optional Parameters
+Optional parameters are passed through a map[string]interface{}.
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **rev_id** | **String**| UUID (lower-case, dash-separated, hex-encoded 128-bit) |
+ **expand** | **String**| List of sub-entities to expand in response. See `get_container`. |
+ **hide** | **String**| List of entity fields to elide in response. See `get_container`. |
+
+### Return type
+
+[**models::ContainerEntity**](container_entity.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_creator**
+> models::CreatorEntity get_creator(ident, optional)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+ **optional** | **map[string]interface{}** | optional parameters | nil if no parameters
+
+### Optional Parameters
+Optional parameters are passed through a map[string]interface{}.
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+ **expand** | **String**| List of sub-entities to expand in response. For creators, none accepted (yet). |
+ **hide** | **String**| List of entity fields to elide in response. For creators, none accepted (yet). |
+
+### Return type
+
+[**models::CreatorEntity**](creator_entity.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_creator_edit**
+> models::EntityEdit get_creator_edit(edit_id)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **edit_id** | **String**| UUID (lower-case, dash-separated, hex-encoded 128-bit) |
+
+### Return type
+
+[**models::EntityEdit**](entity_edit.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_creator_history**
+> Vec<models::EntityHistoryEntry> get_creator_history(ident, optional)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+ **optional** | **map[string]interface{}** | optional parameters | nil if no parameters
+
+### Optional Parameters
+Optional parameters are passed through a map[string]interface{}.
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+ **limit** | **i64**| |
+
+### Return type
+
+[**Vec<models::EntityHistoryEntry>**](entity_history_entry.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_creator_redirects**
+> Vec<String> get_creator_redirects(ident)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+
+### Return type
+
+[**Vec<String>**](string.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_creator_releases**
+> Vec<models::ReleaseEntity> get_creator_releases(ident, optional)
+
+
+Returns the set of Release entities having a `contrib` entry pointing to the creator entity.
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+ **optional** | **map[string]interface{}** | optional parameters | nil if no parameters
+
+### Optional Parameters
+Optional parameters are passed through a map[string]interface{}.
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+ **hide** | **String**| List of entity fields to elide in response. See `get_release`. |
+
+### Return type
+
+[**Vec<models::ReleaseEntity>**](release_entity.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_creator_revision**
+> models::CreatorEntity get_creator_revision(rev_id, optional)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **rev_id** | **String**| UUID (lower-case, dash-separated, hex-encoded 128-bit) |
+ **optional** | **map[string]interface{}** | optional parameters | nil if no parameters
+
+### Optional Parameters
+Optional parameters are passed through a map[string]interface{}.
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **rev_id** | **String**| UUID (lower-case, dash-separated, hex-encoded 128-bit) |
+ **expand** | **String**| List of sub-entities to expand in response. See `get_creator`, though note that identifier-based expansions (like `releases`) will always be empty for revisions. |
+ **hide** | **String**| List of entity fields to elide in response. See `get_creator`. |
+
+### Return type
+
+[**models::CreatorEntity**](creator_entity.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_editgroup**
+> models::Editgroup get_editgroup(editgroup_id)
+
+
+Returns a single editgroup object. Unlike some similar methods, this method will return a full/expanded editgroup object, which includes edit lists of each entity type (though will not include the complete entity objects).
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **editgroup_id** | **String**| base32-encoded unique identifier |
+
+### Return type
+
+[**models::Editgroup**](editgroup.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_editgroup_annotations**
+> Vec<models::EditgroupAnnotation> get_editgroup_annotations(editgroup_id, optional)
+
+
+Returns a list of annotations made to a specific editgroup.
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **editgroup_id** | **String**| base32-encoded unique identifier |
+ **optional** | **map[string]interface{}** | optional parameters | nil if no parameters
+
+### Optional Parameters
+Optional parameters are passed through a map[string]interface{}.
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **editgroup_id** | **String**| base32-encoded unique identifier |
+ **expand** | **String**| List of sub-entities to expand in response. For editgroup annotations: 'editors' |
+
+### Return type
+
+[**Vec<models::EditgroupAnnotation>**](editgroup_annotation.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_editgroups_reviewable**
+> Vec<models::Editgroup> get_editgroups_reviewable(optional)
+
+
+Returns a set of editgroups which have been submitted but not yet accepted. Query parameters can be used to sort and paginate the list returned.
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **optional** | **map[string]interface{}** | optional parameters | nil if no parameters
+
+### Optional Parameters
+Optional parameters are passed through a map[string]interface{}.
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **expand** | **String**| List of sub-entities to expand in response. For editgroups: 'editors' |
+ **limit** | **i64**| Maximum number of reviewable editgroups to return in response |
+ **before** | **chrono::DateTime::<chrono::Utc>**| Return only reviewable editgroups submitted *before* the given timestamp (not inclusive). Editgroups will be sorted by submission time in descending order (most recent first). For use in pagination. |
+ **since** | **chrono::DateTime::<chrono::Utc>**| Return only reviewable editgroups submitted *after* the given timestamp (not inclusive). Editgroups will be sorted by submission time in ascending order (most recent last). For use in pagination. |
+
+### Return type
+
+[**Vec<models::Editgroup>**](editgroup.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_editor**
+> models::Editor get_editor(editor_id)
+
+
+Returns an editor object, including metadata such as the username, type, and role of editor.
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **editor_id** | **String**| |
+
+### Return type
+
+[**models::Editor**](editor.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_editor_annotations**
+> Vec<models::EditgroupAnnotation> get_editor_annotations(editor_id, optional)
+
+
+Fetches a list of annotations made by a particular editor.
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **editor_id** | **String**| base32-encoded unique identifier |
+ **optional** | **map[string]interface{}** | optional parameters | nil if no parameters
+
+### Optional Parameters
+Optional parameters are passed through a map[string]interface{}.
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **editor_id** | **String**| base32-encoded unique identifier |
+ **limit** | **i64**| Maximum number (count) of annotations to return in response |
+ **before** | **chrono::DateTime::<chrono::Utc>**| Return only annotations made *before* the given timestamp (not inclusive). Annotations will be sorted by creation time in descending order (most recent first). For use in pagination. |
+ **since** | **chrono::DateTime::<chrono::Utc>**| Return only annotations made *after* the given timestamp (not inclusive). Annotations will be sorted by creation time in ascending order (most recent last). For use in pagination. |
+
+### Return type
+
+[**Vec<models::EditgroupAnnotation>**](editgroup_annotation.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_editor_editgroups**
+> Vec<models::Editgroup> get_editor_editgroups(editor_id, optional)
+
+
+Returns a set of editgroups created by the given editor, regardless of the status (accepted/submitted) of the editgroups.
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **editor_id** | **String**| |
+ **optional** | **map[string]interface{}** | optional parameters | nil if no parameters
+
+### Optional Parameters
+Optional parameters are passed through a map[string]interface{}.
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **editor_id** | **String**| |
+ **limit** | **i64**| |
+ **before** | **chrono::DateTime::<chrono::Utc>**| Return only editgroups created *before* the given timestamp (not inclusive). Editgroups will be sorted by creation time in descending order (most recent first). For use in pagination. |
+ **since** | **chrono::DateTime::<chrono::Utc>**| Return only editgroups created *after* the given timestamp (not inclusive). Editgroups will be sorted by creation time in ascending order (most recent last). For use in pagination. |
+
+### Return type
+
+[**Vec<models::Editgroup>**](editgroup.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_file**
+> models::FileEntity get_file(ident, optional)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+ **optional** | **map[string]interface{}** | optional parameters | nil if no parameters
+
+### Optional Parameters
+Optional parameters are passed through a map[string]interface{}.
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+ **expand** | **String**| List of sub-entities to expand in response. For files, `releases` is accepted. |
+ **hide** | **String**| List of entity fields to elide in response. For files, none accepted (yet). |
+
+### Return type
+
+[**models::FileEntity**](file_entity.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_file_edit**
+> models::EntityEdit get_file_edit(edit_id)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **edit_id** | **String**| UUID (lower-case, dash-separated, hex-encoded 128-bit) |
+
+### Return type
+
+[**models::EntityEdit**](entity_edit.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_file_history**
+> Vec<models::EntityHistoryEntry> get_file_history(ident, optional)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+ **optional** | **map[string]interface{}** | optional parameters | nil if no parameters
+
+### Optional Parameters
+Optional parameters are passed through a map[string]interface{}.
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+ **limit** | **i64**| |
+
+### Return type
+
+[**Vec<models::EntityHistoryEntry>**](entity_history_entry.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_file_redirects**
+> Vec<String> get_file_redirects(ident)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+
+### Return type
+
+[**Vec<String>**](string.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_file_revision**
+> models::FileEntity get_file_revision(rev_id, optional)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **rev_id** | **String**| UUID (lower-case, dash-separated, hex-encoded 128-bit) |
+ **optional** | **map[string]interface{}** | optional parameters | nil if no parameters
+
+### Optional Parameters
+Optional parameters are passed through a map[string]interface{}.
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **rev_id** | **String**| UUID (lower-case, dash-separated, hex-encoded 128-bit) |
+ **expand** | **String**| List of sub-entities to expand in response. See `get_file`. |
+ **hide** | **String**| List of entity fields to elide in response. See `get_file`. |
+
+### Return type
+
+[**models::FileEntity**](file_entity.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_fileset**
+> models::FilesetEntity get_fileset(ident, optional)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+ **optional** | **map[string]interface{}** | optional parameters | nil if no parameters
+
+### Optional Parameters
+Optional parameters are passed through a map[string]interface{}.
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+ **expand** | **String**| List of sub-entities to expand in response. For filesets, `releases` is accepted. |
+ **hide** | **String**| List of entity fields to elide in response. For filesets, 'manifest' is accepted. |
+
+### Return type
+
+[**models::FilesetEntity**](fileset_entity.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_fileset_edit**
+> models::EntityEdit get_fileset_edit(edit_id)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **edit_id** | **String**| UUID (lower-case, dash-separated, hex-encoded 128-bit) |
+
+### Return type
+
+[**models::EntityEdit**](entity_edit.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_fileset_history**
+> Vec<models::EntityHistoryEntry> get_fileset_history(ident, optional)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+ **optional** | **map[string]interface{}** | optional parameters | nil if no parameters
+
+### Optional Parameters
+Optional parameters are passed through a map[string]interface{}.
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+ **limit** | **i64**| |
+
+### Return type
+
+[**Vec<models::EntityHistoryEntry>**](entity_history_entry.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_fileset_redirects**
+> Vec<String> get_fileset_redirects(ident)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+
+### Return type
+
+[**Vec<String>**](string.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_fileset_revision**
+> models::FilesetEntity get_fileset_revision(rev_id, optional)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **rev_id** | **String**| UUID (lower-case, dash-separated, hex-encoded 128-bit) |
+ **optional** | **map[string]interface{}** | optional parameters | nil if no parameters
+
+### Optional Parameters
+Optional parameters are passed through a map[string]interface{}.
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **rev_id** | **String**| UUID (lower-case, dash-separated, hex-encoded 128-bit) |
+ **expand** | **String**| List of sub-entities to expand in response. See `get_fileset`. |
+ **hide** | **String**| List of entity fields to elide in response. See `get_fileset`. |
+
+### Return type
+
+[**models::FilesetEntity**](fileset_entity.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_release**
+> models::ReleaseEntity get_release(ident, optional)
+
+
+Fetches a single Release entity from the catalog.
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+ **optional** | **map[string]interface{}** | optional parameters | nil if no parameters
+
+### Optional Parameters
+Optional parameters are passed through a map[string]interface{}.
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+ **expand** | **String**| List of sub-entities to expand in response. For releases, 'files', 'filesets, 'webcaptures', 'container', and 'creators' are valid. |
+ **hide** | **String**| List of entity fields to elide in response (for efficiency). For releases, 'abstracts', 'refs', and 'contribs' are valid. |
+
+### Return type
+
+[**models::ReleaseEntity**](release_entity.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_release_edit**
+> models::EntityEdit get_release_edit(edit_id)
+
+
+Returns the entity edit object with the given identifier. This method is expected to be used rarely.
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **edit_id** | **String**| UUID (lower-case, dash-separated, hex-encoded 128-bit) |
+
+### Return type
+
+[**models::EntityEdit**](entity_edit.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_release_files**
+> Vec<models::FileEntity> get_release_files(ident, optional)
+
+
+Returns the set of File entities that have a `release_id` pointing to this release entity.
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+ **optional** | **map[string]interface{}** | optional parameters | nil if no parameters
+
+### Optional Parameters
+Optional parameters are passed through a map[string]interface{}.
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+ **hide** | **String**| List of entity fields to elide in response. See `get_file`. |
+
+### Return type
+
+[**Vec<models::FileEntity>**](file_entity.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_release_filesets**
+> Vec<models::FilesetEntity> get_release_filesets(ident, optional)
+
+
+Returns the set of Fileset entities that have a `release_id` pointing to this release entity.
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+ **optional** | **map[string]interface{}** | optional parameters | nil if no parameters
+
+### Optional Parameters
+Optional parameters are passed through a map[string]interface{}.
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+ **hide** | **String**| List of entity fields to elide in response. See `get_fileset`. |
+
+### Return type
+
+[**Vec<models::FilesetEntity>**](fileset_entity.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_release_history**
+> Vec<models::EntityHistoryEntry> get_release_history(ident, optional)
+
+
+Fetches the history of accepted edits (changelog entries) for a specific entity fatcat identifier.
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+ **optional** | **map[string]interface{}** | optional parameters | nil if no parameters
+
+### Optional Parameters
+Optional parameters are passed through a map[string]interface{}.
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+ **limit** | **i64**| |
+
+### Return type
+
+[**Vec<models::EntityHistoryEntry>**](entity_history_entry.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_release_redirects**
+> Vec<String> get_release_redirects(ident)
+
+
+Returns the set of entity identifiers which currently redirect to this identifier.
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+
+### Return type
+
+[**Vec<String>**](string.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_release_revision**
+> models::ReleaseEntity get_release_revision(rev_id, optional)
+
+
+Fetches a specific entity revision. Note that the returned revision will not be associated with any particular fatcat identifier (even if one or more identifiers do currently point to this revision). The revision may even be part of an un-merged editgroup. Revisions are immutable and can not be deleted or updated.
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **rev_id** | **String**| UUID (lower-case, dash-separated, hex-encoded 128-bit) |
+ **optional** | **map[string]interface{}** | optional parameters | nil if no parameters
+
+### Optional Parameters
+Optional parameters are passed through a map[string]interface{}.
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **rev_id** | **String**| UUID (lower-case, dash-separated, hex-encoded 128-bit) |
+ **expand** | **String**| List of sub-entities to expand in response. See `get_release`, though note that identifier-based exapansions like `file` will always be empty for revisions. |
+ **hide** | **String**| List of entity fields to elide in response. See `get_release`. |
+
+### Return type
+
+[**models::ReleaseEntity**](release_entity.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_release_webcaptures**
+> Vec<models::WebcaptureEntity> get_release_webcaptures(ident, optional)
+
+
+Returns the set of Web Capture entities that have a `release_id` pointing to this release entity.
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+ **optional** | **map[string]interface{}** | optional parameters | nil if no parameters
+
+### Optional Parameters
+Optional parameters are passed through a map[string]interface{}.
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+ **hide** | **String**| List of entity fields to elide in response. See `get_webcapture`. |
+
+### Return type
+
+[**Vec<models::WebcaptureEntity>**](webcapture_entity.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_webcapture**
+> models::WebcaptureEntity get_webcapture(ident, optional)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+ **optional** | **map[string]interface{}** | optional parameters | nil if no parameters
+
+### Optional Parameters
+Optional parameters are passed through a map[string]interface{}.
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+ **expand** | **String**| List of sub-entities to expand in response. For webcaptures, `releases` is accepted. |
+ **hide** | **String**| List of entity fields to elide in response. For webcaptures, 'cdx' is accepted. |
+
+### Return type
+
+[**models::WebcaptureEntity**](webcapture_entity.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_webcapture_edit**
+> models::EntityEdit get_webcapture_edit(edit_id)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **edit_id** | **String**| UUID (lower-case, dash-separated, hex-encoded 128-bit) |
+
+### Return type
+
+[**models::EntityEdit**](entity_edit.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_webcapture_history**
+> Vec<models::EntityHistoryEntry> get_webcapture_history(ident, optional)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+ **optional** | **map[string]interface{}** | optional parameters | nil if no parameters
+
+### Optional Parameters
+Optional parameters are passed through a map[string]interface{}.
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+ **limit** | **i64**| |
+
+### Return type
+
+[**Vec<models::EntityHistoryEntry>**](entity_history_entry.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_webcapture_redirects**
+> Vec<String> get_webcapture_redirects(ident)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+
+### Return type
+
+[**Vec<String>**](string.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_webcapture_revision**
+> models::WebcaptureEntity get_webcapture_revision(rev_id, optional)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **rev_id** | **String**| UUID (lower-case, dash-separated, hex-encoded 128-bit) |
+ **optional** | **map[string]interface{}** | optional parameters | nil if no parameters
+
+### Optional Parameters
+Optional parameters are passed through a map[string]interface{}.
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **rev_id** | **String**| UUID (lower-case, dash-separated, hex-encoded 128-bit) |
+ **expand** | **String**| List of sub-entities to expand in response. See `get_webcapture`. |
+ **hide** | **String**| List of entity fields to elide in response. See `get_webcapture`. |
+
+### Return type
+
+[**models::WebcaptureEntity**](webcapture_entity.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_work**
+> models::WorkEntity get_work(ident, optional)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+ **optional** | **map[string]interface{}** | optional parameters | nil if no parameters
+
+### Optional Parameters
+Optional parameters are passed through a map[string]interface{}.
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+ **expand** | **String**| List of sub-entities to expand in response. For works, none accepted (yet). |
+ **hide** | **String**| List of entity fields to elide in response. For works, none accepted (yet). |
+
+### Return type
+
+[**models::WorkEntity**](work_entity.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_work_edit**
+> models::EntityEdit get_work_edit(edit_id)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **edit_id** | **String**| UUID (lower-case, dash-separated, hex-encoded 128-bit) |
+
+### Return type
+
+[**models::EntityEdit**](entity_edit.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_work_history**
+> Vec<models::EntityHistoryEntry> get_work_history(ident, optional)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+ **optional** | **map[string]interface{}** | optional parameters | nil if no parameters
+
+### Optional Parameters
+Optional parameters are passed through a map[string]interface{}.
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+ **limit** | **i64**| |
+
+### Return type
+
+[**Vec<models::EntityHistoryEntry>**](entity_history_entry.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_work_redirects**
+> Vec<String> get_work_redirects(ident)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+
+### Return type
+
+[**Vec<String>**](string.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_work_releases**
+> Vec<models::ReleaseEntity> get_work_releases(ident, optional)
+
+
+Returns the set of release entities that are part of this work (aka, have `work_id` pointing to this work entity).
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+ **optional** | **map[string]interface{}** | optional parameters | nil if no parameters
+
+### Optional Parameters
+Optional parameters are passed through a map[string]interface{}.
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ident** | **String**| |
+ **hide** | **String**| List of entity fields to elide in response. See `get_release`. |
+
+### Return type
+
+[**Vec<models::ReleaseEntity>**](release_entity.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **get_work_revision**
+> models::WorkEntity get_work_revision(rev_id, optional)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **rev_id** | **String**| UUID (lower-case, dash-separated, hex-encoded 128-bit) |
+ **optional** | **map[string]interface{}** | optional parameters | nil if no parameters
+
+### Optional Parameters
+Optional parameters are passed through a map[string]interface{}.
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **rev_id** | **String**| UUID (lower-case, dash-separated, hex-encoded 128-bit) |
+ **expand** | **String**| List of sub-entities to expand in response. See `get_work`, though note that identifier-based expansions like `releases` will always be empty for revisions. |
+ **hide** | **String**| List of entity fields to elide in response. See `get_work`. |
+
+### Return type
+
+[**models::WorkEntity**](work_entity.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **lookup_container**
+> models::ContainerEntity lookup_container(optional)
+
+
+Looks for an active entity with the given external identifier. If any such entity is found, returns a single complete entity. If multiple entities have the same external identifier, this is considered a soft catalog error, and the behavior of which entity is returned is undefined. One (and only one) external identifier should be specified per request.
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **optional** | **map[string]interface{}** | optional parameters | nil if no parameters
+
+### Optional Parameters
+Optional parameters are passed through a map[string]interface{}.
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **issnl** | **String**| |
+ **wikidata_qid** | **String**| |
+ **expand** | **String**| List of sub-entities to expand in response. See `get_container`. |
+ **hide** | **String**| List of entity fields to elide in response. See `get_container`. |
+
+### Return type
+
+[**models::ContainerEntity**](container_entity.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **lookup_creator**
+> models::CreatorEntity lookup_creator(optional)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **optional** | **map[string]interface{}** | optional parameters | nil if no parameters
+
+### Optional Parameters
+Optional parameters are passed through a map[string]interface{}.
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **orcid** | **String**| ORCiD (https://orcid.org) identifier |
+ **wikidata_qid** | **String**| |
+ **expand** | **String**| List of sub-entities to expand in response. See `get_creator`. |
+ **hide** | **String**| List of entity fields to elide in response. See `get_creator`. |
+
+### Return type
+
+[**models::CreatorEntity**](creator_entity.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **lookup_file**
+> models::FileEntity lookup_file(optional)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **optional** | **map[string]interface{}** | optional parameters | nil if no parameters
+
+### Optional Parameters
+Optional parameters are passed through a map[string]interface{}.
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **md5** | **String**| MD5 hash of data, in hex encoding |
+ **sha1** | **String**| SHA-1 hash of data, in hex encoding |
+ **sha256** | **String**| SHA-256 hash of data, in hex encoding |
+ **expand** | **String**| List of sub-entities to expand in response. See `get_file`. |
+ **hide** | **String**| List of entity fields to elide in response. See `get_file`. |
+
+### Return type
+
+[**models::FileEntity**](file_entity.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **lookup_release**
+> models::ReleaseEntity lookup_release(optional)
+
+
+Looks for an active entity with the given external identifier. If any such entity is found, returns a single complete entity. If multiple entities have the same external identifier, this is considered a soft catalog error, and the behavior of which entity is returned is undefined. One (and only one) external identifier should be specified per request.
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **optional** | **map[string]interface{}** | optional parameters | nil if no parameters
+
+### Optional Parameters
+Optional parameters are passed through a map[string]interface{}.
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **doi** | **String**| |
+ **wikidata_qid** | **String**| |
+ **isbn13** | **String**| |
+ **pmid** | **String**| |
+ **pmcid** | **String**| |
+ **core** | **String**| |
+ **arxiv** | **String**| |
+ **jstor** | **String**| |
+ **ark** | **String**| |
+ **mag** | **String**| |
+ **expand** | **String**| List of sub-entities to expand in response. See `get_release`. |
+ **hide** | **String**| List of sub-entities to elide in response. See `get_release`. |
+
+### Return type
+
+[**models::ReleaseEntity**](release_entity.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **update_container**
+> models::EntityEdit update_container(ctx, editgroup_id, ident, entity)
+
+
+Updates an existing entity as part of a specific (existing) editgroup. The editgroup must be open for updates (aka, not accepted/merged), and the editor making the request must have permissions (aka, must have created the editgroup or have `admin` role). This method can also be used to update an existing entity edit as part of an editgroup. For example, if an entity was created in this editgroup, an editor could make changes to the new entity's metadata before merging.
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **editgroup_id** | **String**| |
+ **ident** | **String**| |
+ **entity** | [**ContainerEntity**](ContainerEntity.md)| |
+
+### Return type
+
+[**models::EntityEdit**](entity_edit.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: application/json
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **update_creator**
+> models::EntityEdit update_creator(ctx, editgroup_id, ident, entity)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **editgroup_id** | **String**| |
+ **ident** | **String**| |
+ **entity** | [**CreatorEntity**](CreatorEntity.md)| |
+
+### Return type
+
+[**models::EntityEdit**](entity_edit.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: application/json
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **update_editgroup**
+> models::Editgroup update_editgroup(ctx, editgroup_id, editgroup, optional)
+
+
+Updates metadata for a single editgroup object. Note that only metadata fields such as the `description` or `extra` metadata can be changed with this method; it does not allow adding or removing edits to the editgroup (for that use the individual entity create/update/delete methods).
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **editgroup_id** | **String**| base32-encoded unique identifier |
+ **editgroup** | [**Editgroup**](Editgroup.md)| |
+ **optional** | **map[string]interface{}** | optional parameters | nil if no parameters
+
+### Optional Parameters
+Optional parameters are passed through a map[string]interface{}.
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **editgroup_id** | **String**| base32-encoded unique identifier |
+ **editgroup** | [**Editgroup**](Editgroup.md)| |
+ **submit** | **bool**| |
+
+### Return type
+
+[**models::Editgroup**](editgroup.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: application/json
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **update_editor**
+> models::Editor update_editor(ctx, editor_id, editor)
+
+
+Allows metadata changes to some editor fields, such as the username. Changes require authentication and permissions. An editor can change their own username; changes to role flags require the `admin` role by the editor making the request.
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **editor_id** | **String**| |
+ **editor** | [**Editor**](Editor.md)| |
+
+### Return type
+
+[**models::Editor**](editor.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: application/json
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **update_file**
+> models::EntityEdit update_file(ctx, editgroup_id, ident, entity)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **editgroup_id** | **String**| |
+ **ident** | **String**| |
+ **entity** | [**FileEntity**](FileEntity.md)| |
+
+### Return type
+
+[**models::EntityEdit**](entity_edit.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: application/json
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **update_fileset**
+> models::EntityEdit update_fileset(ctx, editgroup_id, ident, entity)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **editgroup_id** | **String**| |
+ **ident** | **String**| |
+ **entity** | [**FilesetEntity**](FilesetEntity.md)| |
+
+### Return type
+
+[**models::EntityEdit**](entity_edit.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: application/json
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **update_release**
+> models::EntityEdit update_release(ctx, editgroup_id, ident, entity)
+
+
+Updates an existing entity as part of a specific (existing) editgroup. The editgroup must be open for updates (aka, not accepted/merged), and the editor making the requiest must have permissions (aka, must have created the editgroup or have `admin` role). This method can also be used to update an existing entity edit as part of an editgroup. For example, if an entity was created in this editgroup, an editor could make changes to the new entity's metadata before merging.
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **editgroup_id** | **String**| |
+ **ident** | **String**| |
+ **entity** | [**ReleaseEntity**](ReleaseEntity.md)| |
+
+### Return type
+
+[**models::EntityEdit**](entity_edit.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: application/json
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **update_webcapture**
+> models::EntityEdit update_webcapture(ctx, editgroup_id, ident, entity)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **editgroup_id** | **String**| |
+ **ident** | **String**| |
+ **entity** | [**WebcaptureEntity**](WebcaptureEntity.md)| |
+
+### Return type
+
+[**models::EntityEdit**](entity_edit.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: application/json
+ - **Accept**: application/json,
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+# **update_work**
+> models::EntityEdit update_work(ctx, editgroup_id, ident, entity)
+
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **ctx** | **context.Context** | context containing the authentication | nil if no authentication
+ **editgroup_id** | **String**| |
+ **ident** | **String**| |
+ **entity** | [**WorkEntity**](WorkEntity.md)| |
+
+### Return type
+
+[**models::EntityEdit**](entity_edit.md)
+
+### Authorization
+
+[Bearer](../README.md#Bearer)
+
+### HTTP request headers
+
+ - **Content-Type**: application/json
+ - **Accept**: application/json
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
diff --git a/rust/fatcat-openapi/examples/client.rs b/rust/fatcat-openapi/examples/client.rs
deleted file mode 100644
index 5ed6122a..00000000
--- a/rust/fatcat-openapi/examples/client.rs
+++ /dev/null
@@ -1,691 +0,0 @@
-#![allow(missing_docs, unused_variables, trivial_casts)]
-
-use fatcat_openapi;
-#[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_openapi::{
- AcceptEditgroupResponse, ApiError, ApiNoContext, AuthCheckResponse, AuthOidcResponse, ContextWrapperExt, CreateAuthTokenResponse, 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(&[
- "AuthCheck",
- "CreateAuthToken",
- "GetChangelog",
- "GetChangelogEntry",
- "DeleteContainer",
- "DeleteContainerEdit",
- "GetContainer",
- "GetContainerEdit",
- "GetContainerHistory",
- "GetContainerRedirects",
- "GetContainerRevision",
- "LookupContainer",
- "DeleteCreator",
- "DeleteCreatorEdit",
- "GetCreator",
- "GetCreatorEdit",
- "GetCreatorHistory",
- "GetCreatorRedirects",
- "GetCreatorReleases",
- "GetCreatorRevision",
- "LookupCreator",
- "AcceptEditgroup",
- "GetEditgroup",
- "GetEditgroupAnnotations",
- "GetEditgroupsReviewable",
- "GetEditor",
- "GetEditorAnnotations",
- "GetEditorEditgroups",
- "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_openapi::Client::try_new_https(&base_url, "examples/ca.pem").expect("Failed to create HTTPS client")
- } else {
- // Using HTTP
- fatcat_openapi::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_openapi::Context::new_with_span_id(self::uuid::Uuid::new_v4().to_string()));
-
- match matches.value_of("operation") {
- 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("<none>")));
- }
-
- // 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("<none>")));
- // },
- Some("CreateAuthToken") => {
- let result = client.create_auth_token("editor_id_example".to_string(), Some(56)).wait();
- println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
- }
-
- Some("GetChangelog") => {
- let result = client.get_changelog(Some(789)).wait();
- println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
- }
-
- Some("GetChangelogEntry") => {
- let result = client.get_changelog_entry(789).wait();
- println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
- }
-
- // 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("<none>")));
- // },
-
- // 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("<none>")));
- // },
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- // 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("<none>")));
- // },
-
- // 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("<none>")));
- // },
-
- // 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("<none>")));
- // },
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- // 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("<none>")));
- // },
- 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("<none>")));
- }
-
- // Disabled because there's no example.
- // Some("CreateEditgroup") => {
- // let result = client.create_editgroup(???).wait();
- // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
- // },
-
- // Disabled because there's no example.
- // Some("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("<none>")));
- // },
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- // 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("<none>")));
- // },
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- // 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("<none>")));
- // },
-
- // 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("<none>")));
- // },
-
- // 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("<none>")));
- // },
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- // 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("<none>")));
- // },
-
- // 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("<none>")));
- // },
-
- // 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("<none>")));
- // },
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- // 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("<none>")));
- // },
-
- // 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("<none>")));
- // },
-
- // 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("<none>")));
- // },
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- // 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("<none>")));
- // },
-
- // 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("<none>")));
- // },
-
- // 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("<none>")));
- // },
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- // 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("<none>")));
- // },
-
- // 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("<none>")));
- // },
-
- // 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("<none>")));
- // },
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- 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("<none>")));
- }
-
- // 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("<none>")));
- // },
- _ => panic!("Invalid operation provided"),
- }
-}
diff --git a/rust/fatcat-openapi/examples/client/main.rs b/rust/fatcat-openapi/examples/client/main.rs
new file mode 100644
index 00000000..0bc66626
--- /dev/null
+++ b/rust/fatcat-openapi/examples/client/main.rs
@@ -0,0 +1,1139 @@
+#![allow(missing_docs, unused_variables, trivial_casts)]
+
+use clap::{App, Arg};
+#[allow(unused_imports)]
+use fatcat_openapi::{
+ models, AcceptEditgroupResponse, Api, ApiError, ApiNoContext, AuthCheckResponse,
+ AuthOidcResponse, Client, ContextWrapperExt, CreateAuthTokenResponse,
+ 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};
+
+#[allow(unused_imports)]
+use log::info;
+
+// swagger::Has may be unused if there are no examples
+#[allow(unused_imports)]
+use swagger::{AuthData, ContextBuilder, EmptyContext, Has, Push, XSpanIdString};
+
+// rt may be unused if there are no examples
+#[allow(unused_mut)]
+fn main() {
+ env_logger::init();
+
+ let matches = App::new("client")
+ .arg(
+ Arg::with_name("operation")
+ .help("Sets the operation to run")
+ .possible_values(&[
+ "AcceptEditgroup",
+ "AuthCheck",
+ "CreateAuthToken",
+ "DeleteContainer",
+ "DeleteContainerEdit",
+ "DeleteCreator",
+ "DeleteCreatorEdit",
+ "DeleteFile",
+ "DeleteFileEdit",
+ "DeleteFileset",
+ "DeleteFilesetEdit",
+ "DeleteRelease",
+ "DeleteReleaseEdit",
+ "DeleteWebcapture",
+ "DeleteWebcaptureEdit",
+ "DeleteWork",
+ "DeleteWorkEdit",
+ "GetChangelog",
+ "GetChangelogEntry",
+ "GetContainer",
+ "GetContainerEdit",
+ "GetContainerHistory",
+ "GetContainerRedirects",
+ "GetContainerRevision",
+ "GetCreator",
+ "GetCreatorEdit",
+ "GetCreatorHistory",
+ "GetCreatorRedirects",
+ "GetCreatorReleases",
+ "GetCreatorRevision",
+ "GetEditgroup",
+ "GetEditgroupAnnotations",
+ "GetEditgroupsReviewable",
+ "GetEditor",
+ "GetEditorAnnotations",
+ "GetEditorEditgroups",
+ "GetFile",
+ "GetFileEdit",
+ "GetFileHistory",
+ "GetFileRedirects",
+ "GetFileRevision",
+ "GetFileset",
+ "GetFilesetEdit",
+ "GetFilesetHistory",
+ "GetFilesetRedirects",
+ "GetFilesetRevision",
+ "GetRelease",
+ "GetReleaseEdit",
+ "GetReleaseFiles",
+ "GetReleaseFilesets",
+ "GetReleaseHistory",
+ "GetReleaseRedirects",
+ "GetReleaseRevision",
+ "GetReleaseWebcaptures",
+ "GetWebcapture",
+ "GetWebcaptureEdit",
+ "GetWebcaptureHistory",
+ "GetWebcaptureRedirects",
+ "GetWebcaptureRevision",
+ "GetWork",
+ "GetWorkEdit",
+ "GetWorkHistory",
+ "GetWorkRedirects",
+ "GetWorkReleases",
+ "GetWorkRevision",
+ "LookupContainer",
+ "LookupCreator",
+ "LookupFile",
+ "LookupRelease",
+ ])
+ .required(true)
+ .index(1),
+ )
+ .arg(
+ Arg::with_name("https")
+ .long("https")
+ .help("Whether to use HTTPS or not"),
+ )
+ .arg(
+ Arg::with_name("host")
+ .long("host")
+ .takes_value(true)
+ .default_value("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 matches.is_present("https") {
+ // Using Simple HTTPS
+ Client::try_new_https(&base_url).expect("Failed to create HTTPS client")
+ } else {
+ // Using HTTP
+ Client::try_new_http(&base_url).expect("Failed to create HTTP client")
+ };
+
+ let context: swagger::make_context_ty!(
+ ContextBuilder,
+ EmptyContext,
+ Option<AuthData>,
+ XSpanIdString
+ ) = swagger::make_context!(
+ ContextBuilder,
+ EmptyContext,
+ None as Option<AuthData>,
+ XSpanIdString::default()
+ );
+
+ let client = client.with_context(context);
+
+ let mut rt = tokio::runtime::Runtime::new().unwrap();
+
+ match matches.value_of("operation") {
+ Some("AcceptEditgroup") => {
+ let result = rt.block_on(client.accept_editgroup("editgroup_id_example".to_string()));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("AuthCheck") => {
+ let result = rt.block_on(client.auth_check(Some("role_example".to_string())));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ /* Disabled because there's no example.
+ Some("AuthOidc") => {
+ let result = rt.block_on(client.auth_oidc(
+ ???
+ ));
+ info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone());
+ },
+ */
+ Some("CreateAuthToken") => {
+ let result =
+ rt.block_on(client.create_auth_token("editor_id_example".to_string(), Some(56)));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ /* Disabled because there's no example.
+ Some("CreateContainer") => {
+ let result = rt.block_on(client.create_container(
+ "editgroup_id_example".to_string(),
+ ???
+ ));
+ info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone());
+ },
+ */
+ /* Disabled because there's no example.
+ Some("CreateContainerAutoBatch") => {
+ let result = rt.block_on(client.create_container_auto_batch(
+ ???
+ ));
+ info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone());
+ },
+ */
+ /* Disabled because there's no example.
+ Some("CreateCreator") => {
+ let result = rt.block_on(client.create_creator(
+ "editgroup_id_example".to_string(),
+ ???
+ ));
+ info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone());
+ },
+ */
+ /* Disabled because there's no example.
+ Some("CreateCreatorAutoBatch") => {
+ let result = rt.block_on(client.create_creator_auto_batch(
+ ???
+ ));
+ info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone());
+ },
+ */
+ /* Disabled because there's no example.
+ Some("CreateEditgroup") => {
+ let result = rt.block_on(client.create_editgroup(
+ ???
+ ));
+ info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone());
+ },
+ */
+ /* Disabled because there's no example.
+ Some("CreateEditgroupAnnotation") => {
+ let result = rt.block_on(client.create_editgroup_annotation(
+ "editgroup_id_example".to_string(),
+ ???
+ ));
+ info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone());
+ },
+ */
+ /* Disabled because there's no example.
+ Some("CreateFile") => {
+ let result = rt.block_on(client.create_file(
+ "editgroup_id_example".to_string(),
+ ???
+ ));
+ info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone());
+ },
+ */
+ /* Disabled because there's no example.
+ Some("CreateFileAutoBatch") => {
+ let result = rt.block_on(client.create_file_auto_batch(
+ ???
+ ));
+ info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone());
+ },
+ */
+ /* Disabled because there's no example.
+ Some("CreateFileset") => {
+ let result = rt.block_on(client.create_fileset(
+ "editgroup_id_example".to_string(),
+ ???
+ ));
+ info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone());
+ },
+ */
+ /* Disabled because there's no example.
+ Some("CreateFilesetAutoBatch") => {
+ let result = rt.block_on(client.create_fileset_auto_batch(
+ ???
+ ));
+ info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone());
+ },
+ */
+ /* Disabled because there's no example.
+ Some("CreateRelease") => {
+ let result = rt.block_on(client.create_release(
+ "editgroup_id_example".to_string(),
+ ???
+ ));
+ info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone());
+ },
+ */
+ /* Disabled because there's no example.
+ Some("CreateReleaseAutoBatch") => {
+ let result = rt.block_on(client.create_release_auto_batch(
+ ???
+ ));
+ info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone());
+ },
+ */
+ /* Disabled because there's no example.
+ Some("CreateWebcapture") => {
+ let result = rt.block_on(client.create_webcapture(
+ "editgroup_id_example".to_string(),
+ ???
+ ));
+ info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone());
+ },
+ */
+ /* Disabled because there's no example.
+ Some("CreateWebcaptureAutoBatch") => {
+ let result = rt.block_on(client.create_webcapture_auto_batch(
+ ???
+ ));
+ info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone());
+ },
+ */
+ /* Disabled because there's no example.
+ Some("CreateWork") => {
+ let result = rt.block_on(client.create_work(
+ "editgroup_id_example".to_string(),
+ ???
+ ));
+ info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone());
+ },
+ */
+ /* Disabled because there's no example.
+ Some("CreateWorkAutoBatch") => {
+ let result = rt.block_on(client.create_work_auto_batch(
+ ???
+ ));
+ info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone());
+ },
+ */
+ Some("DeleteContainer") => {
+ let result = rt.block_on(client.delete_container(
+ "editgroup_id_example".to_string(),
+ "ident_example".to_string(),
+ ));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("DeleteContainerEdit") => {
+ let result = rt.block_on(client.delete_container_edit(
+ "editgroup_id_example".to_string(),
+ "edit_id_example".to_string(),
+ ));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("DeleteCreator") => {
+ let result = rt.block_on(client.delete_creator(
+ "editgroup_id_example".to_string(),
+ "ident_example".to_string(),
+ ));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("DeleteCreatorEdit") => {
+ let result = rt.block_on(client.delete_creator_edit(
+ "editgroup_id_example".to_string(),
+ "edit_id_example".to_string(),
+ ));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("DeleteFile") => {
+ let result = rt.block_on(client.delete_file(
+ "editgroup_id_example".to_string(),
+ "ident_example".to_string(),
+ ));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("DeleteFileEdit") => {
+ let result = rt.block_on(client.delete_file_edit(
+ "editgroup_id_example".to_string(),
+ "edit_id_example".to_string(),
+ ));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("DeleteFileset") => {
+ let result = rt.block_on(client.delete_fileset(
+ "editgroup_id_example".to_string(),
+ "ident_example".to_string(),
+ ));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("DeleteFilesetEdit") => {
+ let result = rt.block_on(client.delete_fileset_edit(
+ "editgroup_id_example".to_string(),
+ "edit_id_example".to_string(),
+ ));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("DeleteRelease") => {
+ let result = rt.block_on(client.delete_release(
+ "editgroup_id_example".to_string(),
+ "ident_example".to_string(),
+ ));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("DeleteReleaseEdit") => {
+ let result = rt.block_on(client.delete_release_edit(
+ "editgroup_id_example".to_string(),
+ "edit_id_example".to_string(),
+ ));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("DeleteWebcapture") => {
+ let result = rt.block_on(client.delete_webcapture(
+ "editgroup_id_example".to_string(),
+ "ident_example".to_string(),
+ ));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("DeleteWebcaptureEdit") => {
+ let result = rt.block_on(client.delete_webcapture_edit(
+ "editgroup_id_example".to_string(),
+ "edit_id_example".to_string(),
+ ));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("DeleteWork") => {
+ let result = rt.block_on(client.delete_work(
+ "editgroup_id_example".to_string(),
+ "ident_example".to_string(),
+ ));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("DeleteWorkEdit") => {
+ let result = rt.block_on(client.delete_work_edit(
+ "editgroup_id_example".to_string(),
+ "edit_id_example".to_string(),
+ ));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetChangelog") => {
+ let result = rt.block_on(client.get_changelog(Some(789)));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetChangelogEntry") => {
+ let result = rt.block_on(client.get_changelog_entry(789));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetContainer") => {
+ let result = rt.block_on(client.get_container(
+ "ident_example".to_string(),
+ Some("expand_example".to_string()),
+ Some("hide_example".to_string()),
+ ));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetContainerEdit") => {
+ let result = rt.block_on(client.get_container_edit("edit_id_example".to_string()));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetContainerHistory") => {
+ let result =
+ rt.block_on(client.get_container_history("ident_example".to_string(), Some(789)));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetContainerRedirects") => {
+ let result = rt.block_on(client.get_container_redirects("ident_example".to_string()));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetContainerRevision") => {
+ let result = rt.block_on(client.get_container_revision(
+ "rev_id_example".to_string(),
+ Some("expand_example".to_string()),
+ Some("hide_example".to_string()),
+ ));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetCreator") => {
+ let result = rt.block_on(client.get_creator(
+ "ident_example".to_string(),
+ Some("expand_example".to_string()),
+ Some("hide_example".to_string()),
+ ));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetCreatorEdit") => {
+ let result = rt.block_on(client.get_creator_edit("edit_id_example".to_string()));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetCreatorHistory") => {
+ let result =
+ rt.block_on(client.get_creator_history("ident_example".to_string(), Some(789)));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetCreatorRedirects") => {
+ let result = rt.block_on(client.get_creator_redirects("ident_example".to_string()));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetCreatorReleases") => {
+ let result = rt.block_on(client.get_creator_releases(
+ "ident_example".to_string(),
+ Some("hide_example".to_string()),
+ ));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetCreatorRevision") => {
+ let result = rt.block_on(client.get_creator_revision(
+ "rev_id_example".to_string(),
+ Some("expand_example".to_string()),
+ Some("hide_example".to_string()),
+ ));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetEditgroup") => {
+ let result = rt.block_on(client.get_editgroup("editgroup_id_example".to_string()));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetEditgroupAnnotations") => {
+ let result = rt.block_on(client.get_editgroup_annotations(
+ "editgroup_id_example".to_string(),
+ Some("expand_example".to_string()),
+ ));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetEditgroupsReviewable") => {
+ let result = rt.block_on(client.get_editgroups_reviewable(
+ Some("expand_example".to_string()),
+ Some(789),
+ None,
+ None,
+ ));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetEditor") => {
+ let result = rt.block_on(client.get_editor("editor_id_example".to_string()));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetEditorAnnotations") => {
+ let result = rt.block_on(client.get_editor_annotations(
+ "editor_id_example".to_string(),
+ Some(789),
+ None,
+ None,
+ ));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetEditorEditgroups") => {
+ let result = rt.block_on(client.get_editor_editgroups(
+ "editor_id_example".to_string(),
+ Some(789),
+ None,
+ None,
+ ));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetFile") => {
+ let result = rt.block_on(client.get_file(
+ "ident_example".to_string(),
+ Some("expand_example".to_string()),
+ Some("hide_example".to_string()),
+ ));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetFileEdit") => {
+ let result = rt.block_on(client.get_file_edit("edit_id_example".to_string()));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetFileHistory") => {
+ let result =
+ rt.block_on(client.get_file_history("ident_example".to_string(), Some(789)));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetFileRedirects") => {
+ let result = rt.block_on(client.get_file_redirects("ident_example".to_string()));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetFileRevision") => {
+ let result = rt.block_on(client.get_file_revision(
+ "rev_id_example".to_string(),
+ Some("expand_example".to_string()),
+ Some("hide_example".to_string()),
+ ));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetFileset") => {
+ let result = rt.block_on(client.get_fileset(
+ "ident_example".to_string(),
+ Some("expand_example".to_string()),
+ Some("hide_example".to_string()),
+ ));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetFilesetEdit") => {
+ let result = rt.block_on(client.get_fileset_edit("edit_id_example".to_string()));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetFilesetHistory") => {
+ let result =
+ rt.block_on(client.get_fileset_history("ident_example".to_string(), Some(789)));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetFilesetRedirects") => {
+ let result = rt.block_on(client.get_fileset_redirects("ident_example".to_string()));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetFilesetRevision") => {
+ let result = rt.block_on(client.get_fileset_revision(
+ "rev_id_example".to_string(),
+ Some("expand_example".to_string()),
+ Some("hide_example".to_string()),
+ ));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetRelease") => {
+ let result = rt.block_on(client.get_release(
+ "ident_example".to_string(),
+ Some("expand_example".to_string()),
+ Some("hide_example".to_string()),
+ ));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetReleaseEdit") => {
+ let result = rt.block_on(client.get_release_edit("edit_id_example".to_string()));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetReleaseFiles") => {
+ let result = rt.block_on(client.get_release_files(
+ "ident_example".to_string(),
+ Some("hide_example".to_string()),
+ ));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetReleaseFilesets") => {
+ let result = rt.block_on(client.get_release_filesets(
+ "ident_example".to_string(),
+ Some("hide_example".to_string()),
+ ));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetReleaseHistory") => {
+ let result =
+ rt.block_on(client.get_release_history("ident_example".to_string(), Some(789)));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetReleaseRedirects") => {
+ let result = rt.block_on(client.get_release_redirects("ident_example".to_string()));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetReleaseRevision") => {
+ let result = rt.block_on(client.get_release_revision(
+ "rev_id_example".to_string(),
+ Some("expand_example".to_string()),
+ Some("hide_example".to_string()),
+ ));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetReleaseWebcaptures") => {
+ let result = rt.block_on(client.get_release_webcaptures(
+ "ident_example".to_string(),
+ Some("hide_example".to_string()),
+ ));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetWebcapture") => {
+ let result = rt.block_on(client.get_webcapture(
+ "ident_example".to_string(),
+ Some("expand_example".to_string()),
+ Some("hide_example".to_string()),
+ ));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetWebcaptureEdit") => {
+ let result = rt.block_on(client.get_webcapture_edit("edit_id_example".to_string()));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetWebcaptureHistory") => {
+ let result =
+ rt.block_on(client.get_webcapture_history("ident_example".to_string(), Some(789)));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetWebcaptureRedirects") => {
+ let result = rt.block_on(client.get_webcapture_redirects("ident_example".to_string()));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetWebcaptureRevision") => {
+ let result = rt.block_on(client.get_webcapture_revision(
+ "rev_id_example".to_string(),
+ Some("expand_example".to_string()),
+ Some("hide_example".to_string()),
+ ));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetWork") => {
+ let result = rt.block_on(client.get_work(
+ "ident_example".to_string(),
+ Some("expand_example".to_string()),
+ Some("hide_example".to_string()),
+ ));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetWorkEdit") => {
+ let result = rt.block_on(client.get_work_edit("edit_id_example".to_string()));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetWorkHistory") => {
+ let result =
+ rt.block_on(client.get_work_history("ident_example".to_string(), Some(789)));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetWorkRedirects") => {
+ let result = rt.block_on(client.get_work_redirects("ident_example".to_string()));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetWorkReleases") => {
+ let result = rt.block_on(client.get_work_releases(
+ "ident_example".to_string(),
+ Some("hide_example".to_string()),
+ ));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("GetWorkRevision") => {
+ let result = rt.block_on(client.get_work_revision(
+ "rev_id_example".to_string(),
+ Some("expand_example".to_string()),
+ Some("hide_example".to_string()),
+ ));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("LookupContainer") => {
+ let result = rt.block_on(client.lookup_container(
+ Some("issnl_example".to_string()),
+ Some("wikidata_qid_example".to_string()),
+ Some("expand_example".to_string()),
+ Some("hide_example".to_string()),
+ ));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("LookupCreator") => {
+ let result = rt.block_on(client.lookup_creator(
+ Some("orcid_example".to_string()),
+ Some("wikidata_qid_example".to_string()),
+ Some("expand_example".to_string()),
+ Some("hide_example".to_string()),
+ ));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("LookupFile") => {
+ let result = rt.block_on(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()),
+ ));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ Some("LookupRelease") => {
+ let result = rt.block_on(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()),
+ ));
+ info!(
+ "{:?} (X-Span-ID: {:?})",
+ result,
+ (client.context() as &dyn Has<XSpanIdString>).get().clone()
+ );
+ }
+ /* Disabled because there's no example.
+ Some("UpdateContainer") => {
+ let result = rt.block_on(client.update_container(
+ "editgroup_id_example".to_string(),
+ "ident_example".to_string(),
+ ???
+ ));
+ info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone());
+ },
+ */
+ /* Disabled because there's no example.
+ Some("UpdateCreator") => {
+ let result = rt.block_on(client.update_creator(
+ "editgroup_id_example".to_string(),
+ "ident_example".to_string(),
+ ???
+ ));
+ info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone());
+ },
+ */
+ /* Disabled because there's no example.
+ Some("UpdateEditgroup") => {
+ let result = rt.block_on(client.update_editgroup(
+ "editgroup_id_example".to_string(),
+ ???,
+ Some(true)
+ ));
+ info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone());
+ },
+ */
+ /* Disabled because there's no example.
+ Some("UpdateEditor") => {
+ let result = rt.block_on(client.update_editor(
+ "editor_id_example".to_string(),
+ ???
+ ));
+ info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone());
+ },
+ */
+ /* Disabled because there's no example.
+ Some("UpdateFile") => {
+ let result = rt.block_on(client.update_file(
+ "editgroup_id_example".to_string(),
+ "ident_example".to_string(),
+ ???
+ ));
+ info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone());
+ },
+ */
+ /* Disabled because there's no example.
+ Some("UpdateFileset") => {
+ let result = rt.block_on(client.update_fileset(
+ "editgroup_id_example".to_string(),
+ "ident_example".to_string(),
+ ???
+ ));
+ info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone());
+ },
+ */
+ /* Disabled because there's no example.
+ Some("UpdateRelease") => {
+ let result = rt.block_on(client.update_release(
+ "editgroup_id_example".to_string(),
+ "ident_example".to_string(),
+ ???
+ ));
+ info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone());
+ },
+ */
+ /* Disabled because there's no example.
+ Some("UpdateWebcapture") => {
+ let result = rt.block_on(client.update_webcapture(
+ "editgroup_id_example".to_string(),
+ "ident_example".to_string(),
+ ???
+ ));
+ info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone());
+ },
+ */
+ /* Disabled because there's no example.
+ Some("UpdateWork") => {
+ let result = rt.block_on(client.update_work(
+ "editgroup_id_example".to_string(),
+ "ident_example".to_string(),
+ ???
+ ));
+ info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone());
+ },
+ */
+ _ => panic!("Invalid operation provided"),
+ }
+}
diff --git a/rust/fatcat-openapi/examples/server.rs b/rust/fatcat-openapi/examples/server.rs
deleted file mode 100644
index a033413b..00000000
--- a/rust/fatcat-openapi/examples/server.rs
+++ /dev/null
@@ -1,59 +0,0 @@
-//! Main binary entry point for fatcat implementation.
-
-#![allow(missing_docs)]
-
-// Imports required by this file.
-// extern crate <name of this crate>;
-use fatcat_openapi;
-
-// Imports required by server library.
-// extern crate fatcat_openapi;
-// extern crate swagger;
-use chrono;
-use 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};
-
-mod server_lib;
-
-/// Builds an SSL implementation for Simple HTTPS from some hard-coded file names
-fn ssl() -> Result<OpensslServer, ErrorStack> {
- let mut ssl = SslAcceptorBuilder::mozilla_intermediate_raw(SslMethod::tls())?;
-
- // Server authentication
- ssl.set_private_key_file("examples/server-key.pem", X509_FILETYPE_PEM)?;
- ssl.set_certificate_chain_file("examples/server-chain.pem")?;
- ssl.check_private_key()?;
-
- Ok(OpensslServer::from(ssl.build()))
-}
-
-/// Create custom server, wire it to the autogenerated router,
-/// and pass it to the web server.
-fn main() {
- let matches = App::new("server").arg(Arg::with_name("https").long("https").help("Whether to use HTTPS or not")).get_matches();
-
- let server = server_lib::server().unwrap();
- let router = fatcat_openapi::router(server);
-
- let mut chain = Chain::new(router);
- chain.link_before(fatcat_openapi::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-openapi/examples/server/main.rs b/rust/fatcat-openapi/examples/server/main.rs
new file mode 100644
index 00000000..af089c2f
--- /dev/null
+++ b/rust/fatcat-openapi/examples/server/main.rs
@@ -0,0 +1,25 @@
+//! Main binary entry point for fatcat_openapi implementation.
+
+#![allow(missing_docs)]
+
+use clap::{App, Arg};
+
+mod server;
+
+/// Create custom server, wire it to the autogenerated router,
+/// and pass it to the web server.
+fn main() {
+ env_logger::init();
+
+ let matches = App::new("server")
+ .arg(
+ Arg::with_name("https")
+ .long("https")
+ .help("Whether to use HTTPS or not"),
+ )
+ .get_matches();
+
+ let addr = "127.0.0.1:8080";
+
+ hyper::rt::run(server::create(addr, matches.is_present("https")));
+}
diff --git a/rust/fatcat-openapi/examples/server/server.rs b/rust/fatcat-openapi/examples/server/server.rs
new file mode 100644
index 00000000..30f8bfed
--- /dev/null
+++ b/rust/fatcat-openapi/examples/server/server.rs
@@ -0,0 +1,1691 @@
+//! Main library entry point for fatcat_openapi implementation.
+
+#![allow(unused_imports)]
+
+mod errors {
+ error_chain::error_chain! {}
+}
+
+pub use self::errors::*;
+
+use chrono;
+use futures::{future, Future, Stream};
+use hyper::server::conn::Http;
+use hyper::service::MakeService as _;
+use log::info;
+use openssl::ssl::SslAcceptorBuilder;
+use std::marker::PhantomData;
+use std::net::SocketAddr;
+use std::sync::{Arc, Mutex};
+use swagger;
+use swagger::auth::MakeAllowAllAuthenticator;
+use swagger::EmptyContext;
+use swagger::{Has, XSpanIdString};
+use tokio::net::TcpListener;
+
+#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
+use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod};
+#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
+use tokio_openssl::SslAcceptorExt;
+
+use fatcat_openapi::models;
+
+#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
+/// Builds an SSL implementation for Simple HTTPS from some hard-coded file names
+pub fn create(addr: &str, https: bool) -> Box<dyn Future<Item = (), Error = ()> + Send> {
+ let addr = addr.parse().expect("Failed to parse bind address");
+
+ let server = Server::new();
+
+ let service_fn = MakeService::new(server);
+
+ let service_fn = MakeAllowAllAuthenticator::new(service_fn, "cosmo");
+
+ let service_fn =
+ fatcat_openapi::server::context::MakeAddContext::<_, EmptyContext>::new(service_fn);
+
+ if https {
+ #[cfg(any(target_os = "macos", target_os = "windows", target_os = "ios"))]
+ {
+ unimplemented!("SSL is not implemented for the examples on MacOS, Windows or iOS");
+ }
+
+ #[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
+ {
+ let mut ssl = SslAcceptor::mozilla_intermediate_v5(SslMethod::tls())
+ .expect("Failed to create SSL Acceptor");
+
+ // Server authentication
+ ssl.set_private_key_file("examples/server-key.pem", SslFiletype::PEM)
+ .expect("Failed to set private key");
+ ssl.set_certificate_chain_file("examples/server-chain.pem")
+ .expect("Failed to set cerificate chain");
+ ssl.check_private_key()
+ .expect("Failed to check private key");
+
+ let tls_acceptor = ssl.build();
+ let service_fn = Arc::new(Mutex::new(service_fn));
+ let tls_listener = TcpListener::bind(&addr)
+ .unwrap()
+ .incoming()
+ .for_each(move |tcp| {
+ let addr = tcp.peer_addr().expect("Unable to get remote address");
+
+ let service_fn = service_fn.clone();
+
+ hyper::rt::spawn(tls_acceptor.accept_async(tcp).map_err(|_| ()).and_then(
+ move |tls| {
+ let ms = {
+ let mut service_fn = service_fn.lock().unwrap();
+ service_fn.make_service(&addr)
+ };
+
+ ms.and_then(move |service| Http::new().serve_connection(tls, service))
+ .map_err(|_| ())
+ },
+ ));
+
+ Ok(())
+ })
+ .map_err(|_| ());
+
+ Box::new(tls_listener)
+ }
+ } else {
+ // Using HTTP
+ Box::new(
+ hyper::server::Server::bind(&addr)
+ .serve(service_fn)
+ .map_err(|e| panic!("{:?}", e)),
+ )
+ }
+}
+
+#[derive(Copy, Clone)]
+pub struct Server<C> {
+ marker: PhantomData<C>,
+}
+
+impl<C> Server<C> {
+ pub fn new() -> Self {
+ Server {
+ marker: PhantomData,
+ }
+ }
+}
+
+use fatcat_openapi::server::MakeService;
+use fatcat_openapi::{
+ AcceptEditgroupResponse, Api, ApiError, AuthCheckResponse, AuthOidcResponse,
+ CreateAuthTokenResponse, 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,
+};
+
+impl<C> Api<C> for Server<C>
+where
+ C: Has<XSpanIdString>,
+{
+ fn accept_editgroup(
+ &self,
+ editgroup_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = AcceptEditgroupResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "accept_editgroup(\"{}\") - X-Span-ID: {:?}",
+ editgroup_id,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn auth_check(
+ &self,
+ role: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = AuthCheckResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "auth_check({:?}) - X-Span-ID: {:?}",
+ role,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn auth_oidc(
+ &self,
+ oidc_params: models::AuthOidc,
+ context: &C,
+ ) -> Box<dyn Future<Item = AuthOidcResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "auth_oidc({:?}) - X-Span-ID: {:?}",
+ oidc_params,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn create_auth_token(
+ &self,
+ editor_id: String,
+ duration_seconds: Option<i32>,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateAuthTokenResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "create_auth_token(\"{}\", {:?}) - X-Span-ID: {:?}",
+ editor_id,
+ duration_seconds,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn create_container(
+ &self,
+ editgroup_id: String,
+ entity: models::ContainerEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateContainerResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "create_container(\"{}\", {:?}) - X-Span-ID: {:?}",
+ editgroup_id,
+ entity,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn create_container_auto_batch(
+ &self,
+ auto_batch: models::ContainerAutoBatch,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateContainerAutoBatchResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "create_container_auto_batch({:?}) - X-Span-ID: {:?}",
+ auto_batch,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn create_creator(
+ &self,
+ editgroup_id: String,
+ entity: models::CreatorEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateCreatorResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "create_creator(\"{}\", {:?}) - X-Span-ID: {:?}",
+ editgroup_id,
+ entity,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn create_creator_auto_batch(
+ &self,
+ auto_batch: models::CreatorAutoBatch,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateCreatorAutoBatchResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "create_creator_auto_batch({:?}) - X-Span-ID: {:?}",
+ auto_batch,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn create_editgroup(
+ &self,
+ editgroup: models::Editgroup,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateEditgroupResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "create_editgroup({:?}) - X-Span-ID: {:?}",
+ editgroup,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn create_editgroup_annotation(
+ &self,
+ editgroup_id: String,
+ annotation: models::EditgroupAnnotation,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateEditgroupAnnotationResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "create_editgroup_annotation(\"{}\", {:?}) - X-Span-ID: {:?}",
+ editgroup_id,
+ annotation,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn create_file(
+ &self,
+ editgroup_id: String,
+ entity: models::FileEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateFileResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "create_file(\"{}\", {:?}) - X-Span-ID: {:?}",
+ editgroup_id,
+ entity,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn create_file_auto_batch(
+ &self,
+ auto_batch: models::FileAutoBatch,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateFileAutoBatchResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "create_file_auto_batch({:?}) - X-Span-ID: {:?}",
+ auto_batch,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn create_fileset(
+ &self,
+ editgroup_id: String,
+ entity: models::FilesetEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateFilesetResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "create_fileset(\"{}\", {:?}) - X-Span-ID: {:?}",
+ editgroup_id,
+ entity,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn create_fileset_auto_batch(
+ &self,
+ auto_batch: models::FilesetAutoBatch,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateFilesetAutoBatchResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "create_fileset_auto_batch({:?}) - X-Span-ID: {:?}",
+ auto_batch,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn create_release(
+ &self,
+ editgroup_id: String,
+ entity: models::ReleaseEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateReleaseResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "create_release(\"{}\", {:?}) - X-Span-ID: {:?}",
+ editgroup_id,
+ entity,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn create_release_auto_batch(
+ &self,
+ auto_batch: models::ReleaseAutoBatch,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateReleaseAutoBatchResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "create_release_auto_batch({:?}) - X-Span-ID: {:?}",
+ auto_batch,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn create_webcapture(
+ &self,
+ editgroup_id: String,
+ entity: models::WebcaptureEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateWebcaptureResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "create_webcapture(\"{}\", {:?}) - X-Span-ID: {:?}",
+ editgroup_id,
+ entity,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn create_webcapture_auto_batch(
+ &self,
+ auto_batch: models::WebcaptureAutoBatch,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateWebcaptureAutoBatchResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "create_webcapture_auto_batch({:?}) - X-Span-ID: {:?}",
+ auto_batch,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn create_work(
+ &self,
+ editgroup_id: String,
+ entity: models::WorkEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateWorkResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "create_work(\"{}\", {:?}) - X-Span-ID: {:?}",
+ editgroup_id,
+ entity,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn create_work_auto_batch(
+ &self,
+ auto_batch: models::WorkAutoBatch,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateWorkAutoBatchResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "create_work_auto_batch({:?}) - X-Span-ID: {:?}",
+ auto_batch,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn delete_container(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteContainerResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "delete_container(\"{}\", \"{}\") - X-Span-ID: {:?}",
+ editgroup_id,
+ ident,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn delete_container_edit(
+ &self,
+ editgroup_id: String,
+ edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteContainerEditResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "delete_container_edit(\"{}\", \"{}\") - X-Span-ID: {:?}",
+ editgroup_id,
+ edit_id,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn delete_creator(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteCreatorResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "delete_creator(\"{}\", \"{}\") - X-Span-ID: {:?}",
+ editgroup_id,
+ ident,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn delete_creator_edit(
+ &self,
+ editgroup_id: String,
+ edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteCreatorEditResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "delete_creator_edit(\"{}\", \"{}\") - X-Span-ID: {:?}",
+ editgroup_id,
+ edit_id,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn delete_file(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteFileResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "delete_file(\"{}\", \"{}\") - X-Span-ID: {:?}",
+ editgroup_id,
+ ident,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn delete_file_edit(
+ &self,
+ editgroup_id: String,
+ edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteFileEditResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "delete_file_edit(\"{}\", \"{}\") - X-Span-ID: {:?}",
+ editgroup_id,
+ edit_id,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn delete_fileset(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteFilesetResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "delete_fileset(\"{}\", \"{}\") - X-Span-ID: {:?}",
+ editgroup_id,
+ ident,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn delete_fileset_edit(
+ &self,
+ editgroup_id: String,
+ edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteFilesetEditResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "delete_fileset_edit(\"{}\", \"{}\") - X-Span-ID: {:?}",
+ editgroup_id,
+ edit_id,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn delete_release(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteReleaseResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "delete_release(\"{}\", \"{}\") - X-Span-ID: {:?}",
+ editgroup_id,
+ ident,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn delete_release_edit(
+ &self,
+ editgroup_id: String,
+ edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteReleaseEditResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "delete_release_edit(\"{}\", \"{}\") - X-Span-ID: {:?}",
+ editgroup_id,
+ edit_id,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn delete_webcapture(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteWebcaptureResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "delete_webcapture(\"{}\", \"{}\") - X-Span-ID: {:?}",
+ editgroup_id,
+ ident,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn delete_webcapture_edit(
+ &self,
+ editgroup_id: String,
+ edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteWebcaptureEditResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "delete_webcapture_edit(\"{}\", \"{}\") - X-Span-ID: {:?}",
+ editgroup_id,
+ edit_id,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn delete_work(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteWorkResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "delete_work(\"{}\", \"{}\") - X-Span-ID: {:?}",
+ editgroup_id,
+ ident,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn delete_work_edit(
+ &self,
+ editgroup_id: String,
+ edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteWorkEditResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "delete_work_edit(\"{}\", \"{}\") - X-Span-ID: {:?}",
+ editgroup_id,
+ edit_id,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_changelog(
+ &self,
+ limit: Option<i64>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetChangelogResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_changelog({:?}) - X-Span-ID: {:?}",
+ limit,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_changelog_entry(
+ &self,
+ index: i64,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetChangelogEntryResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_changelog_entry({}) - X-Span-ID: {:?}",
+ index,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_container(
+ &self,
+ ident: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetContainerResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_container(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}",
+ ident,
+ expand,
+ hide,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_container_edit(
+ &self,
+ edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetContainerEditResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_container_edit(\"{}\") - X-Span-ID: {:?}",
+ edit_id,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_container_history(
+ &self,
+ ident: String,
+ limit: Option<i64>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetContainerHistoryResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_container_history(\"{}\", {:?}) - X-Span-ID: {:?}",
+ ident,
+ limit,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_container_redirects(
+ &self,
+ ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetContainerRedirectsResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_container_redirects(\"{}\") - X-Span-ID: {:?}",
+ ident,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_container_revision(
+ &self,
+ rev_id: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetContainerRevisionResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_container_revision(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}",
+ rev_id,
+ expand,
+ hide,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_creator(
+ &self,
+ ident: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetCreatorResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_creator(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}",
+ ident,
+ expand,
+ hide,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_creator_edit(
+ &self,
+ edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetCreatorEditResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_creator_edit(\"{}\") - X-Span-ID: {:?}",
+ edit_id,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_creator_history(
+ &self,
+ ident: String,
+ limit: Option<i64>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetCreatorHistoryResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_creator_history(\"{}\", {:?}) - X-Span-ID: {:?}",
+ ident,
+ limit,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_creator_redirects(
+ &self,
+ ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetCreatorRedirectsResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_creator_redirects(\"{}\") - X-Span-ID: {:?}",
+ ident,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_creator_releases(
+ &self,
+ ident: String,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetCreatorReleasesResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_creator_releases(\"{}\", {:?}) - X-Span-ID: {:?}",
+ ident,
+ hide,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_creator_revision(
+ &self,
+ rev_id: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetCreatorRevisionResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_creator_revision(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}",
+ rev_id,
+ expand,
+ hide,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_editgroup(
+ &self,
+ editgroup_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetEditgroupResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_editgroup(\"{}\") - X-Span-ID: {:?}",
+ editgroup_id,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_editgroup_annotations(
+ &self,
+ editgroup_id: String,
+ expand: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetEditgroupAnnotationsResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_editgroup_annotations(\"{}\", {:?}) - X-Span-ID: {:?}",
+ editgroup_id,
+ expand,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_editgroups_reviewable(
+ &self,
+ expand: Option<String>,
+ limit: Option<i64>,
+ before: Option<chrono::DateTime<chrono::Utc>>,
+ since: Option<chrono::DateTime<chrono::Utc>>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetEditgroupsReviewableResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_editgroups_reviewable({:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}",
+ expand,
+ limit,
+ before,
+ since,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_editor(
+ &self,
+ editor_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetEditorResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_editor(\"{}\") - X-Span-ID: {:?}",
+ editor_id,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_editor_annotations(
+ &self,
+ editor_id: String,
+ limit: Option<i64>,
+ before: Option<chrono::DateTime<chrono::Utc>>,
+ since: Option<chrono::DateTime<chrono::Utc>>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetEditorAnnotationsResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_editor_annotations(\"{}\", {:?}, {:?}, {:?}) - X-Span-ID: {:?}",
+ editor_id,
+ limit,
+ before,
+ since,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_editor_editgroups(
+ &self,
+ editor_id: String,
+ limit: Option<i64>,
+ before: Option<chrono::DateTime<chrono::Utc>>,
+ since: Option<chrono::DateTime<chrono::Utc>>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetEditorEditgroupsResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_editor_editgroups(\"{}\", {:?}, {:?}, {:?}) - X-Span-ID: {:?}",
+ editor_id,
+ limit,
+ before,
+ since,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_file(
+ &self,
+ ident: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetFileResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_file(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}",
+ ident,
+ expand,
+ hide,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_file_edit(
+ &self,
+ edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetFileEditResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_file_edit(\"{}\") - X-Span-ID: {:?}",
+ edit_id,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_file_history(
+ &self,
+ ident: String,
+ limit: Option<i64>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetFileHistoryResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_file_history(\"{}\", {:?}) - X-Span-ID: {:?}",
+ ident,
+ limit,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_file_redirects(
+ &self,
+ ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetFileRedirectsResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_file_redirects(\"{}\") - X-Span-ID: {:?}",
+ ident,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_file_revision(
+ &self,
+ rev_id: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetFileRevisionResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_file_revision(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}",
+ rev_id,
+ expand,
+ hide,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_fileset(
+ &self,
+ ident: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetFilesetResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_fileset(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}",
+ ident,
+ expand,
+ hide,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_fileset_edit(
+ &self,
+ edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetFilesetEditResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_fileset_edit(\"{}\") - X-Span-ID: {:?}",
+ edit_id,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_fileset_history(
+ &self,
+ ident: String,
+ limit: Option<i64>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetFilesetHistoryResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_fileset_history(\"{}\", {:?}) - X-Span-ID: {:?}",
+ ident,
+ limit,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_fileset_redirects(
+ &self,
+ ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetFilesetRedirectsResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_fileset_redirects(\"{}\") - X-Span-ID: {:?}",
+ ident,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_fileset_revision(
+ &self,
+ rev_id: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetFilesetRevisionResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_fileset_revision(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}",
+ rev_id,
+ expand,
+ hide,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_release(
+ &self,
+ ident: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetReleaseResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_release(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}",
+ ident,
+ expand,
+ hide,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_release_edit(
+ &self,
+ edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetReleaseEditResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_release_edit(\"{}\") - X-Span-ID: {:?}",
+ edit_id,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_release_files(
+ &self,
+ ident: String,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetReleaseFilesResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_release_files(\"{}\", {:?}) - X-Span-ID: {:?}",
+ ident,
+ hide,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_release_filesets(
+ &self,
+ ident: String,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetReleaseFilesetsResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_release_filesets(\"{}\", {:?}) - X-Span-ID: {:?}",
+ ident,
+ hide,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_release_history(
+ &self,
+ ident: String,
+ limit: Option<i64>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetReleaseHistoryResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_release_history(\"{}\", {:?}) - X-Span-ID: {:?}",
+ ident,
+ limit,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_release_redirects(
+ &self,
+ ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetReleaseRedirectsResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_release_redirects(\"{}\") - X-Span-ID: {:?}",
+ ident,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_release_revision(
+ &self,
+ rev_id: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetReleaseRevisionResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_release_revision(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}",
+ rev_id,
+ expand,
+ hide,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_release_webcaptures(
+ &self,
+ ident: String,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetReleaseWebcapturesResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_release_webcaptures(\"{}\", {:?}) - X-Span-ID: {:?}",
+ ident,
+ hide,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_webcapture(
+ &self,
+ ident: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetWebcaptureResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_webcapture(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}",
+ ident,
+ expand,
+ hide,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_webcapture_edit(
+ &self,
+ edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetWebcaptureEditResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_webcapture_edit(\"{}\") - X-Span-ID: {:?}",
+ edit_id,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_webcapture_history(
+ &self,
+ ident: String,
+ limit: Option<i64>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetWebcaptureHistoryResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_webcapture_history(\"{}\", {:?}) - X-Span-ID: {:?}",
+ ident,
+ limit,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_webcapture_redirects(
+ &self,
+ ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetWebcaptureRedirectsResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_webcapture_redirects(\"{}\") - X-Span-ID: {:?}",
+ ident,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_webcapture_revision(
+ &self,
+ rev_id: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetWebcaptureRevisionResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_webcapture_revision(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}",
+ rev_id,
+ expand,
+ hide,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_work(
+ &self,
+ ident: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetWorkResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_work(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}",
+ ident,
+ expand,
+ hide,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_work_edit(
+ &self,
+ edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetWorkEditResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_work_edit(\"{}\") - X-Span-ID: {:?}",
+ edit_id,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_work_history(
+ &self,
+ ident: String,
+ limit: Option<i64>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetWorkHistoryResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_work_history(\"{}\", {:?}) - X-Span-ID: {:?}",
+ ident,
+ limit,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_work_redirects(
+ &self,
+ ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetWorkRedirectsResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_work_redirects(\"{}\") - X-Span-ID: {:?}",
+ ident,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_work_releases(
+ &self,
+ ident: String,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetWorkReleasesResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_work_releases(\"{}\", {:?}) - X-Span-ID: {:?}",
+ ident,
+ hide,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn get_work_revision(
+ &self,
+ rev_id: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetWorkRevisionResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "get_work_revision(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}",
+ rev_id,
+ expand,
+ hide,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn lookup_container(
+ &self,
+ issnl: Option<String>,
+ wikidata_qid: Option<String>,
+ expand: Option<String>,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = LookupContainerResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "lookup_container({:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}",
+ issnl,
+ wikidata_qid,
+ expand,
+ hide,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn lookup_creator(
+ &self,
+ orcid: Option<String>,
+ wikidata_qid: Option<String>,
+ expand: Option<String>,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = LookupCreatorResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "lookup_creator({:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}",
+ orcid,
+ wikidata_qid,
+ expand,
+ hide,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn lookup_file(
+ &self,
+ md5: Option<String>,
+ sha1: Option<String>,
+ sha256: Option<String>,
+ expand: Option<String>,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = LookupFileResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "lookup_file({:?}, {:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}",
+ md5,
+ sha1,
+ sha256,
+ expand,
+ hide,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn lookup_release(
+ &self,
+ doi: Option<String>,
+ wikidata_qid: Option<String>,
+ isbn13: Option<String>,
+ pmid: Option<String>,
+ pmcid: Option<String>,
+ core: Option<String>,
+ arxiv: Option<String>,
+ jstor: Option<String>,
+ ark: Option<String>,
+ mag: Option<String>,
+ expand: Option<String>,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = LookupReleaseResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!("lookup_release({:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", doi, wikidata_qid, isbn13, pmid, pmcid, core, arxiv, jstor, ark, mag, expand, hide, context.get().0.clone());
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn update_container(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ entity: models::ContainerEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = UpdateContainerResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "update_container(\"{}\", \"{}\", {:?}) - X-Span-ID: {:?}",
+ editgroup_id,
+ ident,
+ entity,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn update_creator(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ entity: models::CreatorEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = UpdateCreatorResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "update_creator(\"{}\", \"{}\", {:?}) - X-Span-ID: {:?}",
+ editgroup_id,
+ ident,
+ entity,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn update_editgroup(
+ &self,
+ editgroup_id: String,
+ editgroup: models::Editgroup,
+ submit: Option<bool>,
+ context: &C,
+ ) -> Box<dyn Future<Item = UpdateEditgroupResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "update_editgroup(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}",
+ editgroup_id,
+ editgroup,
+ submit,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn update_editor(
+ &self,
+ editor_id: String,
+ editor: models::Editor,
+ context: &C,
+ ) -> Box<dyn Future<Item = UpdateEditorResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "update_editor(\"{}\", {:?}) - X-Span-ID: {:?}",
+ editor_id,
+ editor,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn update_file(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ entity: models::FileEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = UpdateFileResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "update_file(\"{}\", \"{}\", {:?}) - X-Span-ID: {:?}",
+ editgroup_id,
+ ident,
+ entity,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn update_fileset(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ entity: models::FilesetEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = UpdateFilesetResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "update_fileset(\"{}\", \"{}\", {:?}) - X-Span-ID: {:?}",
+ editgroup_id,
+ ident,
+ entity,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn update_release(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ entity: models::ReleaseEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = UpdateReleaseResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "update_release(\"{}\", \"{}\", {:?}) - X-Span-ID: {:?}",
+ editgroup_id,
+ ident,
+ entity,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn update_webcapture(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ entity: models::WebcaptureEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = UpdateWebcaptureResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "update_webcapture(\"{}\", \"{}\", {:?}) - X-Span-ID: {:?}",
+ editgroup_id,
+ ident,
+ entity,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+
+ fn update_work(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ entity: models::WorkEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = UpdateWorkResponse, Error = ApiError> + Send> {
+ let context = context.clone();
+ info!(
+ "update_work(\"{}\", \"{}\", {:?}) - X-Span-ID: {:?}",
+ editgroup_id,
+ ident,
+ entity,
+ context.get().0.clone()
+ );
+ Box::new(future::err("Generic failure".into()))
+ }
+}
diff --git a/rust/fatcat-openapi/examples/server_lib/mod.rs b/rust/fatcat-openapi/examples/server_lib/mod.rs
deleted file mode 100644
index bf404d49..00000000
--- a/rust/fatcat-openapi/examples/server_lib/mod.rs
+++ /dev/null
@@ -1,14 +0,0 @@
-//! Main library entry point for fatcat implementation.
-
-mod server;
-
-mod errors {
- error_chain! {}
-}
-
-pub use self::errors::*;
-
-/// Instantiate a new server.
-pub fn server() -> Result<server::Server> {
- Ok(server::Server {})
-}
diff --git a/rust/fatcat-openapi/examples/server_lib/server.rs b/rust/fatcat-openapi/examples/server_lib/server.rs
deleted file mode 100644
index 838bd63d..00000000
--- a/rust/fatcat-openapi/examples/server_lib/server.rs
+++ /dev/null
@@ -1,1081 +0,0 @@
-//! Server implementation of fatcat.
-
-#![allow(unused_imports)]
-
-use chrono;
-use futures::{self, Future};
-
-use std::collections::HashMap;
-
-use swagger;
-
-use fatcat_openapi::models;
-use fatcat_openapi::{
- AcceptEditgroupResponse, Api, ApiError, AuthCheckResponse, AuthOidcResponse, Context, CreateAuthTokenResponse, 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 auth_check(&self, role: Option<String>, context: &Context) -> Box<dyn Future<Item = AuthCheckResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!("auth_check({:?}) - X-Span-ID: {:?}", role, context.x_span_id.unwrap_or(String::from("<none>")).clone());
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn auth_oidc(&self, oidc_params: models::AuthOidc, context: &Context) -> Box<dyn Future<Item = AuthOidcResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!("auth_oidc({:?}) - X-Span-ID: {:?}", oidc_params, context.x_span_id.unwrap_or(String::from("<none>")).clone());
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn create_auth_token(&self, editor_id: String, duration_seconds: Option<i32>, context: &Context) -> Box<dyn Future<Item = CreateAuthTokenResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "create_auth_token(\"{}\", {:?}) - X-Span-ID: {:?}",
- editor_id,
- duration_seconds,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_changelog(&self, limit: Option<i64>, context: &Context) -> Box<dyn Future<Item = GetChangelogResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!("get_changelog({:?}) - X-Span-ID: {:?}", limit, context.x_span_id.unwrap_or(String::from("<none>")).clone());
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_changelog_entry(&self, index: i64, context: &Context) -> Box<dyn Future<Item = GetChangelogEntryResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!("get_changelog_entry({}) - X-Span-ID: {:?}", index, context.x_span_id.unwrap_or(String::from("<none>")).clone());
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn create_container(&self, editgroup_id: String, entity: models::ContainerEntity, context: &Context) -> Box<dyn Future<Item = CreateContainerResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "create_container(\"{}\", {:?}) - X-Span-ID: {:?}",
- editgroup_id,
- entity,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn create_container_auto_batch(&self, auto_batch: models::ContainerAutoBatch, context: &Context) -> Box<dyn Future<Item = CreateContainerAutoBatchResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "create_container_auto_batch({:?}) - X-Span-ID: {:?}",
- auto_batch,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn delete_container(&self, editgroup_id: String, ident: String, context: &Context) -> Box<dyn Future<Item = DeleteContainerResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "delete_container(\"{}\", \"{}\") - X-Span-ID: {:?}",
- editgroup_id,
- ident,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn delete_container_edit(&self, editgroup_id: String, edit_id: String, context: &Context) -> Box<dyn Future<Item = DeleteContainerEditResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "delete_container_edit(\"{}\", \"{}\") - X-Span-ID: {:?}",
- editgroup_id,
- edit_id,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_container(&self, ident: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetContainerResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "get_container(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}",
- ident,
- expand,
- hide,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_container_edit(&self, edit_id: String, context: &Context) -> Box<dyn Future<Item = GetContainerEditResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!("get_container_edit(\"{}\") - X-Span-ID: {:?}", edit_id, context.x_span_id.unwrap_or(String::from("<none>")).clone());
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_container_history(&self, ident: String, limit: Option<i64>, context: &Context) -> Box<dyn Future<Item = GetContainerHistoryResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "get_container_history(\"{}\", {:?}) - X-Span-ID: {:?}",
- ident,
- limit,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_container_redirects(&self, ident: String, context: &Context) -> Box<dyn Future<Item = GetContainerRedirectsResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!("get_container_redirects(\"{}\") - X-Span-ID: {:?}", ident, context.x_span_id.unwrap_or(String::from("<none>")).clone());
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_container_revision(&self, rev_id: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetContainerRevisionResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "get_container_revision(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}",
- rev_id,
- expand,
- hide,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn lookup_container(
- &self,
- issnl: Option<String>,
- wikidata_qid: Option<String>,
- expand: Option<String>,
- hide: Option<String>,
- context: &Context,
- ) -> Box<dyn Future<Item = LookupContainerResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "lookup_container({:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}",
- issnl,
- wikidata_qid,
- expand,
- hide,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn update_container(&self, editgroup_id: String, ident: String, entity: models::ContainerEntity, context: &Context) -> Box<dyn Future<Item = UpdateContainerResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "update_container(\"{}\", \"{}\", {:?}) - X-Span-ID: {:?}",
- editgroup_id,
- ident,
- entity,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn create_creator(&self, editgroup_id: String, entity: models::CreatorEntity, context: &Context) -> Box<dyn Future<Item = CreateCreatorResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "create_creator(\"{}\", {:?}) - X-Span-ID: {:?}",
- editgroup_id,
- entity,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn create_creator_auto_batch(&self, auto_batch: models::CreatorAutoBatch, context: &Context) -> Box<dyn Future<Item = CreateCreatorAutoBatchResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "create_creator_auto_batch({:?}) - X-Span-ID: {:?}",
- auto_batch,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn delete_creator(&self, editgroup_id: String, ident: String, context: &Context) -> Box<dyn Future<Item = DeleteCreatorResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "delete_creator(\"{}\", \"{}\") - X-Span-ID: {:?}",
- editgroup_id,
- ident,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn delete_creator_edit(&self, editgroup_id: String, edit_id: String, context: &Context) -> Box<dyn Future<Item = DeleteCreatorEditResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "delete_creator_edit(\"{}\", \"{}\") - X-Span-ID: {:?}",
- editgroup_id,
- edit_id,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_creator(&self, ident: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetCreatorResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "get_creator(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}",
- ident,
- expand,
- hide,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_creator_edit(&self, edit_id: String, context: &Context) -> Box<dyn Future<Item = GetCreatorEditResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!("get_creator_edit(\"{}\") - X-Span-ID: {:?}", edit_id, context.x_span_id.unwrap_or(String::from("<none>")).clone());
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_creator_history(&self, ident: String, limit: Option<i64>, context: &Context) -> Box<dyn Future<Item = GetCreatorHistoryResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "get_creator_history(\"{}\", {:?}) - X-Span-ID: {:?}",
- ident,
- limit,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_creator_redirects(&self, ident: String, context: &Context) -> Box<dyn Future<Item = GetCreatorRedirectsResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!("get_creator_redirects(\"{}\") - X-Span-ID: {:?}", ident, context.x_span_id.unwrap_or(String::from("<none>")).clone());
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_creator_releases(&self, ident: String, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetCreatorReleasesResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "get_creator_releases(\"{}\", {:?}) - X-Span-ID: {:?}",
- ident,
- hide,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_creator_revision(&self, rev_id: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetCreatorRevisionResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "get_creator_revision(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}",
- rev_id,
- expand,
- hide,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn lookup_creator(
- &self,
- orcid: Option<String>,
- wikidata_qid: Option<String>,
- expand: Option<String>,
- hide: Option<String>,
- context: &Context,
- ) -> Box<dyn Future<Item = LookupCreatorResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "lookup_creator({:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}",
- orcid,
- wikidata_qid,
- expand,
- hide,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn update_creator(&self, editgroup_id: String, ident: String, entity: models::CreatorEntity, context: &Context) -> Box<dyn Future<Item = UpdateCreatorResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "update_creator(\"{}\", \"{}\", {:?}) - X-Span-ID: {:?}",
- editgroup_id,
- ident,
- entity,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn accept_editgroup(&self, editgroup_id: String, context: &Context) -> Box<dyn Future<Item = AcceptEditgroupResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!("accept_editgroup(\"{}\") - X-Span-ID: {:?}", editgroup_id, context.x_span_id.unwrap_or(String::from("<none>")).clone());
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn create_editgroup(&self, editgroup: models::Editgroup, context: &Context) -> Box<dyn Future<Item = CreateEditgroupResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!("create_editgroup({:?}) - X-Span-ID: {:?}", editgroup, context.x_span_id.unwrap_or(String::from("<none>")).clone());
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn create_editgroup_annotation(
- &self,
- editgroup_id: String,
- annotation: models::EditgroupAnnotation,
- context: &Context,
- ) -> Box<dyn Future<Item = CreateEditgroupAnnotationResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "create_editgroup_annotation(\"{}\", {:?}) - X-Span-ID: {:?}",
- editgroup_id,
- annotation,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_editgroup(&self, editgroup_id: String, context: &Context) -> Box<dyn Future<Item = GetEditgroupResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!("get_editgroup(\"{}\") - X-Span-ID: {:?}", editgroup_id, context.x_span_id.unwrap_or(String::from("<none>")).clone());
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_editgroup_annotations(&self, editgroup_id: String, expand: Option<String>, context: &Context) -> Box<dyn Future<Item = GetEditgroupAnnotationsResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "get_editgroup_annotations(\"{}\", {:?}) - X-Span-ID: {:?}",
- editgroup_id,
- expand,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_editgroups_reviewable(
- &self,
- expand: Option<String>,
- limit: Option<i64>,
- before: Option<chrono::DateTime<chrono::Utc>>,
- since: Option<chrono::DateTime<chrono::Utc>>,
- context: &Context,
- ) -> Box<dyn Future<Item = GetEditgroupsReviewableResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "get_editgroups_reviewable({:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}",
- expand,
- limit,
- before,
- since,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn update_editgroup(
- &self,
- editgroup_id: String,
- editgroup: models::Editgroup,
- submit: Option<bool>,
- context: &Context,
- ) -> Box<dyn Future<Item = UpdateEditgroupResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "update_editgroup(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}",
- editgroup_id,
- editgroup,
- submit,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_editor(&self, editor_id: String, context: &Context) -> Box<dyn Future<Item = GetEditorResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!("get_editor(\"{}\") - X-Span-ID: {:?}", editor_id, context.x_span_id.unwrap_or(String::from("<none>")).clone());
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_editor_annotations(
- &self,
- editor_id: String,
- limit: Option<i64>,
- before: Option<chrono::DateTime<chrono::Utc>>,
- since: Option<chrono::DateTime<chrono::Utc>>,
- context: &Context,
- ) -> Box<dyn Future<Item = GetEditorAnnotationsResponse, Error = ApiError> + 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("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_editor_editgroups(
- &self,
- editor_id: String,
- limit: Option<i64>,
- before: Option<chrono::DateTime<chrono::Utc>>,
- since: Option<chrono::DateTime<chrono::Utc>>,
- context: &Context,
- ) -> Box<dyn Future<Item = GetEditorEditgroupsResponse, Error = ApiError> + 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("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn update_editor(&self, editor_id: String, editor: models::Editor, context: &Context) -> Box<dyn Future<Item = UpdateEditorResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "update_editor(\"{}\", {:?}) - X-Span-ID: {:?}",
- editor_id,
- editor,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn create_file(&self, editgroup_id: String, entity: models::FileEntity, context: &Context) -> Box<dyn Future<Item = CreateFileResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "create_file(\"{}\", {:?}) - X-Span-ID: {:?}",
- editgroup_id,
- entity,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn create_file_auto_batch(&self, auto_batch: models::FileAutoBatch, context: &Context) -> Box<dyn Future<Item = CreateFileAutoBatchResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "create_file_auto_batch({:?}) - X-Span-ID: {:?}",
- auto_batch,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn delete_file(&self, editgroup_id: String, ident: String, context: &Context) -> Box<dyn Future<Item = DeleteFileResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "delete_file(\"{}\", \"{}\") - X-Span-ID: {:?}",
- editgroup_id,
- ident,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn delete_file_edit(&self, editgroup_id: String, edit_id: String, context: &Context) -> Box<dyn Future<Item = DeleteFileEditResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "delete_file_edit(\"{}\", \"{}\") - X-Span-ID: {:?}",
- editgroup_id,
- edit_id,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_file(&self, ident: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetFileResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "get_file(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}",
- ident,
- expand,
- hide,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_file_edit(&self, edit_id: String, context: &Context) -> Box<dyn Future<Item = GetFileEditResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!("get_file_edit(\"{}\") - X-Span-ID: {:?}", edit_id, context.x_span_id.unwrap_or(String::from("<none>")).clone());
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_file_history(&self, ident: String, limit: Option<i64>, context: &Context) -> Box<dyn Future<Item = GetFileHistoryResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "get_file_history(\"{}\", {:?}) - X-Span-ID: {:?}",
- ident,
- limit,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_file_redirects(&self, ident: String, context: &Context) -> Box<dyn Future<Item = GetFileRedirectsResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!("get_file_redirects(\"{}\") - X-Span-ID: {:?}", ident, context.x_span_id.unwrap_or(String::from("<none>")).clone());
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_file_revision(&self, rev_id: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetFileRevisionResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "get_file_revision(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}",
- rev_id,
- expand,
- hide,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn lookup_file(
- &self,
- md5: Option<String>,
- sha1: Option<String>,
- sha256: Option<String>,
- expand: Option<String>,
- hide: Option<String>,
- context: &Context,
- ) -> Box<dyn Future<Item = LookupFileResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "lookup_file({:?}, {:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}",
- md5,
- sha1,
- sha256,
- expand,
- hide,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn update_file(&self, editgroup_id: String, ident: String, entity: models::FileEntity, context: &Context) -> Box<dyn Future<Item = UpdateFileResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "update_file(\"{}\", \"{}\", {:?}) - X-Span-ID: {:?}",
- editgroup_id,
- ident,
- entity,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn create_fileset(&self, editgroup_id: String, entity: models::FilesetEntity, context: &Context) -> Box<dyn Future<Item = CreateFilesetResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "create_fileset(\"{}\", {:?}) - X-Span-ID: {:?}",
- editgroup_id,
- entity,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn create_fileset_auto_batch(&self, auto_batch: models::FilesetAutoBatch, context: &Context) -> Box<dyn Future<Item = CreateFilesetAutoBatchResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "create_fileset_auto_batch({:?}) - X-Span-ID: {:?}",
- auto_batch,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn delete_fileset(&self, editgroup_id: String, ident: String, context: &Context) -> Box<dyn Future<Item = DeleteFilesetResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "delete_fileset(\"{}\", \"{}\") - X-Span-ID: {:?}",
- editgroup_id,
- ident,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn delete_fileset_edit(&self, editgroup_id: String, edit_id: String, context: &Context) -> Box<dyn Future<Item = DeleteFilesetEditResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "delete_fileset_edit(\"{}\", \"{}\") - X-Span-ID: {:?}",
- editgroup_id,
- edit_id,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_fileset(&self, ident: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetFilesetResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "get_fileset(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}",
- ident,
- expand,
- hide,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_fileset_edit(&self, edit_id: String, context: &Context) -> Box<dyn Future<Item = GetFilesetEditResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!("get_fileset_edit(\"{}\") - X-Span-ID: {:?}", edit_id, context.x_span_id.unwrap_or(String::from("<none>")).clone());
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_fileset_history(&self, ident: String, limit: Option<i64>, context: &Context) -> Box<dyn Future<Item = GetFilesetHistoryResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "get_fileset_history(\"{}\", {:?}) - X-Span-ID: {:?}",
- ident,
- limit,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_fileset_redirects(&self, ident: String, context: &Context) -> Box<dyn Future<Item = GetFilesetRedirectsResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!("get_fileset_redirects(\"{}\") - X-Span-ID: {:?}", ident, context.x_span_id.unwrap_or(String::from("<none>")).clone());
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_fileset_revision(&self, rev_id: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetFilesetRevisionResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "get_fileset_revision(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}",
- rev_id,
- expand,
- hide,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn update_fileset(&self, editgroup_id: String, ident: String, entity: models::FilesetEntity, context: &Context) -> Box<dyn Future<Item = UpdateFilesetResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "update_fileset(\"{}\", \"{}\", {:?}) - X-Span-ID: {:?}",
- editgroup_id,
- ident,
- entity,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn create_release(&self, editgroup_id: String, entity: models::ReleaseEntity, context: &Context) -> Box<dyn Future<Item = CreateReleaseResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "create_release(\"{}\", {:?}) - X-Span-ID: {:?}",
- editgroup_id,
- entity,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn create_release_auto_batch(&self, auto_batch: models::ReleaseAutoBatch, context: &Context) -> Box<dyn Future<Item = CreateReleaseAutoBatchResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "create_release_auto_batch({:?}) - X-Span-ID: {:?}",
- auto_batch,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn delete_release(&self, editgroup_id: String, ident: String, context: &Context) -> Box<dyn Future<Item = DeleteReleaseResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "delete_release(\"{}\", \"{}\") - X-Span-ID: {:?}",
- editgroup_id,
- ident,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn delete_release_edit(&self, editgroup_id: String, edit_id: String, context: &Context) -> Box<dyn Future<Item = DeleteReleaseEditResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "delete_release_edit(\"{}\", \"{}\") - X-Span-ID: {:?}",
- editgroup_id,
- edit_id,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_release(&self, ident: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetReleaseResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "get_release(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}",
- ident,
- expand,
- hide,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_release_edit(&self, edit_id: String, context: &Context) -> Box<dyn Future<Item = GetReleaseEditResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!("get_release_edit(\"{}\") - X-Span-ID: {:?}", edit_id, context.x_span_id.unwrap_or(String::from("<none>")).clone());
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_release_files(&self, ident: String, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetReleaseFilesResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "get_release_files(\"{}\", {:?}) - X-Span-ID: {:?}",
- ident,
- hide,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_release_filesets(&self, ident: String, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetReleaseFilesetsResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "get_release_filesets(\"{}\", {:?}) - X-Span-ID: {:?}",
- ident,
- hide,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_release_history(&self, ident: String, limit: Option<i64>, context: &Context) -> Box<dyn Future<Item = GetReleaseHistoryResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "get_release_history(\"{}\", {:?}) - X-Span-ID: {:?}",
- ident,
- limit,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_release_redirects(&self, ident: String, context: &Context) -> Box<dyn Future<Item = GetReleaseRedirectsResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!("get_release_redirects(\"{}\") - X-Span-ID: {:?}", ident, context.x_span_id.unwrap_or(String::from("<none>")).clone());
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_release_revision(&self, rev_id: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetReleaseRevisionResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "get_release_revision(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}",
- rev_id,
- expand,
- hide,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_release_webcaptures(&self, ident: String, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetReleaseWebcapturesResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "get_release_webcaptures(\"{}\", {:?}) - X-Span-ID: {:?}",
- ident,
- hide,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn lookup_release(
- &self,
- doi: Option<String>,
- wikidata_qid: Option<String>,
- isbn13: Option<String>,
- pmid: Option<String>,
- pmcid: Option<String>,
- core: Option<String>,
- arxiv: Option<String>,
- jstor: Option<String>,
- ark: Option<String>,
- mag: Option<String>,
- expand: Option<String>,
- hide: Option<String>,
- context: &Context,
- ) -> Box<dyn Future<Item = LookupReleaseResponse, Error = ApiError> + 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("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn update_release(&self, editgroup_id: String, ident: String, entity: models::ReleaseEntity, context: &Context) -> Box<dyn Future<Item = UpdateReleaseResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "update_release(\"{}\", \"{}\", {:?}) - X-Span-ID: {:?}",
- editgroup_id,
- ident,
- entity,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn create_webcapture(&self, editgroup_id: String, entity: models::WebcaptureEntity, context: &Context) -> Box<dyn Future<Item = CreateWebcaptureResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "create_webcapture(\"{}\", {:?}) - X-Span-ID: {:?}",
- editgroup_id,
- entity,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn create_webcapture_auto_batch(&self, auto_batch: models::WebcaptureAutoBatch, context: &Context) -> Box<dyn Future<Item = CreateWebcaptureAutoBatchResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "create_webcapture_auto_batch({:?}) - X-Span-ID: {:?}",
- auto_batch,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn delete_webcapture(&self, editgroup_id: String, ident: String, context: &Context) -> Box<dyn Future<Item = DeleteWebcaptureResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "delete_webcapture(\"{}\", \"{}\") - X-Span-ID: {:?}",
- editgroup_id,
- ident,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn delete_webcapture_edit(&self, editgroup_id: String, edit_id: String, context: &Context) -> Box<dyn Future<Item = DeleteWebcaptureEditResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "delete_webcapture_edit(\"{}\", \"{}\") - X-Span-ID: {:?}",
- editgroup_id,
- edit_id,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_webcapture(&self, ident: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetWebcaptureResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "get_webcapture(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}",
- ident,
- expand,
- hide,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_webcapture_edit(&self, edit_id: String, context: &Context) -> Box<dyn Future<Item = GetWebcaptureEditResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!("get_webcapture_edit(\"{}\") - X-Span-ID: {:?}", edit_id, context.x_span_id.unwrap_or(String::from("<none>")).clone());
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_webcapture_history(&self, ident: String, limit: Option<i64>, context: &Context) -> Box<dyn Future<Item = GetWebcaptureHistoryResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "get_webcapture_history(\"{}\", {:?}) - X-Span-ID: {:?}",
- ident,
- limit,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_webcapture_redirects(&self, ident: String, context: &Context) -> Box<dyn Future<Item = GetWebcaptureRedirectsResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!("get_webcapture_redirects(\"{}\") - X-Span-ID: {:?}", ident, context.x_span_id.unwrap_or(String::from("<none>")).clone());
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_webcapture_revision(
- &self,
- rev_id: String,
- expand: Option<String>,
- hide: Option<String>,
- context: &Context,
- ) -> Box<dyn Future<Item = GetWebcaptureRevisionResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "get_webcapture_revision(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}",
- rev_id,
- expand,
- hide,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn update_webcapture(&self, editgroup_id: String, ident: String, entity: models::WebcaptureEntity, context: &Context) -> Box<dyn Future<Item = UpdateWebcaptureResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "update_webcapture(\"{}\", \"{}\", {:?}) - X-Span-ID: {:?}",
- editgroup_id,
- ident,
- entity,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn create_work(&self, editgroup_id: String, entity: models::WorkEntity, context: &Context) -> Box<dyn Future<Item = CreateWorkResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "create_work(\"{}\", {:?}) - X-Span-ID: {:?}",
- editgroup_id,
- entity,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn create_work_auto_batch(&self, auto_batch: models::WorkAutoBatch, context: &Context) -> Box<dyn Future<Item = CreateWorkAutoBatchResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "create_work_auto_batch({:?}) - X-Span-ID: {:?}",
- auto_batch,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn delete_work(&self, editgroup_id: String, ident: String, context: &Context) -> Box<dyn Future<Item = DeleteWorkResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "delete_work(\"{}\", \"{}\") - X-Span-ID: {:?}",
- editgroup_id,
- ident,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn delete_work_edit(&self, editgroup_id: String, edit_id: String, context: &Context) -> Box<dyn Future<Item = DeleteWorkEditResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "delete_work_edit(\"{}\", \"{}\") - X-Span-ID: {:?}",
- editgroup_id,
- edit_id,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_work(&self, ident: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetWorkResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "get_work(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}",
- ident,
- expand,
- hide,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_work_edit(&self, edit_id: String, context: &Context) -> Box<dyn Future<Item = GetWorkEditResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!("get_work_edit(\"{}\") - X-Span-ID: {:?}", edit_id, context.x_span_id.unwrap_or(String::from("<none>")).clone());
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_work_history(&self, ident: String, limit: Option<i64>, context: &Context) -> Box<dyn Future<Item = GetWorkHistoryResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "get_work_history(\"{}\", {:?}) - X-Span-ID: {:?}",
- ident,
- limit,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_work_redirects(&self, ident: String, context: &Context) -> Box<dyn Future<Item = GetWorkRedirectsResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!("get_work_redirects(\"{}\") - X-Span-ID: {:?}", ident, context.x_span_id.unwrap_or(String::from("<none>")).clone());
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_work_releases(&self, ident: String, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetWorkReleasesResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "get_work_releases(\"{}\", {:?}) - X-Span-ID: {:?}",
- ident,
- hide,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn get_work_revision(&self, rev_id: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetWorkRevisionResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "get_work_revision(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}",
- rev_id,
- expand,
- hide,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-
- fn update_work(&self, editgroup_id: String, ident: String, entity: models::WorkEntity, context: &Context) -> Box<dyn Future<Item = UpdateWorkResponse, Error = ApiError> + Send> {
- let context = context.clone();
- println!(
- "update_work(\"{}\", \"{}\", {:?}) - X-Span-ID: {:?}",
- editgroup_id,
- ident,
- entity,
- context.x_span_id.unwrap_or(String::from("<none>")).clone()
- );
- Box::new(futures::failed("Generic failure".into()))
- }
-}
diff --git a/rust/fatcat-openapi/rustfmt.toml b/rust/fatcat-openapi/rustfmt.toml
deleted file mode 100644
index cba42c2b..00000000
--- a/rust/fatcat-openapi/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-openapi/src/client.rs b/rust/fatcat-openapi/src/client.rs
deleted file mode 100644
index e1e8130e..00000000
--- a/rust/fatcat-openapi/src/client.rs
+++ /dev/null
@@ -1,7758 +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 crate::mimetypes;
-
-use serde_json;
-
-#[allow(unused_imports)]
-use std::collections::{BTreeMap, HashMap};
-#[allow(unused_imports)]
-use swagger;
-
-use swagger::{ApiError, Context, XSpanId};
-
-use crate::models;
-use crate::{
- AcceptEditgroupResponse, Api, AuthCheckResponse, AuthOidcResponse, CreateAuthTokenResponse, 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<T: IntoUrl>(input: T, correct_scheme: Option<&'static str>) -> Result<String, ClientInitError> {
- // First convert to Url, since a base path is a subset of Url.
- let url = input.into_url()?;
-
- let scheme = url.scheme();
-
- // Check the scheme if necessary
- if let Some(correct_scheme) = correct_scheme {
- if scheme != correct_scheme {
- return Err(ClientInitError::InvalidScheme);
- }
- }
-
- let host = url.host().ok_or_else(|| ClientInitError::MissingHost)?;
- let port = url.port().map(|x| format!(":{}", x)).unwrap_or_default();
- Ok(format!("{}://{}{}", scheme, host, port))
-}
-
-/// A client that implements the API by making HTTP calls out to a server.
-#[derive(Clone)]
-pub struct Client {
- base_path: String,
- hyper_client: Arc<dyn Fn() -> hyper::client::Client + Sync + Send>,
-}
-
-impl fmt::Debug for Client {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "Client {{ base_path: {} }}", self.base_path)
- }
-}
-
-impl Client {
- pub fn try_new_http<T>(base_path: T) -> Result<Client, ClientInitError>
- where
- T: IntoUrl,
- {
- Ok(Client {
- base_path: into_base_path(base_path, Some("http"))?,
- hyper_client: Arc::new(hyper::client::Client::new),
- })
- }
-
- pub fn try_new_https<T, CA>(base_path: T, ca_certificate: CA) -> Result<Client, ClientInitError>
- where
- T: IntoUrl,
- CA: AsRef<Path>,
- {
- let ca_certificate = ca_certificate.as_ref().to_owned();
-
- let https_hyper_client = move || {
- // SSL implementation
- let mut ssl = openssl::ssl::SslConnectorBuilder::new(openssl::ssl::SslMethod::tls()).unwrap();
-
- // Server authentication
- ssl.set_ca_file(ca_certificate.clone()).unwrap();
-
- let ssl = hyper_openssl::OpensslClient::from(ssl.build());
- let connector = hyper::net::HttpsConnector::new(ssl);
- hyper::client::Client::with_connector(connector)
- };
-
- Ok(Client {
- base_path: into_base_path(base_path, Some("https"))?,
- hyper_client: Arc::new(https_hyper_client),
- })
- }
-
- pub fn try_new_https_mutual<T, CA, K, C>(base_path: T, ca_certificate: CA, client_key: K, client_certificate: C) -> Result<Client, ClientInitError>
- where
- T: IntoUrl,
- CA: AsRef<Path>,
- K: AsRef<Path>,
- C: AsRef<Path>,
- {
- let ca_certificate = ca_certificate.as_ref().to_owned();
- let client_key = client_key.as_ref().to_owned();
- let client_certificate = client_certificate.as_ref().to_owned();
-
- let https_mutual_hyper_client = move || {
- // SSL implementation
- let mut ssl = openssl::ssl::SslConnectorBuilder::new(openssl::ssl::SslMethod::tls()).unwrap();
-
- // Server authentication
- ssl.set_ca_file(ca_certificate.clone()).unwrap();
-
- // Client authentication
- ssl.set_private_key_file(client_key.clone(), openssl::x509::X509_FILETYPE_PEM).unwrap();
- ssl.set_certificate_chain_file(client_certificate.clone()).unwrap();
- ssl.check_private_key().unwrap();
-
- let ssl = hyper_openssl::OpensslClient::from(ssl.build());
- let connector = hyper::net::HttpsConnector::new(ssl);
- hyper::client::Client::with_connector(connector)
- };
-
- Ok(Client {
- base_path: into_base_path(base_path, Some("https"))?,
- hyper_client: Arc::new(https_mutual_hyper_client),
- })
- }
-
- /// Constructor for creating a `Client` by passing in a pre-made `hyper` client.
- ///
- /// One should avoid relying on this function if possible, since it adds a dependency on the underlying transport
- /// implementation, which it would be better to abstract away. Therefore, using this function may lead to a loss of
- /// code generality, which may make it harder to move the application to a serverless environment, for example.
- ///
- /// The reason for this function's existence is to support legacy test code, which did mocking at the hyper layer.
- /// This is not a recommended way to write new tests. If other reasons are found for using this function, they
- /// should be mentioned here.
- pub fn try_new_with_hyper_client<T>(base_path: T, hyper_client: Arc<dyn Fn() -> hyper::client::Client + Sync + Send>) -> Result<Client, ClientInitError>
- where
- T: IntoUrl,
- {
- Ok(Client {
- base_path: into_base_path(base_path, None)?,
- hyper_client: hyper_client,
- })
- }
-}
-
-impl Api for Client {
- fn auth_check(&self, param_role: Option<String>, context: &Context) -> Box<dyn Future<Item = AuthCheckResponse, Error = ApiError> + 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<AuthCheckResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::Success>(&buf)?;
-
- Ok(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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn auth_oidc(&self, param_oidc_params: models::AuthOidc, context: &Context) -> Box<dyn Future<Item = AuthOidcResponse, Error = ApiError> + Send> {
- let url = format!("{}/v0/auth/oidc", self.base_path);
-
- let body = serde_json::to_string(&param_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<AuthOidcResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::AuthOidcResult>(&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::<models::AuthOidcResult>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn create_auth_token(&self, param_editor_id: String, param_duration_seconds: Option<i32>, context: &Context) -> Box<dyn Future<Item = CreateAuthTokenResponse, Error = ApiError> + Send> {
- // Query parameters
- let query_duration_seconds = param_duration_seconds.map_or_else(String::new, |query| format!("duration_seconds={duration_seconds}&", duration_seconds = query.to_string()));
-
- let url = format!(
- "{}/v0/auth/token/{editor_id}?{duration_seconds}",
- self.base_path,
- editor_id = utf8_percent_encode(&param_editor_id.to_string(), PATH_SEGMENT_ENCODE_SET),
- duration_seconds = utf8_percent_encode(&query_duration_seconds, QUERY_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<CreateAuthTokenResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::AuthTokenResult>(&buf)?;
-
- Ok(CreateAuthTokenResponse::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::<models::ErrorResponse>(&buf)?;
-
- Ok(CreateAuthTokenResponse::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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?;
-
- Ok(CreateAuthTokenResponse::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::<models::ErrorResponse>(&buf)?;
-
- Ok(CreateAuthTokenResponse::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::<models::ErrorResponse>(&buf)?;
-
- Ok(CreateAuthTokenResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_changelog(&self, param_limit: Option<i64>, context: &Context) -> Box<dyn Future<Item = GetChangelogResponse, Error = ApiError> + Send> {
- // Query parameters
- let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string()));
-
- let url = format!("{}/v0/changelog?{limit}", self.base_path, limit = utf8_percent_encode(&query_limit, QUERY_ENCODE_SET));
-
- let hyper_client = (self.hyper_client)();
- let request = hyper_client.request(hyper::method::Method::Get, &url);
- let mut custom_headers = hyper::header::Headers::new();
-
- context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
-
- let request = request.headers(custom_headers);
-
- // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<GetChangelogResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<Vec<models::ChangelogEntry>>(&buf)?;
-
- Ok(GetChangelogResponse::Success(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(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::<models::ErrorResponse>(&buf)?;
-
- Ok(GetChangelogResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_changelog_entry(&self, param_index: i64, context: &Context) -> Box<dyn Future<Item = GetChangelogEntryResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/changelog/{index}",
- self.base_path,
- index = utf8_percent_encode(&param_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<GetChangelogEntryResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ChangelogEntry>(&buf)?;
-
- Ok(GetChangelogEntryResponse::FoundChangelogEntry(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(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::<models::ErrorResponse>(&buf)?;
-
- Ok(GetChangelogEntryResponse::NotFound(body))
- }
- 500 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetChangelogEntryResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn create_container(&self, param_editgroup_id: String, param_entity: models::ContainerEntity, context: &Context) -> Box<dyn Future<Item = CreateContainerResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/editgroup/{editgroup_id}/container",
- self.base_path,
- editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET)
- );
-
- let body = serde_json::to_string(&param_entity).expect("impossible to fail to serialize");
-
- let hyper_client = (self.hyper_client)();
- let request = hyper_client.request(hyper::method::Method::Post, &url);
- let mut custom_headers = hyper::header::Headers::new();
-
- let request = request.body(&body);
-
- custom_headers.set(ContentType(mimetypes::requests::CREATE_CONTAINER.clone()));
- context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
-
- let request = request.headers(custom_headers);
-
- // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<CreateContainerResponse, ApiError> {
- match response.status.to_u16() {
- 201 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::EntityEdit>(&buf)?;
-
- Ok(CreateContainerResponse::CreatedEntity(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(CreateContainerResponse::BadRequest(body))
- }
- 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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
-
- Ok(CreateContainerResponse::NotFound(body))
- }
- 500 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(CreateContainerResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn create_container_auto_batch(&self, param_auto_batch: models::ContainerAutoBatch, context: &Context) -> Box<dyn Future<Item = CreateContainerAutoBatchResponse, Error = ApiError> + Send> {
- let url = format!("{}/v0/editgroup/auto/container/batch", self.base_path);
-
- let body = serde_json::to_string(&param_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<CreateContainerAutoBatchResponse, ApiError> {
- match response.status.to_u16() {
- 201 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::Editgroup>(&buf)?;
-
- Ok(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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn delete_container(&self, param_editgroup_id: String, param_ident: String, context: &Context) -> Box<dyn Future<Item = DeleteContainerResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/editgroup/{editgroup_id}/container/{ident}",
- self.base_path,
- editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET),
- ident = utf8_percent_encode(&param_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<DeleteContainerResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::EntityEdit>(&buf)?;
-
- Ok(DeleteContainerResponse::DeletedEntity(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(DeleteContainerResponse::BadRequest(body))
- }
- 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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
-
- Ok(DeleteContainerResponse::NotFound(body))
- }
- 500 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(DeleteContainerResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn delete_container_edit(&self, param_editgroup_id: String, param_edit_id: String, context: &Context) -> Box<dyn Future<Item = DeleteContainerEditResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/editgroup/{editgroup_id}/container/edit/{edit_id}",
- self.base_path,
- editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET),
- edit_id = utf8_percent_encode(&param_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<DeleteContainerEditResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::Success>(&buf)?;
-
- Ok(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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_container(&self, param_ident: String, param_expand: Option<String>, param_hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetContainerResponse, Error = ApiError> + Send> {
- // Query parameters
- let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string()));
- let 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(&param_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<GetContainerResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ContainerEntity>(&buf)?;
-
- Ok(GetContainerResponse::FoundEntity(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetContainerResponse::BadRequest(body))
- }
- 404 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetContainerResponse::NotFound(body))
- }
- 500 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetContainerResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_container_edit(&self, param_edit_id: String, context: &Context) -> Box<dyn Future<Item = GetContainerEditResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/container/edit/{edit_id}",
- self.base_path,
- edit_id = utf8_percent_encode(&param_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<GetContainerEditResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::EntityEdit>(&buf)?;
-
- Ok(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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_container_history(&self, param_ident: String, param_limit: Option<i64>, context: &Context) -> Box<dyn Future<Item = GetContainerHistoryResponse, Error = ApiError> + Send> {
- // Query parameters
- let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string()));
-
- let url = format!(
- "{}/v0/container/{ident}/history?{limit}",
- self.base_path,
- ident = utf8_percent_encode(&param_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<GetContainerHistoryResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<Vec<models::EntityHistoryEntry>>(&buf)?;
-
- Ok(GetContainerHistoryResponse::FoundEntityHistory(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetContainerHistoryResponse::BadRequest(body))
- }
- 404 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetContainerHistoryResponse::NotFound(body))
- }
- 500 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetContainerHistoryResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_container_redirects(&self, param_ident: String, context: &Context) -> Box<dyn Future<Item = GetContainerRedirectsResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/container/{ident}/redirects",
- self.base_path,
- ident = utf8_percent_encode(&param_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<GetContainerRedirectsResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<Vec<String>>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_container_revision(
- &self,
- param_rev_id: String,
- param_expand: Option<String>,
- param_hide: Option<String>,
- context: &Context,
- ) -> Box<dyn Future<Item = GetContainerRevisionResponse, Error = ApiError> + 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(&param_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<GetContainerRevisionResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ContainerEntity>(&buf)?;
-
- Ok(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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn lookup_container(
- &self,
- param_issnl: Option<String>,
- param_wikidata_qid: Option<String>,
- param_expand: Option<String>,
- param_hide: Option<String>,
- context: &Context,
- ) -> Box<dyn Future<Item = LookupContainerResponse, Error = ApiError> + 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<LookupContainerResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ContainerEntity>(&buf)?;
-
- Ok(LookupContainerResponse::FoundEntity(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(LookupContainerResponse::BadRequest(body))
- }
- 404 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(LookupContainerResponse::NotFound(body))
- }
- 500 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(LookupContainerResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn update_container(
- &self,
- param_editgroup_id: String,
- param_ident: String,
- param_entity: models::ContainerEntity,
- context: &Context,
- ) -> Box<dyn Future<Item = UpdateContainerResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/editgroup/{editgroup_id}/container/{ident}",
- self.base_path,
- editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET),
- ident = utf8_percent_encode(&param_ident.to_string(), PATH_SEGMENT_ENCODE_SET)
- );
-
- let body = serde_json::to_string(&param_entity).expect("impossible to fail to serialize");
-
- let hyper_client = (self.hyper_client)();
- let request = hyper_client.request(hyper::method::Method::Put, &url);
- let mut custom_headers = hyper::header::Headers::new();
-
- let request = request.body(&body);
-
- custom_headers.set(ContentType(mimetypes::requests::UPDATE_CONTAINER.clone()));
- context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
-
- let request = request.headers(custom_headers);
-
- // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<UpdateContainerResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::EntityEdit>(&buf)?;
-
- Ok(UpdateContainerResponse::UpdatedEntity(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(UpdateContainerResponse::BadRequest(body))
- }
- 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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
-
- Ok(UpdateContainerResponse::NotFound(body))
- }
- 500 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(UpdateContainerResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn create_creator(&self, param_editgroup_id: String, param_entity: models::CreatorEntity, context: &Context) -> Box<dyn Future<Item = CreateCreatorResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/editgroup/{editgroup_id}/creator",
- self.base_path,
- editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET)
- );
-
- let body = serde_json::to_string(&param_entity).expect("impossible to fail to serialize");
-
- let hyper_client = (self.hyper_client)();
- let request = hyper_client.request(hyper::method::Method::Post, &url);
- let mut custom_headers = hyper::header::Headers::new();
-
- let request = request.body(&body);
-
- custom_headers.set(ContentType(mimetypes::requests::CREATE_CREATOR.clone()));
- context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
-
- let request = request.headers(custom_headers);
-
- // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<CreateCreatorResponse, ApiError> {
- match response.status.to_u16() {
- 201 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::EntityEdit>(&buf)?;
-
- Ok(CreateCreatorResponse::CreatedEntity(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(CreateCreatorResponse::BadRequest(body))
- }
- 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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
-
- Ok(CreateCreatorResponse::NotFound(body))
- }
- 500 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(CreateCreatorResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn create_creator_auto_batch(&self, param_auto_batch: models::CreatorAutoBatch, context: &Context) -> Box<dyn Future<Item = CreateCreatorAutoBatchResponse, Error = ApiError> + Send> {
- let url = format!("{}/v0/editgroup/auto/creator/batch", self.base_path);
-
- let body = serde_json::to_string(&param_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<CreateCreatorAutoBatchResponse, ApiError> {
- match response.status.to_u16() {
- 201 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::Editgroup>(&buf)?;
-
- Ok(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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn delete_creator(&self, param_editgroup_id: String, param_ident: String, context: &Context) -> Box<dyn Future<Item = DeleteCreatorResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/editgroup/{editgroup_id}/creator/{ident}",
- self.base_path,
- editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET),
- ident = utf8_percent_encode(&param_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<DeleteCreatorResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::EntityEdit>(&buf)?;
-
- Ok(DeleteCreatorResponse::DeletedEntity(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(DeleteCreatorResponse::BadRequest(body))
- }
- 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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
-
- Ok(DeleteCreatorResponse::NotFound(body))
- }
- 500 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(DeleteCreatorResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn delete_creator_edit(&self, param_editgroup_id: String, param_edit_id: String, context: &Context) -> Box<dyn Future<Item = DeleteCreatorEditResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/editgroup/{editgroup_id}/creator/edit/{edit_id}",
- self.base_path,
- editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET),
- edit_id = utf8_percent_encode(&param_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<DeleteCreatorEditResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::Success>(&buf)?;
-
- Ok(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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_creator(&self, param_ident: String, param_expand: Option<String>, param_hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetCreatorResponse, Error = ApiError> + Send> {
- // Query parameters
- let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string()));
- let 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(&param_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<GetCreatorResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::CreatorEntity>(&buf)?;
-
- Ok(GetCreatorResponse::FoundEntity(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetCreatorResponse::BadRequest(body))
- }
- 404 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetCreatorResponse::NotFound(body))
- }
- 500 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetCreatorResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_creator_edit(&self, param_edit_id: String, context: &Context) -> Box<dyn Future<Item = GetCreatorEditResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/creator/edit/{edit_id}",
- self.base_path,
- edit_id = utf8_percent_encode(&param_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<GetCreatorEditResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::EntityEdit>(&buf)?;
-
- Ok(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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_creator_history(&self, param_ident: String, param_limit: Option<i64>, context: &Context) -> Box<dyn Future<Item = GetCreatorHistoryResponse, Error = ApiError> + Send> {
- // Query parameters
- let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string()));
-
- let url = format!(
- "{}/v0/creator/{ident}/history?{limit}",
- self.base_path,
- ident = utf8_percent_encode(&param_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<GetCreatorHistoryResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<Vec<models::EntityHistoryEntry>>(&buf)?;
-
- Ok(GetCreatorHistoryResponse::FoundEntityHistory(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetCreatorHistoryResponse::BadRequest(body))
- }
- 404 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetCreatorHistoryResponse::NotFound(body))
- }
- 500 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetCreatorHistoryResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_creator_redirects(&self, param_ident: String, context: &Context) -> Box<dyn Future<Item = GetCreatorRedirectsResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/creator/{ident}/redirects",
- self.base_path,
- ident = utf8_percent_encode(&param_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<GetCreatorRedirectsResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<Vec<String>>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_creator_releases(&self, param_ident: String, param_hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetCreatorReleasesResponse, Error = ApiError> + 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(&param_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<GetCreatorReleasesResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<Vec<models::ReleaseEntity>>(&buf)?;
-
- Ok(GetCreatorReleasesResponse::Found(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetCreatorReleasesResponse::BadRequest(body))
- }
- 404 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetCreatorReleasesResponse::NotFound(body))
- }
- 500 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetCreatorReleasesResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_creator_revision(
- &self,
- param_rev_id: String,
- param_expand: Option<String>,
- param_hide: Option<String>,
- context: &Context,
- ) -> Box<dyn Future<Item = GetCreatorRevisionResponse, Error = ApiError> + 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(&param_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<GetCreatorRevisionResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::CreatorEntity>(&buf)?;
-
- Ok(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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn lookup_creator(
- &self,
- param_orcid: Option<String>,
- param_wikidata_qid: Option<String>,
- param_expand: Option<String>,
- param_hide: Option<String>,
- context: &Context,
- ) -> Box<dyn Future<Item = LookupCreatorResponse, Error = ApiError> + 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<LookupCreatorResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::CreatorEntity>(&buf)?;
-
- Ok(LookupCreatorResponse::FoundEntity(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(LookupCreatorResponse::BadRequest(body))
- }
- 404 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(LookupCreatorResponse::NotFound(body))
- }
- 500 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(LookupCreatorResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn update_creator(
- &self,
- param_editgroup_id: String,
- param_ident: String,
- param_entity: models::CreatorEntity,
- context: &Context,
- ) -> Box<dyn Future<Item = UpdateCreatorResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/editgroup/{editgroup_id}/creator/{ident}",
- self.base_path,
- editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET),
- ident = utf8_percent_encode(&param_ident.to_string(), PATH_SEGMENT_ENCODE_SET)
- );
-
- let body = serde_json::to_string(&param_entity).expect("impossible to fail to serialize");
-
- let hyper_client = (self.hyper_client)();
- let request = hyper_client.request(hyper::method::Method::Put, &url);
- let mut custom_headers = hyper::header::Headers::new();
-
- let request = request.body(&body);
-
- custom_headers.set(ContentType(mimetypes::requests::UPDATE_CREATOR.clone()));
- context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
-
- let request = request.headers(custom_headers);
-
- // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<UpdateCreatorResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::EntityEdit>(&buf)?;
-
- Ok(UpdateCreatorResponse::UpdatedEntity(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(UpdateCreatorResponse::BadRequest(body))
- }
- 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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
-
- Ok(UpdateCreatorResponse::NotFound(body))
- }
- 500 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(UpdateCreatorResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn accept_editgroup(&self, param_editgroup_id: String, context: &Context) -> Box<dyn Future<Item = AcceptEditgroupResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/editgroup/{editgroup_id}/accept",
- self.base_path,
- editgroup_id = utf8_percent_encode(&param_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<AcceptEditgroupResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::Success>(&buf)?;
-
- Ok(AcceptEditgroupResponse::MergedSuccessfully(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(AcceptEditgroupResponse::BadRequest(body))
- }
- 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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
-
- Ok(AcceptEditgroupResponse::NotFound(body))
- }
- 409 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(AcceptEditgroupResponse::EditConflict(body))
- }
- 500 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(AcceptEditgroupResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn create_editgroup(&self, param_editgroup: models::Editgroup, context: &Context) -> Box<dyn Future<Item = CreateEditgroupResponse, Error = ApiError> + Send> {
- let url = format!("{}/v0/editgroup", self.base_path);
-
- let body = serde_json::to_string(&param_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<CreateEditgroupResponse, ApiError> {
- match response.status.to_u16() {
- 201 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::Editgroup>(&buf)?;
-
- Ok(CreateEditgroupResponse::SuccessfullyCreated(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(CreateEditgroupResponse::BadRequest(body))
- }
- 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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
-
- Ok(CreateEditgroupResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn create_editgroup_annotation(
- &self,
- param_editgroup_id: String,
- param_annotation: models::EditgroupAnnotation,
- context: &Context,
- ) -> Box<dyn Future<Item = CreateEditgroupAnnotationResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/editgroup/{editgroup_id}/annotation",
- self.base_path,
- editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET)
- );
-
- let body = serde_json::to_string(&param_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<CreateEditgroupAnnotationResponse, ApiError> {
- match response.status.to_u16() {
- 201 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::EditgroupAnnotation>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_editgroup(&self, param_editgroup_id: String, context: &Context) -> Box<dyn Future<Item = GetEditgroupResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/editgroup/{editgroup_id}",
- self.base_path,
- editgroup_id = utf8_percent_encode(&param_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<GetEditgroupResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::Editgroup>(&buf)?;
-
- Ok(GetEditgroupResponse::Found(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetEditgroupResponse::BadRequest(body))
- }
- 404 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetEditgroupResponse::NotFound(body))
- }
- 500 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetEditgroupResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_editgroup_annotations(
- &self,
- param_editgroup_id: String,
- param_expand: Option<String>,
- context: &Context,
- ) -> Box<dyn Future<Item = GetEditgroupAnnotationsResponse, Error = ApiError> + Send> {
- // Query parameters
- let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string()));
-
- let url = format!(
- "{}/v0/editgroup/{editgroup_id}/annotations?{expand}",
- self.base_path,
- editgroup_id = utf8_percent_encode(&param_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<GetEditgroupAnnotationsResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<Vec<models::EditgroupAnnotation>>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_editgroups_reviewable(
- &self,
- param_expand: Option<String>,
- param_limit: Option<i64>,
- param_before: Option<chrono::DateTime<chrono::Utc>>,
- param_since: Option<chrono::DateTime<chrono::Utc>>,
- context: &Context,
- ) -> Box<dyn Future<Item = GetEditgroupsReviewableResponse, Error = ApiError> + 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<GetEditgroupsReviewableResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<Vec<models::Editgroup>>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn update_editgroup(
- &self,
- param_editgroup_id: String,
- param_editgroup: models::Editgroup,
- param_submit: Option<bool>,
- context: &Context,
- ) -> Box<dyn Future<Item = UpdateEditgroupResponse, Error = ApiError> + 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(&param_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET),
- submit = utf8_percent_encode(&query_submit, QUERY_ENCODE_SET)
- );
-
- let body = serde_json::to_string(&param_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<UpdateEditgroupResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::Editgroup>(&buf)?;
-
- Ok(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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_editor(&self, param_editor_id: String, context: &Context) -> Box<dyn Future<Item = GetEditorResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/editor/{editor_id}",
- self.base_path,
- editor_id = utf8_percent_encode(&param_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<GetEditorResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::Editor>(&buf)?;
-
- Ok(GetEditorResponse::Found(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetEditorResponse::BadRequest(body))
- }
- 404 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetEditorResponse::NotFound(body))
- }
- 500 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetEditorResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_editor_annotations(
- &self,
- param_editor_id: String,
- param_limit: Option<i64>,
- param_before: Option<chrono::DateTime<chrono::Utc>>,
- param_since: Option<chrono::DateTime<chrono::Utc>>,
- context: &Context,
- ) -> Box<dyn Future<Item = GetEditorAnnotationsResponse, Error = ApiError> + 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(&param_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<GetEditorAnnotationsResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<Vec<models::EditgroupAnnotation>>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_editor_editgroups(
- &self,
- param_editor_id: String,
- param_limit: Option<i64>,
- param_before: Option<chrono::DateTime<chrono::Utc>>,
- param_since: Option<chrono::DateTime<chrono::Utc>>,
- context: &Context,
- ) -> Box<dyn Future<Item = GetEditorEditgroupsResponse, Error = ApiError> + 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(&param_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<GetEditorEditgroupsResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<Vec<models::Editgroup>>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn update_editor(&self, param_editor_id: String, param_editor: models::Editor, context: &Context) -> Box<dyn Future<Item = UpdateEditorResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/editor/{editor_id}",
- self.base_path,
- editor_id = utf8_percent_encode(&param_editor_id.to_string(), PATH_SEGMENT_ENCODE_SET)
- );
-
- let body = serde_json::to_string(&param_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<UpdateEditorResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::Editor>(&buf)?;
-
- Ok(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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn create_file(&self, param_editgroup_id: String, param_entity: models::FileEntity, context: &Context) -> Box<dyn Future<Item = CreateFileResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/editgroup/{editgroup_id}/file",
- self.base_path,
- editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET)
- );
-
- let body = serde_json::to_string(&param_entity).expect("impossible to fail to serialize");
-
- let hyper_client = (self.hyper_client)();
- let request = hyper_client.request(hyper::method::Method::Post, &url);
- let mut custom_headers = hyper::header::Headers::new();
-
- let request = request.body(&body);
-
- custom_headers.set(ContentType(mimetypes::requests::CREATE_FILE.clone()));
- context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
-
- let request = request.headers(custom_headers);
-
- // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<CreateFileResponse, ApiError> {
- match response.status.to_u16() {
- 201 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::EntityEdit>(&buf)?;
-
- Ok(CreateFileResponse::CreatedEntity(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(CreateFileResponse::BadRequest(body))
- }
- 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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
-
- Ok(CreateFileResponse::NotFound(body))
- }
- 500 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(CreateFileResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn create_file_auto_batch(&self, param_auto_batch: models::FileAutoBatch, context: &Context) -> Box<dyn Future<Item = CreateFileAutoBatchResponse, Error = ApiError> + Send> {
- let url = format!("{}/v0/editgroup/auto/file/batch", self.base_path);
-
- let body = serde_json::to_string(&param_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<CreateFileAutoBatchResponse, ApiError> {
- match response.status.to_u16() {
- 201 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::Editgroup>(&buf)?;
-
- Ok(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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn delete_file(&self, param_editgroup_id: String, param_ident: String, context: &Context) -> Box<dyn Future<Item = DeleteFileResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/editgroup/{editgroup_id}/file/{ident}",
- self.base_path,
- editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET),
- ident = utf8_percent_encode(&param_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<DeleteFileResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::EntityEdit>(&buf)?;
-
- Ok(DeleteFileResponse::DeletedEntity(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(DeleteFileResponse::BadRequest(body))
- }
- 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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
-
- Ok(DeleteFileResponse::NotFound(body))
- }
- 500 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(DeleteFileResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn delete_file_edit(&self, param_editgroup_id: String, param_edit_id: String, context: &Context) -> Box<dyn Future<Item = DeleteFileEditResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/editgroup/{editgroup_id}/file/edit/{edit_id}",
- self.base_path,
- editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET),
- edit_id = utf8_percent_encode(&param_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<DeleteFileEditResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::Success>(&buf)?;
-
- Ok(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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_file(&self, param_ident: String, param_expand: Option<String>, param_hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetFileResponse, Error = ApiError> + Send> {
- // Query parameters
- let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string()));
- let 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(&param_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<GetFileResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::FileEntity>(&buf)?;
-
- Ok(GetFileResponse::FoundEntity(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetFileResponse::BadRequest(body))
- }
- 404 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetFileResponse::NotFound(body))
- }
- 500 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetFileResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_file_edit(&self, param_edit_id: String, context: &Context) -> Box<dyn Future<Item = GetFileEditResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/file/edit/{edit_id}",
- self.base_path,
- edit_id = utf8_percent_encode(&param_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<GetFileEditResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::EntityEdit>(&buf)?;
-
- Ok(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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_file_history(&self, param_ident: String, param_limit: Option<i64>, context: &Context) -> Box<dyn Future<Item = GetFileHistoryResponse, Error = ApiError> + Send> {
- // Query parameters
- let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string()));
-
- let url = format!(
- "{}/v0/file/{ident}/history?{limit}",
- self.base_path,
- ident = utf8_percent_encode(&param_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<GetFileHistoryResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<Vec<models::EntityHistoryEntry>>(&buf)?;
-
- Ok(GetFileHistoryResponse::FoundEntityHistory(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetFileHistoryResponse::BadRequest(body))
- }
- 404 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetFileHistoryResponse::NotFound(body))
- }
- 500 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetFileHistoryResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_file_redirects(&self, param_ident: String, context: &Context) -> Box<dyn Future<Item = GetFileRedirectsResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/file/{ident}/redirects",
- self.base_path,
- ident = utf8_percent_encode(&param_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<GetFileRedirectsResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<Vec<String>>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_file_revision(
- &self,
- param_rev_id: String,
- param_expand: Option<String>,
- param_hide: Option<String>,
- context: &Context,
- ) -> Box<dyn Future<Item = GetFileRevisionResponse, Error = ApiError> + 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(&param_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<GetFileRevisionResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::FileEntity>(&buf)?;
-
- Ok(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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn lookup_file(
- &self,
- param_md5: Option<String>,
- param_sha1: Option<String>,
- param_sha256: Option<String>,
- param_expand: Option<String>,
- param_hide: Option<String>,
- context: &Context,
- ) -> Box<dyn Future<Item = LookupFileResponse, Error = ApiError> + 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<LookupFileResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::FileEntity>(&buf)?;
-
- Ok(LookupFileResponse::FoundEntity(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(LookupFileResponse::BadRequest(body))
- }
- 404 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(LookupFileResponse::NotFound(body))
- }
- 500 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(LookupFileResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn update_file(&self, param_editgroup_id: String, param_ident: String, param_entity: models::FileEntity, context: &Context) -> Box<dyn Future<Item = UpdateFileResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/editgroup/{editgroup_id}/file/{ident}",
- self.base_path,
- editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET),
- ident = utf8_percent_encode(&param_ident.to_string(), PATH_SEGMENT_ENCODE_SET)
- );
-
- let body = serde_json::to_string(&param_entity).expect("impossible to fail to serialize");
-
- let hyper_client = (self.hyper_client)();
- let request = hyper_client.request(hyper::method::Method::Put, &url);
- let mut custom_headers = hyper::header::Headers::new();
-
- let request = request.body(&body);
-
- custom_headers.set(ContentType(mimetypes::requests::UPDATE_FILE.clone()));
- context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
-
- let request = request.headers(custom_headers);
-
- // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<UpdateFileResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::EntityEdit>(&buf)?;
-
- Ok(UpdateFileResponse::UpdatedEntity(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(UpdateFileResponse::BadRequest(body))
- }
- 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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
-
- Ok(UpdateFileResponse::NotFound(body))
- }
- 500 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(UpdateFileResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn create_fileset(&self, param_editgroup_id: String, param_entity: models::FilesetEntity, context: &Context) -> Box<dyn Future<Item = CreateFilesetResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/editgroup/{editgroup_id}/fileset",
- self.base_path,
- editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET)
- );
-
- let body = serde_json::to_string(&param_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<CreateFilesetResponse, ApiError> {
- match response.status.to_u16() {
- 201 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::EntityEdit>(&buf)?;
-
- Ok(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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn create_fileset_auto_batch(&self, param_auto_batch: models::FilesetAutoBatch, context: &Context) -> Box<dyn Future<Item = CreateFilesetAutoBatchResponse, Error = ApiError> + Send> {
- let url = format!("{}/v0/editgroup/auto/fileset/batch", self.base_path);
-
- let body = serde_json::to_string(&param_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<CreateFilesetAutoBatchResponse, ApiError> {
- match response.status.to_u16() {
- 201 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::Editgroup>(&buf)?;
-
- Ok(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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn delete_fileset(&self, param_editgroup_id: String, param_ident: String, context: &Context) -> Box<dyn Future<Item = DeleteFilesetResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/editgroup/{editgroup_id}/fileset/{ident}",
- self.base_path,
- editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET),
- ident = utf8_percent_encode(&param_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<DeleteFilesetResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::EntityEdit>(&buf)?;
-
- Ok(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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn delete_fileset_edit(&self, param_editgroup_id: String, param_edit_id: String, context: &Context) -> Box<dyn Future<Item = DeleteFilesetEditResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/editgroup/{editgroup_id}/fileset/edit/{edit_id}",
- self.base_path,
- editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET),
- edit_id = utf8_percent_encode(&param_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<DeleteFilesetEditResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::Success>(&buf)?;
-
- Ok(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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_fileset(&self, param_ident: String, param_expand: Option<String>, param_hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetFilesetResponse, Error = ApiError> + 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(&param_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<GetFilesetResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::FilesetEntity>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_fileset_edit(&self, param_edit_id: String, context: &Context) -> Box<dyn Future<Item = GetFilesetEditResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/fileset/edit/{edit_id}",
- self.base_path,
- edit_id = utf8_percent_encode(&param_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<GetFilesetEditResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::EntityEdit>(&buf)?;
-
- Ok(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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_fileset_history(&self, param_ident: String, param_limit: Option<i64>, context: &Context) -> Box<dyn Future<Item = GetFilesetHistoryResponse, Error = ApiError> + Send> {
- // Query parameters
- let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string()));
-
- let url = format!(
- "{}/v0/fileset/{ident}/history?{limit}",
- self.base_path,
- ident = utf8_percent_encode(&param_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<GetFilesetHistoryResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<Vec<models::EntityHistoryEntry>>(&buf)?;
-
- Ok(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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_fileset_redirects(&self, param_ident: String, context: &Context) -> Box<dyn Future<Item = GetFilesetRedirectsResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/fileset/{ident}/redirects",
- self.base_path,
- ident = utf8_percent_encode(&param_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<GetFilesetRedirectsResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<Vec<String>>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_fileset_revision(
- &self,
- param_rev_id: String,
- param_expand: Option<String>,
- param_hide: Option<String>,
- context: &Context,
- ) -> Box<dyn Future<Item = GetFilesetRevisionResponse, Error = ApiError> + 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(&param_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<GetFilesetRevisionResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::FilesetEntity>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn update_fileset(
- &self,
- param_editgroup_id: String,
- param_ident: String,
- param_entity: models::FilesetEntity,
- context: &Context,
- ) -> Box<dyn Future<Item = UpdateFilesetResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/editgroup/{editgroup_id}/fileset/{ident}",
- self.base_path,
- editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET),
- ident = utf8_percent_encode(&param_ident.to_string(), PATH_SEGMENT_ENCODE_SET)
- );
-
- let body = serde_json::to_string(&param_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<UpdateFilesetResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::EntityEdit>(&buf)?;
-
- Ok(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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn create_release(&self, param_editgroup_id: String, param_entity: models::ReleaseEntity, context: &Context) -> Box<dyn Future<Item = CreateReleaseResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/editgroup/{editgroup_id}/release",
- self.base_path,
- editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET)
- );
-
- let body = serde_json::to_string(&param_entity).expect("impossible to fail to serialize");
-
- let hyper_client = (self.hyper_client)();
- let request = hyper_client.request(hyper::method::Method::Post, &url);
- let mut custom_headers = hyper::header::Headers::new();
-
- let request = request.body(&body);
-
- custom_headers.set(ContentType(mimetypes::requests::CREATE_RELEASE.clone()));
- context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
-
- let request = request.headers(custom_headers);
-
- // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<CreateReleaseResponse, ApiError> {
- match response.status.to_u16() {
- 201 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::EntityEdit>(&buf)?;
-
- Ok(CreateReleaseResponse::CreatedEntity(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(CreateReleaseResponse::BadRequest(body))
- }
- 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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
-
- Ok(CreateReleaseResponse::NotFound(body))
- }
- 500 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(CreateReleaseResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn create_release_auto_batch(&self, param_auto_batch: models::ReleaseAutoBatch, context: &Context) -> Box<dyn Future<Item = CreateReleaseAutoBatchResponse, Error = ApiError> + Send> {
- let url = format!("{}/v0/editgroup/auto/release/batch", self.base_path);
-
- let body = serde_json::to_string(&param_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<CreateReleaseAutoBatchResponse, ApiError> {
- match response.status.to_u16() {
- 201 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::Editgroup>(&buf)?;
-
- Ok(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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn delete_release(&self, param_editgroup_id: String, param_ident: String, context: &Context) -> Box<dyn Future<Item = DeleteReleaseResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/editgroup/{editgroup_id}/release/{ident}",
- self.base_path,
- editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET),
- ident = utf8_percent_encode(&param_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<DeleteReleaseResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::EntityEdit>(&buf)?;
-
- Ok(DeleteReleaseResponse::DeletedEntity(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(DeleteReleaseResponse::BadRequest(body))
- }
- 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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
-
- Ok(DeleteReleaseResponse::NotFound(body))
- }
- 500 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(DeleteReleaseResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn delete_release_edit(&self, param_editgroup_id: String, param_edit_id: String, context: &Context) -> Box<dyn Future<Item = DeleteReleaseEditResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/editgroup/{editgroup_id}/release/edit/{edit_id}",
- self.base_path,
- editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET),
- edit_id = utf8_percent_encode(&param_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<DeleteReleaseEditResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::Success>(&buf)?;
-
- Ok(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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_release(&self, param_ident: String, param_expand: Option<String>, param_hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetReleaseResponse, Error = ApiError> + Send> {
- // Query parameters
- let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string()));
- let 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(&param_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<GetReleaseResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ReleaseEntity>(&buf)?;
-
- Ok(GetReleaseResponse::FoundEntity(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetReleaseResponse::BadRequest(body))
- }
- 404 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetReleaseResponse::NotFound(body))
- }
- 500 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetReleaseResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_release_edit(&self, param_edit_id: String, context: &Context) -> Box<dyn Future<Item = GetReleaseEditResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/release/edit/{edit_id}",
- self.base_path,
- edit_id = utf8_percent_encode(&param_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<GetReleaseEditResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::EntityEdit>(&buf)?;
-
- Ok(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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_release_files(&self, param_ident: String, param_hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetReleaseFilesResponse, Error = ApiError> + 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(&param_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<GetReleaseFilesResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<Vec<models::FileEntity>>(&buf)?;
-
- Ok(GetReleaseFilesResponse::Found(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetReleaseFilesResponse::BadRequest(body))
- }
- 404 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetReleaseFilesResponse::NotFound(body))
- }
- 500 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetReleaseFilesResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_release_filesets(&self, param_ident: String, param_hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetReleaseFilesetsResponse, Error = ApiError> + 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(&param_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<GetReleaseFilesetsResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<Vec<models::FilesetEntity>>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_release_history(&self, param_ident: String, param_limit: Option<i64>, context: &Context) -> Box<dyn Future<Item = GetReleaseHistoryResponse, Error = ApiError> + Send> {
- // Query parameters
- let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string()));
-
- let url = format!(
- "{}/v0/release/{ident}/history?{limit}",
- self.base_path,
- ident = utf8_percent_encode(&param_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<GetReleaseHistoryResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<Vec<models::EntityHistoryEntry>>(&buf)?;
-
- Ok(GetReleaseHistoryResponse::FoundEntityHistory(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetReleaseHistoryResponse::BadRequest(body))
- }
- 404 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetReleaseHistoryResponse::NotFound(body))
- }
- 500 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetReleaseHistoryResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_release_redirects(&self, param_ident: String, context: &Context) -> Box<dyn Future<Item = GetReleaseRedirectsResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/release/{ident}/redirects",
- self.base_path,
- ident = utf8_percent_encode(&param_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<GetReleaseRedirectsResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<Vec<String>>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_release_revision(
- &self,
- param_rev_id: String,
- param_expand: Option<String>,
- param_hide: Option<String>,
- context: &Context,
- ) -> Box<dyn Future<Item = GetReleaseRevisionResponse, Error = ApiError> + 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(&param_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<GetReleaseRevisionResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ReleaseEntity>(&buf)?;
-
- Ok(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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_release_webcaptures(&self, param_ident: String, param_hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetReleaseWebcapturesResponse, Error = ApiError> + 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(&param_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<GetReleaseWebcapturesResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<Vec<models::WebcaptureEntity>>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn lookup_release(
- &self,
- param_doi: Option<String>,
- param_wikidata_qid: Option<String>,
- param_isbn13: Option<String>,
- param_pmid: Option<String>,
- param_pmcid: Option<String>,
- param_core: Option<String>,
- param_arxiv: Option<String>,
- param_jstor: Option<String>,
- param_ark: Option<String>,
- param_mag: Option<String>,
- param_expand: Option<String>,
- param_hide: Option<String>,
- context: &Context,
- ) -> Box<dyn Future<Item = LookupReleaseResponse, Error = ApiError> + 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<LookupReleaseResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ReleaseEntity>(&buf)?;
-
- Ok(LookupReleaseResponse::FoundEntity(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(LookupReleaseResponse::BadRequest(body))
- }
- 404 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(LookupReleaseResponse::NotFound(body))
- }
- 500 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(LookupReleaseResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn update_release(
- &self,
- param_editgroup_id: String,
- param_ident: String,
- param_entity: models::ReleaseEntity,
- context: &Context,
- ) -> Box<dyn Future<Item = UpdateReleaseResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/editgroup/{editgroup_id}/release/{ident}",
- self.base_path,
- editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET),
- ident = utf8_percent_encode(&param_ident.to_string(), PATH_SEGMENT_ENCODE_SET)
- );
-
- let body = serde_json::to_string(&param_entity).expect("impossible to fail to serialize");
-
- let hyper_client = (self.hyper_client)();
- let request = hyper_client.request(hyper::method::Method::Put, &url);
- let mut custom_headers = hyper::header::Headers::new();
-
- let request = request.body(&body);
-
- custom_headers.set(ContentType(mimetypes::requests::UPDATE_RELEASE.clone()));
- context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
-
- let request = request.headers(custom_headers);
-
- // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<UpdateReleaseResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::EntityEdit>(&buf)?;
-
- Ok(UpdateReleaseResponse::UpdatedEntity(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(UpdateReleaseResponse::BadRequest(body))
- }
- 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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
-
- Ok(UpdateReleaseResponse::NotFound(body))
- }
- 500 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(UpdateReleaseResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn create_webcapture(&self, param_editgroup_id: String, param_entity: models::WebcaptureEntity, context: &Context) -> Box<dyn Future<Item = CreateWebcaptureResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/editgroup/{editgroup_id}/webcapture",
- self.base_path,
- editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET)
- );
-
- let body = serde_json::to_string(&param_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<CreateWebcaptureResponse, ApiError> {
- match response.status.to_u16() {
- 201 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::EntityEdit>(&buf)?;
-
- Ok(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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn create_webcapture_auto_batch(&self, param_auto_batch: models::WebcaptureAutoBatch, context: &Context) -> Box<dyn Future<Item = CreateWebcaptureAutoBatchResponse, Error = ApiError> + Send> {
- let url = format!("{}/v0/editgroup/auto/webcapture/batch", self.base_path);
-
- let body = serde_json::to_string(&param_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<CreateWebcaptureAutoBatchResponse, ApiError> {
- match response.status.to_u16() {
- 201 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::Editgroup>(&buf)?;
-
- Ok(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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn delete_webcapture(&self, param_editgroup_id: String, param_ident: String, context: &Context) -> Box<dyn Future<Item = DeleteWebcaptureResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/editgroup/{editgroup_id}/webcapture/{ident}",
- self.base_path,
- editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET),
- ident = utf8_percent_encode(&param_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<DeleteWebcaptureResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::EntityEdit>(&buf)?;
-
- Ok(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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn delete_webcapture_edit(&self, param_editgroup_id: String, param_edit_id: String, context: &Context) -> Box<dyn Future<Item = DeleteWebcaptureEditResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/editgroup/{editgroup_id}/webcapture/edit/{edit_id}",
- self.base_path,
- editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET),
- edit_id = utf8_percent_encode(&param_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<DeleteWebcaptureEditResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::Success>(&buf)?;
-
- Ok(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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_webcapture(
- &self,
- param_ident: String,
- param_expand: Option<String>,
- param_hide: Option<String>,
- context: &Context,
- ) -> Box<dyn Future<Item = GetWebcaptureResponse, Error = ApiError> + 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(&param_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<GetWebcaptureResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::WebcaptureEntity>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_webcapture_edit(&self, param_edit_id: String, context: &Context) -> Box<dyn Future<Item = GetWebcaptureEditResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/webcapture/edit/{edit_id}",
- self.base_path,
- edit_id = utf8_percent_encode(&param_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<GetWebcaptureEditResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::EntityEdit>(&buf)?;
-
- Ok(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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_webcapture_history(&self, param_ident: String, param_limit: Option<i64>, context: &Context) -> Box<dyn Future<Item = GetWebcaptureHistoryResponse, Error = ApiError> + Send> {
- // Query parameters
- let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string()));
-
- let url = format!(
- "{}/v0/webcapture/{ident}/history?{limit}",
- self.base_path,
- ident = utf8_percent_encode(&param_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<GetWebcaptureHistoryResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<Vec<models::EntityHistoryEntry>>(&buf)?;
-
- Ok(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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_webcapture_redirects(&self, param_ident: String, context: &Context) -> Box<dyn Future<Item = GetWebcaptureRedirectsResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/webcapture/{ident}/redirects",
- self.base_path,
- ident = utf8_percent_encode(&param_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<GetWebcaptureRedirectsResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<Vec<String>>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_webcapture_revision(
- &self,
- param_rev_id: String,
- param_expand: Option<String>,
- param_hide: Option<String>,
- context: &Context,
- ) -> Box<dyn Future<Item = GetWebcaptureRevisionResponse, Error = ApiError> + 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(&param_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<GetWebcaptureRevisionResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::WebcaptureEntity>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn update_webcapture(
- &self,
- param_editgroup_id: String,
- param_ident: String,
- param_entity: models::WebcaptureEntity,
- context: &Context,
- ) -> Box<dyn Future<Item = UpdateWebcaptureResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/editgroup/{editgroup_id}/webcapture/{ident}",
- self.base_path,
- editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET),
- ident = utf8_percent_encode(&param_ident.to_string(), PATH_SEGMENT_ENCODE_SET)
- );
-
- let body = serde_json::to_string(&param_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<UpdateWebcaptureResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::EntityEdit>(&buf)?;
-
- Ok(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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn create_work(&self, param_editgroup_id: String, param_entity: models::WorkEntity, context: &Context) -> Box<dyn Future<Item = CreateWorkResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/editgroup/{editgroup_id}/work",
- self.base_path,
- editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET)
- );
-
- let body = serde_json::to_string(&param_entity).expect("impossible to fail to serialize");
-
- let hyper_client = (self.hyper_client)();
- let request = hyper_client.request(hyper::method::Method::Post, &url);
- let mut custom_headers = hyper::header::Headers::new();
-
- let request = request.body(&body);
-
- custom_headers.set(ContentType(mimetypes::requests::CREATE_WORK.clone()));
- context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
-
- let request = request.headers(custom_headers);
-
- // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<CreateWorkResponse, ApiError> {
- match response.status.to_u16() {
- 201 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::EntityEdit>(&buf)?;
-
- Ok(CreateWorkResponse::CreatedEntity(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(CreateWorkResponse::BadRequest(body))
- }
- 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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
-
- Ok(CreateWorkResponse::NotFound(body))
- }
- 500 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(CreateWorkResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn create_work_auto_batch(&self, param_auto_batch: models::WorkAutoBatch, context: &Context) -> Box<dyn Future<Item = CreateWorkAutoBatchResponse, Error = ApiError> + Send> {
- let url = format!("{}/v0/editgroup/auto/work/batch", self.base_path);
-
- let body = serde_json::to_string(&param_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<CreateWorkAutoBatchResponse, ApiError> {
- match response.status.to_u16() {
- 201 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::Editgroup>(&buf)?;
-
- Ok(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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn delete_work(&self, param_editgroup_id: String, param_ident: String, context: &Context) -> Box<dyn Future<Item = DeleteWorkResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/editgroup/{editgroup_id}/work/{ident}",
- self.base_path,
- editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET),
- ident = utf8_percent_encode(&param_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<DeleteWorkResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::EntityEdit>(&buf)?;
-
- Ok(DeleteWorkResponse::DeletedEntity(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(DeleteWorkResponse::BadRequest(body))
- }
- 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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
-
- Ok(DeleteWorkResponse::NotFound(body))
- }
- 500 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(DeleteWorkResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn delete_work_edit(&self, param_editgroup_id: String, param_edit_id: String, context: &Context) -> Box<dyn Future<Item = DeleteWorkEditResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/editgroup/{editgroup_id}/work/edit/{edit_id}",
- self.base_path,
- editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET),
- edit_id = utf8_percent_encode(&param_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<DeleteWorkEditResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::Success>(&buf)?;
-
- Ok(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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_work(&self, param_ident: String, param_expand: Option<String>, param_hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetWorkResponse, Error = ApiError> + Send> {
- // Query parameters
- let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string()));
- let 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(&param_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<GetWorkResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::WorkEntity>(&buf)?;
-
- Ok(GetWorkResponse::FoundEntity(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetWorkResponse::BadRequest(body))
- }
- 404 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetWorkResponse::NotFound(body))
- }
- 500 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetWorkResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_work_edit(&self, param_edit_id: String, context: &Context) -> Box<dyn Future<Item = GetWorkEditResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/work/edit/{edit_id}",
- self.base_path,
- edit_id = utf8_percent_encode(&param_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<GetWorkEditResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::EntityEdit>(&buf)?;
-
- Ok(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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_work_history(&self, param_ident: String, param_limit: Option<i64>, context: &Context) -> Box<dyn Future<Item = GetWorkHistoryResponse, Error = ApiError> + Send> {
- // Query parameters
- let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string()));
-
- let url = format!(
- "{}/v0/work/{ident}/history?{limit}",
- self.base_path,
- ident = utf8_percent_encode(&param_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<GetWorkHistoryResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<Vec<models::EntityHistoryEntry>>(&buf)?;
-
- Ok(GetWorkHistoryResponse::FoundEntityHistory(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetWorkHistoryResponse::BadRequest(body))
- }
- 404 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetWorkHistoryResponse::NotFound(body))
- }
- 500 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetWorkHistoryResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_work_redirects(&self, param_ident: String, context: &Context) -> Box<dyn Future<Item = GetWorkRedirectsResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/work/{ident}/redirects",
- self.base_path,
- ident = utf8_percent_encode(&param_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<GetWorkRedirectsResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<Vec<String>>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_work_releases(&self, param_ident: String, param_hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetWorkReleasesResponse, Error = ApiError> + 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(&param_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<GetWorkReleasesResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<Vec<models::ReleaseEntity>>(&buf)?;
-
- Ok(GetWorkReleasesResponse::Found(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetWorkReleasesResponse::BadRequest(body))
- }
- 404 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetWorkReleasesResponse::NotFound(body))
- }
- 500 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetWorkReleasesResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_work_revision(
- &self,
- param_rev_id: String,
- param_expand: Option<String>,
- param_hide: Option<String>,
- context: &Context,
- ) -> Box<dyn Future<Item = GetWorkRevisionResponse, Error = ApiError> + 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(&param_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<GetWorkRevisionResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::WorkEntity>(&buf)?;
-
- Ok(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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&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!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn update_work(&self, param_editgroup_id: String, param_ident: String, param_entity: models::WorkEntity, context: &Context) -> Box<dyn Future<Item = UpdateWorkResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/editgroup/{editgroup_id}/work/{ident}",
- self.base_path,
- editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET),
- ident = utf8_percent_encode(&param_ident.to_string(), PATH_SEGMENT_ENCODE_SET)
- );
-
- let body = serde_json::to_string(&param_entity).expect("impossible to fail to serialize");
-
- let hyper_client = (self.hyper_client)();
- let request = hyper_client.request(hyper::method::Method::Put, &url);
- let mut custom_headers = hyper::header::Headers::new();
-
- let request = request.body(&body);
-
- custom_headers.set(ContentType(mimetypes::requests::UPDATE_WORK.clone()));
- context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
-
- let request = request.headers(custom_headers);
-
- // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<UpdateWorkResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::EntityEdit>(&buf)?;
-
- Ok(UpdateWorkResponse::UpdatedEntity(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(UpdateWorkResponse::BadRequest(body))
- }
- 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::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .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::<models::ErrorResponse>(&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::<models::ErrorResponse>(&buf)?;
-
- Ok(UpdateWorkResponse::NotFound(body))
- }
- 500 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(UpdateWorkResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-}
-
-#[derive(Debug)]
-pub enum ClientInitError {
- InvalidScheme,
- InvalidUrl(hyper::error::ParseError),
- MissingHost,
- SslError(openssl::error::ErrorStack),
-}
-
-impl From<hyper::error::ParseError> for ClientInitError {
- fn from(err: hyper::error::ParseError) -> ClientInitError {
- ClientInitError::InvalidUrl(err)
- }
-}
-
-impl From<openssl::error::ErrorStack> for ClientInitError {
- fn from(err: openssl::error::ErrorStack) -> ClientInitError {
- ClientInitError::SslError(err)
- }
-}
-
-impl fmt::Display for ClientInitError {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- (self as &dyn fmt::Debug).fmt(f)
- }
-}
-
-impl error::Error for ClientInitError {
- fn description(&self) -> &str {
- "Failed to produce a hyper client."
- }
-}
diff --git a/rust/fatcat-openapi/src/client/mod.rs b/rust/fatcat-openapi/src/client/mod.rs
new file mode 100644
index 00000000..8a768668
--- /dev/null
+++ b/rust/fatcat-openapi/src/client/mod.rs
@@ -0,0 +1,19689 @@
+use futures;
+use futures::{future, stream, Future, Stream};
+use hyper;
+use hyper::client::HttpConnector;
+use hyper::header::{HeaderName, HeaderValue, CONTENT_TYPE};
+use hyper::{Body, Response, Uri};
+#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
+use hyper_openssl::HttpsConnector;
+use serde_json;
+use std::borrow::Cow;
+use std::convert::TryInto;
+use std::error;
+use std::fmt;
+use std::io::{Error, ErrorKind, Read};
+use std::path::Path;
+use std::str;
+use std::str::FromStr;
+use std::string::ToString;
+use std::sync::Arc;
+use swagger;
+use swagger::{client::Service, ApiError, AuthData, Connector, Has, XSpanIdString};
+use url::form_urlencoded;
+use url::percent_encoding::{utf8_percent_encode, PATH_SEGMENT_ENCODE_SET, QUERY_ENCODE_SET};
+
+use crate::header;
+use crate::models;
+
+url::define_encode_set! {
+ /// This encode set is used for object IDs
+ ///
+ /// Aside from the special characters defined in the `PATH_SEGMENT_ENCODE_SET`,
+ /// the vertical bar (|) is encoded.
+ pub ID_ENCODE_SET = [PATH_SEGMENT_ENCODE_SET] | {'|'}
+}
+
+use crate::{
+ AcceptEditgroupResponse, Api, AuthCheckResponse, AuthOidcResponse, CreateAuthTokenResponse,
+ 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: &str,
+ correct_scheme: Option<&'static str>,
+) -> Result<String, ClientInitError> {
+ // First convert to Uri, since a base path is a subset of Uri.
+ let uri = Uri::from_str(input)?;
+
+ let scheme = uri.scheme_part().ok_or(ClientInitError::InvalidScheme)?;
+
+ // Check the scheme if necessary
+ if let Some(correct_scheme) = correct_scheme {
+ if scheme != correct_scheme {
+ return Err(ClientInitError::InvalidScheme);
+ }
+ }
+
+ let host = uri.host().ok_or_else(|| ClientInitError::MissingHost)?;
+ let port = uri
+ .port_part()
+ .map(|x| format!(":{}", x))
+ .unwrap_or_default();
+ Ok(format!(
+ "{}://{}{}{}",
+ scheme,
+ host,
+ port,
+ uri.path().trim_end_matches('/')
+ ))
+}
+
+/// A client that implements the API by making HTTP calls out to a server.
+pub struct Client<F> {
+ /// Inner service
+ client_service: Arc<Box<dyn Service<ReqBody = Body, Future = F> + Send + Sync>>,
+
+ /// Base path of the API
+ base_path: String,
+}
+
+impl<F> fmt::Debug for Client<F> {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ write!(f, "Client {{ base_path: {} }}", self.base_path)
+ }
+}
+
+impl<F> Clone for Client<F> {
+ fn clone(&self) -> Self {
+ Client {
+ client_service: self.client_service.clone(),
+ base_path: self.base_path.clone(),
+ }
+ }
+}
+
+impl Client<hyper::client::ResponseFuture> {
+ /// Create a client with a custom implementation of hyper::client::Connect.
+ ///
+ /// Intended for use with custom implementations of connect for e.g. protocol logging
+ /// or similar functionality which requires wrapping the transport layer. When wrapping a TCP connection,
+ /// this function should be used in conjunction with `swagger::Connector::builder()`.
+ ///
+ /// For ordinary tcp connections, prefer the use of `try_new_http`, `try_new_https`
+ /// and `try_new_https_mutual`, to avoid introducing a dependency on the underlying transport layer.
+ ///
+ /// # Arguments
+ ///
+ /// * `base_path` - base path of the client API, i.e. "www.my-api-implementation.com"
+ /// * `protocol` - Which protocol to use when constructing the request url, e.g. `Some("http")`
+ /// * `connector` - Implementation of `hyper::client::Connect` to use for the client
+ pub fn try_new_with_connector<C>(
+ base_path: &str,
+ protocol: Option<&'static str>,
+ connector: C,
+ ) -> Result<Self, ClientInitError>
+ where
+ C: hyper::client::connect::Connect + 'static,
+ C::Transport: 'static,
+ C::Future: 'static,
+ {
+ let client_service = Box::new(hyper::client::Client::builder().build(connector));
+
+ Ok(Client {
+ client_service: Arc::new(client_service),
+ base_path: into_base_path(base_path, protocol)?,
+ })
+ }
+
+ /// Create an HTTP client.
+ ///
+ /// # Arguments
+ /// * `base_path` - base path of the client API, i.e. "www.my-api-implementation.com"
+ pub fn try_new_http(base_path: &str) -> Result<Self, ClientInitError> {
+ let http_connector = Connector::builder().build();
+
+ Self::try_new_with_connector(base_path, Some("http"), http_connector)
+ }
+
+ /// Create a client with a TLS connection to the server
+ ///
+ /// # Arguments
+ /// * `base_path` - base path of the client API, i.e. "www.my-api-implementation.com"
+ pub fn try_new_https(base_path: &str) -> Result<Self, ClientInitError> {
+ let https_connector = Connector::builder()
+ .https()
+ .build()
+ .map_err(|e| ClientInitError::SslError(e))?;
+ Self::try_new_with_connector(base_path, Some("https"), https_connector)
+ }
+
+ /// Create a client with a TLS connection to the server using a pinned certificate
+ ///
+ /// # Arguments
+ /// * `base_path` - base path of the client API, i.e. "www.my-api-implementation.com"
+ /// * `ca_certificate` - Path to CA certificate used to authenticate the server
+ #[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
+ pub fn try_new_https_pinned<CA>(
+ base_path: &str,
+ ca_certificate: CA,
+ ) -> Result<Self, ClientInitError>
+ where
+ CA: AsRef<Path>,
+ {
+ let https_connector = Connector::builder()
+ .https()
+ .pin_server_certificate(ca_certificate)
+ .build()
+ .map_err(|e| ClientInitError::SslError(e))?;
+ Self::try_new_with_connector(base_path, Some("https"), https_connector)
+ }
+
+ /// Create a client with a mutually authenticated TLS connection to the server.
+ ///
+ /// # Arguments
+ /// * `base_path` - base path of the client API, i.e. "www.my-api-implementation.com"
+ /// * `ca_certificate` - Path to CA certificate used to authenticate the server
+ /// * `client_key` - Path to the client private key
+ /// * `client_certificate` - Path to the client's public certificate associated with the private key
+ #[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
+ pub fn try_new_https_mutual<CA, K, D>(
+ base_path: &str,
+ ca_certificate: CA,
+ client_key: K,
+ client_certificate: D,
+ ) -> Result<Self, ClientInitError>
+ where
+ CA: AsRef<Path>,
+ K: AsRef<Path>,
+ D: AsRef<Path>,
+ {
+ let https_connector = Connector::builder()
+ .https()
+ .pin_server_certificate(ca_certificate)
+ .client_authentication(client_key, client_certificate)
+ .build()
+ .map_err(|e| ClientInitError::SslError(e))?;
+ Self::try_new_with_connector(base_path, Some("https"), https_connector)
+ }
+}
+
+impl<F> Client<F> {
+ /// Constructor for creating a `Client` by passing in a pre-made `swagger::Service`
+ ///
+ /// This allows adding custom wrappers around the underlying transport, for example for logging.
+ pub fn try_new_with_client_service(
+ client_service: Arc<Box<dyn Service<ReqBody = Body, Future = F> + Send + Sync>>,
+ base_path: &str,
+ ) -> Result<Self, ClientInitError> {
+ Ok(Client {
+ client_service: client_service,
+ base_path: into_base_path(base_path, None)?,
+ })
+ }
+}
+
+/// Error type failing to create a Client
+#[derive(Debug)]
+pub enum ClientInitError {
+ /// Invalid URL Scheme
+ InvalidScheme,
+
+ /// Invalid URI
+ InvalidUri(hyper::http::uri::InvalidUri),
+
+ /// Missing Hostname
+ MissingHost,
+
+ /// SSL Connection Error
+ #[cfg(any(target_os = "macos", target_os = "windows", target_os = "ios"))]
+ SslError(native_tls::Error),
+
+ /// SSL Connection Error
+ #[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
+ SslError(openssl::error::ErrorStack),
+}
+
+impl From<hyper::http::uri::InvalidUri> for ClientInitError {
+ fn from(err: hyper::http::uri::InvalidUri) -> ClientInitError {
+ ClientInitError::InvalidUri(err)
+ }
+}
+
+impl fmt::Display for ClientInitError {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ let s: &dyn fmt::Debug = self;
+ s.fmt(f)
+ }
+}
+
+impl error::Error for ClientInitError {
+ fn description(&self) -> &str {
+ "Failed to produce a hyper client."
+ }
+}
+
+impl<C, F> Api<C> for Client<F>
+where
+ C: Has<XSpanIdString> + Has<Option<AuthData>>,
+ F: Future<Item = Response<Body>, Error = hyper::Error> + Send + 'static,
+{
+ fn accept_editgroup(
+ &self,
+ param_editgroup_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = AcceptEditgroupResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/editgroup/{editgroup_id}/accept",
+ self.base_path,
+ editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("POST")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::Success>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ AcceptEditgroupResponse::MergedSuccessfully
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ AcceptEditgroupResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ AcceptEditgroupResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ AcceptEditgroupResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ AcceptEditgroupResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 409 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ AcceptEditgroupResponse::EditConflict
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ AcceptEditgroupResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn auth_check(
+ &self,
+ param_role: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = AuthCheckResponse, Error = ApiError> + Send> {
+ let mut uri = format!("{}/v0/auth/check", self.base_path);
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_role) = param_role {
+ query_string.append_pair("role", &param_role.to_string());
+ }
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::Success>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ AuthCheckResponse::Success
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ AuthCheckResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ AuthCheckResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ AuthCheckResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ AuthCheckResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn auth_oidc(
+ &self,
+ param_oidc_params: models::AuthOidc,
+ context: &C,
+ ) -> Box<dyn Future<Item = AuthOidcResponse, Error = ApiError> + Send> {
+ let mut uri = format!("{}/v0/auth/oidc", self.base_path);
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("POST")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let body =
+ serde_json::to_string(&param_oidc_params).expect("impossible to fail to serialize");
+ *request.body_mut() = Body::from(body);
+
+ let header = "application/json";
+ request.headers_mut().insert(
+ CONTENT_TYPE,
+ match HeaderValue::from_str(header) {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ ))))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::AuthOidcResult>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ AuthOidcResponse::Found
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 201 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::AuthOidcResult>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ AuthOidcResponse::Created
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ AuthOidcResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ AuthOidcResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ AuthOidcResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 409 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ AuthOidcResponse::Conflict
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ AuthOidcResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn create_auth_token(
+ &self,
+ param_editor_id: String,
+ param_duration_seconds: Option<i32>,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateAuthTokenResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/auth/token/{editor_id}",
+ self.base_path,
+ editor_id = utf8_percent_encode(&param_editor_id.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_duration_seconds) = param_duration_seconds {
+ query_string.append_pair("duration_seconds", &param_duration_seconds.to_string());
+ }
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("POST")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::AuthTokenResult>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateAuthTokenResponse::Success
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateAuthTokenResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateAuthTokenResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateAuthTokenResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateAuthTokenResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn create_container(
+ &self,
+ param_editgroup_id: String,
+ param_entity: models::ContainerEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateContainerResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/editgroup/{editgroup_id}/container",
+ self.base_path,
+ editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("POST")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let body = serde_json::to_string(&param_entity).expect("impossible to fail to serialize");
+ *request.body_mut() = Body::from(body);
+
+ let header = "application/json";
+ request.headers_mut().insert(
+ CONTENT_TYPE,
+ match HeaderValue::from_str(header) {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ ))))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 201 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::EntityEdit>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateContainerResponse::CreatedEntity
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateContainerResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateContainerResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateContainerResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateContainerResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateContainerResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn create_container_auto_batch(
+ &self,
+ param_auto_batch: models::ContainerAutoBatch,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateContainerAutoBatchResponse, Error = ApiError> + Send> {
+ let mut uri = format!("{}/v0/editgroup/auto/container/batch", self.base_path);
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("POST")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let body =
+ serde_json::to_string(&param_auto_batch).expect("impossible to fail to serialize");
+ *request.body_mut() = Body::from(body);
+
+ let header = "application/json";
+ request.headers_mut().insert(
+ CONTENT_TYPE,
+ match HeaderValue::from_str(header) {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ ))))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 201 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::Editgroup>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateContainerAutoBatchResponse::CreatedEditgroup
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateContainerAutoBatchResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateContainerAutoBatchResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateContainerAutoBatchResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateContainerAutoBatchResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateContainerAutoBatchResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn create_creator(
+ &self,
+ param_editgroup_id: String,
+ param_entity: models::CreatorEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateCreatorResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/editgroup/{editgroup_id}/creator",
+ self.base_path,
+ editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("POST")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let body = serde_json::to_string(&param_entity).expect("impossible to fail to serialize");
+ *request.body_mut() = Body::from(body);
+
+ let header = "application/json";
+ request.headers_mut().insert(
+ CONTENT_TYPE,
+ match HeaderValue::from_str(header) {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ ))))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 201 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::EntityEdit>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateCreatorResponse::CreatedEntity
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateCreatorResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateCreatorResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateCreatorResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateCreatorResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateCreatorResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn create_creator_auto_batch(
+ &self,
+ param_auto_batch: models::CreatorAutoBatch,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateCreatorAutoBatchResponse, Error = ApiError> + Send> {
+ let mut uri = format!("{}/v0/editgroup/auto/creator/batch", self.base_path);
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("POST")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let body =
+ serde_json::to_string(&param_auto_batch).expect("impossible to fail to serialize");
+ *request.body_mut() = Body::from(body);
+
+ let header = "application/json";
+ request.headers_mut().insert(
+ CONTENT_TYPE,
+ match HeaderValue::from_str(header) {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ ))))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 201 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::Editgroup>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateCreatorAutoBatchResponse::CreatedEditgroup
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateCreatorAutoBatchResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateCreatorAutoBatchResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateCreatorAutoBatchResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateCreatorAutoBatchResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateCreatorAutoBatchResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn create_editgroup(
+ &self,
+ param_editgroup: models::Editgroup,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateEditgroupResponse, Error = ApiError> + Send> {
+ let mut uri = format!("{}/v0/editgroup", self.base_path);
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("POST")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let body =
+ serde_json::to_string(&param_editgroup).expect("impossible to fail to serialize");
+ *request.body_mut() = Body::from(body);
+
+ let header = "application/json";
+ request.headers_mut().insert(
+ CONTENT_TYPE,
+ match HeaderValue::from_str(header) {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ ))))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 201 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::Editgroup>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateEditgroupResponse::SuccessfullyCreated
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateEditgroupResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateEditgroupResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateEditgroupResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateEditgroupResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateEditgroupResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn create_editgroup_annotation(
+ &self,
+ param_editgroup_id: String,
+ param_annotation: models::EditgroupAnnotation,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateEditgroupAnnotationResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/editgroup/{editgroup_id}/annotation",
+ self.base_path,
+ editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("POST")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let body =
+ serde_json::to_string(&param_annotation).expect("impossible to fail to serialize");
+ *request.body_mut() = Body::from(body);
+
+ let header = "application/json";
+ request.headers_mut().insert(
+ CONTENT_TYPE,
+ match HeaderValue::from_str(header) {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ ))))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 201 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::EditgroupAnnotation>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateEditgroupAnnotationResponse::Created
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateEditgroupAnnotationResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateEditgroupAnnotationResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateEditgroupAnnotationResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateEditgroupAnnotationResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateEditgroupAnnotationResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn create_file(
+ &self,
+ param_editgroup_id: String,
+ param_entity: models::FileEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateFileResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/editgroup/{editgroup_id}/file",
+ self.base_path,
+ editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("POST")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let body = serde_json::to_string(&param_entity).expect("impossible to fail to serialize");
+ *request.body_mut() = Body::from(body);
+
+ let header = "application/json";
+ request.headers_mut().insert(
+ CONTENT_TYPE,
+ match HeaderValue::from_str(header) {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ ))))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 201 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::EntityEdit>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateFileResponse::CreatedEntity
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateFileResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateFileResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateFileResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateFileResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateFileResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn create_file_auto_batch(
+ &self,
+ param_auto_batch: models::FileAutoBatch,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateFileAutoBatchResponse, Error = ApiError> + Send> {
+ let mut uri = format!("{}/v0/editgroup/auto/file/batch", self.base_path);
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("POST")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let body =
+ serde_json::to_string(&param_auto_batch).expect("impossible to fail to serialize");
+ *request.body_mut() = Body::from(body);
+
+ let header = "application/json";
+ request.headers_mut().insert(
+ CONTENT_TYPE,
+ match HeaderValue::from_str(header) {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ ))))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 201 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::Editgroup>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateFileAutoBatchResponse::CreatedEditgroup
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateFileAutoBatchResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateFileAutoBatchResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateFileAutoBatchResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateFileAutoBatchResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateFileAutoBatchResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn create_fileset(
+ &self,
+ param_editgroup_id: String,
+ param_entity: models::FilesetEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateFilesetResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/editgroup/{editgroup_id}/fileset",
+ self.base_path,
+ editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("POST")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let body = serde_json::to_string(&param_entity).expect("impossible to fail to serialize");
+ *request.body_mut() = Body::from(body);
+
+ let header = "application/json";
+ request.headers_mut().insert(
+ CONTENT_TYPE,
+ match HeaderValue::from_str(header) {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ ))))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 201 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::EntityEdit>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateFilesetResponse::CreatedEntity
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateFilesetResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateFilesetResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateFilesetResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateFilesetResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateFilesetResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn create_fileset_auto_batch(
+ &self,
+ param_auto_batch: models::FilesetAutoBatch,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateFilesetAutoBatchResponse, Error = ApiError> + Send> {
+ let mut uri = format!("{}/v0/editgroup/auto/fileset/batch", self.base_path);
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("POST")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let body =
+ serde_json::to_string(&param_auto_batch).expect("impossible to fail to serialize");
+ *request.body_mut() = Body::from(body);
+
+ let header = "application/json";
+ request.headers_mut().insert(
+ CONTENT_TYPE,
+ match HeaderValue::from_str(header) {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ ))))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 201 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::Editgroup>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateFilesetAutoBatchResponse::CreatedEditgroup
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateFilesetAutoBatchResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateFilesetAutoBatchResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateFilesetAutoBatchResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateFilesetAutoBatchResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateFilesetAutoBatchResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn create_release(
+ &self,
+ param_editgroup_id: String,
+ param_entity: models::ReleaseEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateReleaseResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/editgroup/{editgroup_id}/release",
+ self.base_path,
+ editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("POST")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let body = serde_json::to_string(&param_entity).expect("impossible to fail to serialize");
+ *request.body_mut() = Body::from(body);
+
+ let header = "application/json";
+ request.headers_mut().insert(
+ CONTENT_TYPE,
+ match HeaderValue::from_str(header) {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ ))))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 201 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::EntityEdit>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateReleaseResponse::CreatedEntity
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateReleaseResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateReleaseResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateReleaseResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateReleaseResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateReleaseResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn create_release_auto_batch(
+ &self,
+ param_auto_batch: models::ReleaseAutoBatch,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateReleaseAutoBatchResponse, Error = ApiError> + Send> {
+ let mut uri = format!("{}/v0/editgroup/auto/release/batch", self.base_path);
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("POST")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let body =
+ serde_json::to_string(&param_auto_batch).expect("impossible to fail to serialize");
+ *request.body_mut() = Body::from(body);
+
+ let header = "application/json";
+ request.headers_mut().insert(
+ CONTENT_TYPE,
+ match HeaderValue::from_str(header) {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ ))))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 201 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::Editgroup>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateReleaseAutoBatchResponse::CreatedEditgroup
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateReleaseAutoBatchResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateReleaseAutoBatchResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateReleaseAutoBatchResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateReleaseAutoBatchResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateReleaseAutoBatchResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn create_webcapture(
+ &self,
+ param_editgroup_id: String,
+ param_entity: models::WebcaptureEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateWebcaptureResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/editgroup/{editgroup_id}/webcapture",
+ self.base_path,
+ editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("POST")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let body = serde_json::to_string(&param_entity).expect("impossible to fail to serialize");
+ *request.body_mut() = Body::from(body);
+
+ let header = "application/json";
+ request.headers_mut().insert(
+ CONTENT_TYPE,
+ match HeaderValue::from_str(header) {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ ))))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 201 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::EntityEdit>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateWebcaptureResponse::CreatedEntity
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateWebcaptureResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateWebcaptureResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateWebcaptureResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateWebcaptureResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateWebcaptureResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn create_webcapture_auto_batch(
+ &self,
+ param_auto_batch: models::WebcaptureAutoBatch,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateWebcaptureAutoBatchResponse, Error = ApiError> + Send> {
+ let mut uri = format!("{}/v0/editgroup/auto/webcapture/batch", self.base_path);
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("POST")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let body =
+ serde_json::to_string(&param_auto_batch).expect("impossible to fail to serialize");
+ *request.body_mut() = Body::from(body);
+
+ let header = "application/json";
+ request.headers_mut().insert(
+ CONTENT_TYPE,
+ match HeaderValue::from_str(header) {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ ))))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 201 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::Editgroup>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateWebcaptureAutoBatchResponse::CreatedEditgroup
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateWebcaptureAutoBatchResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateWebcaptureAutoBatchResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateWebcaptureAutoBatchResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateWebcaptureAutoBatchResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateWebcaptureAutoBatchResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn create_work(
+ &self,
+ param_editgroup_id: String,
+ param_entity: models::WorkEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateWorkResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/editgroup/{editgroup_id}/work",
+ self.base_path,
+ editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("POST")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let body = serde_json::to_string(&param_entity).expect("impossible to fail to serialize");
+ *request.body_mut() = Body::from(body);
+
+ let header = "application/json";
+ request.headers_mut().insert(
+ CONTENT_TYPE,
+ match HeaderValue::from_str(header) {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ ))))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 201 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::EntityEdit>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateWorkResponse::CreatedEntity
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateWorkResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateWorkResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateWorkResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateWorkResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateWorkResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn create_work_auto_batch(
+ &self,
+ param_auto_batch: models::WorkAutoBatch,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateWorkAutoBatchResponse, Error = ApiError> + Send> {
+ let mut uri = format!("{}/v0/editgroup/auto/work/batch", self.base_path);
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("POST")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let body =
+ serde_json::to_string(&param_auto_batch).expect("impossible to fail to serialize");
+ *request.body_mut() = Body::from(body);
+
+ let header = "application/json";
+ request.headers_mut().insert(
+ CONTENT_TYPE,
+ match HeaderValue::from_str(header) {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ ))))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 201 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::Editgroup>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateWorkAutoBatchResponse::CreatedEditgroup
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateWorkAutoBatchResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateWorkAutoBatchResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateWorkAutoBatchResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateWorkAutoBatchResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ CreateWorkAutoBatchResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn delete_container(
+ &self,
+ param_editgroup_id: String,
+ param_ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteContainerResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/editgroup/{editgroup_id}/container/{ident}",
+ self.base_path,
+ editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), ID_ENCODE_SET),
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("DELETE")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::EntityEdit>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteContainerResponse::DeletedEntity
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteContainerResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteContainerResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteContainerResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteContainerResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteContainerResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn delete_container_edit(
+ &self,
+ param_editgroup_id: String,
+ param_edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteContainerEditResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/editgroup/{editgroup_id}/container/edit/{edit_id}",
+ self.base_path,
+ editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), ID_ENCODE_SET),
+ edit_id = utf8_percent_encode(&param_edit_id.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("DELETE")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::Success>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteContainerEditResponse::DeletedEdit
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteContainerEditResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteContainerEditResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteContainerEditResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteContainerEditResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteContainerEditResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn delete_creator(
+ &self,
+ param_editgroup_id: String,
+ param_ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteCreatorResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/editgroup/{editgroup_id}/creator/{ident}",
+ self.base_path,
+ editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), ID_ENCODE_SET),
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("DELETE")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::EntityEdit>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteCreatorResponse::DeletedEntity
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteCreatorResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteCreatorResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteCreatorResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteCreatorResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteCreatorResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn delete_creator_edit(
+ &self,
+ param_editgroup_id: String,
+ param_edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteCreatorEditResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/editgroup/{editgroup_id}/creator/edit/{edit_id}",
+ self.base_path,
+ editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), ID_ENCODE_SET),
+ edit_id = utf8_percent_encode(&param_edit_id.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("DELETE")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::Success>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteCreatorEditResponse::DeletedEdit
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteCreatorEditResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteCreatorEditResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteCreatorEditResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteCreatorEditResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteCreatorEditResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn delete_file(
+ &self,
+ param_editgroup_id: String,
+ param_ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteFileResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/editgroup/{editgroup_id}/file/{ident}",
+ self.base_path,
+ editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), ID_ENCODE_SET),
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("DELETE")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::EntityEdit>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteFileResponse::DeletedEntity
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteFileResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteFileResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteFileResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteFileResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteFileResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn delete_file_edit(
+ &self,
+ param_editgroup_id: String,
+ param_edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteFileEditResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/editgroup/{editgroup_id}/file/edit/{edit_id}",
+ self.base_path,
+ editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), ID_ENCODE_SET),
+ edit_id = utf8_percent_encode(&param_edit_id.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("DELETE")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::Success>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteFileEditResponse::DeletedEdit
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteFileEditResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteFileEditResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteFileEditResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteFileEditResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteFileEditResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn delete_fileset(
+ &self,
+ param_editgroup_id: String,
+ param_ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteFilesetResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/editgroup/{editgroup_id}/fileset/{ident}",
+ self.base_path,
+ editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), ID_ENCODE_SET),
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("DELETE")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::EntityEdit>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteFilesetResponse::DeletedEntity
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteFilesetResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteFilesetResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteFilesetResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteFilesetResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteFilesetResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn delete_fileset_edit(
+ &self,
+ param_editgroup_id: String,
+ param_edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteFilesetEditResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/editgroup/{editgroup_id}/fileset/edit/{edit_id}",
+ self.base_path,
+ editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), ID_ENCODE_SET),
+ edit_id = utf8_percent_encode(&param_edit_id.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("DELETE")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::Success>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteFilesetEditResponse::DeletedEdit
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteFilesetEditResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteFilesetEditResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteFilesetEditResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteFilesetEditResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteFilesetEditResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn delete_release(
+ &self,
+ param_editgroup_id: String,
+ param_ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteReleaseResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/editgroup/{editgroup_id}/release/{ident}",
+ self.base_path,
+ editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), ID_ENCODE_SET),
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("DELETE")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::EntityEdit>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteReleaseResponse::DeletedEntity
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteReleaseResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteReleaseResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteReleaseResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteReleaseResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteReleaseResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn delete_release_edit(
+ &self,
+ param_editgroup_id: String,
+ param_edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteReleaseEditResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/editgroup/{editgroup_id}/release/edit/{edit_id}",
+ self.base_path,
+ editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), ID_ENCODE_SET),
+ edit_id = utf8_percent_encode(&param_edit_id.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("DELETE")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::Success>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteReleaseEditResponse::DeletedEdit
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteReleaseEditResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteReleaseEditResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteReleaseEditResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteReleaseEditResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteReleaseEditResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn delete_webcapture(
+ &self,
+ param_editgroup_id: String,
+ param_ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteWebcaptureResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/editgroup/{editgroup_id}/webcapture/{ident}",
+ self.base_path,
+ editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), ID_ENCODE_SET),
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("DELETE")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::EntityEdit>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteWebcaptureResponse::DeletedEntity
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteWebcaptureResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteWebcaptureResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteWebcaptureResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteWebcaptureResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteWebcaptureResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn delete_webcapture_edit(
+ &self,
+ param_editgroup_id: String,
+ param_edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteWebcaptureEditResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/editgroup/{editgroup_id}/webcapture/edit/{edit_id}",
+ self.base_path,
+ editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), ID_ENCODE_SET),
+ edit_id = utf8_percent_encode(&param_edit_id.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("DELETE")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::Success>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteWebcaptureEditResponse::DeletedEdit
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteWebcaptureEditResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteWebcaptureEditResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteWebcaptureEditResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteWebcaptureEditResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteWebcaptureEditResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn delete_work(
+ &self,
+ param_editgroup_id: String,
+ param_ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteWorkResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/editgroup/{editgroup_id}/work/{ident}",
+ self.base_path,
+ editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), ID_ENCODE_SET),
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("DELETE")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::EntityEdit>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteWorkResponse::DeletedEntity
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteWorkResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteWorkResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteWorkResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteWorkResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteWorkResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn delete_work_edit(
+ &self,
+ param_editgroup_id: String,
+ param_edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteWorkEditResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/editgroup/{editgroup_id}/work/edit/{edit_id}",
+ self.base_path,
+ editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), ID_ENCODE_SET),
+ edit_id = utf8_percent_encode(&param_edit_id.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("DELETE")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::Success>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteWorkEditResponse::DeletedEdit
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteWorkEditResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteWorkEditResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteWorkEditResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteWorkEditResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ DeleteWorkEditResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn get_changelog(
+ &self,
+ param_limit: Option<i64>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetChangelogResponse, Error = ApiError> + Send> {
+ let mut uri = format!("{}/v0/changelog", self.base_path);
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_limit) = param_limit {
+ query_string.append_pair("limit", &param_limit.to_string());
+ }
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<Vec<models::ChangelogEntry>>(
+ body,
+ )
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetChangelogResponse::Success(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetChangelogResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetChangelogResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_changelog_entry(
+ &self,
+ param_index: i64,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetChangelogEntryResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/changelog/{index}",
+ self.base_path,
+ index = utf8_percent_encode(&param_index.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ChangelogEntry>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| {
+ GetChangelogEntryResponse::FoundChangelogEntry(body)
+ }),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetChangelogEntryResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetChangelogEntryResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetChangelogEntryResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_container(
+ &self,
+ param_ident: String,
+ param_expand: Option<String>,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetContainerResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/container/{ident}",
+ self.base_path,
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_expand) = param_expand {
+ query_string.append_pair("expand", &param_expand.to_string());
+ }
+ if let Some(param_hide) = param_hide {
+ query_string.append_pair("hide", &param_hide.to_string());
+ }
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ContainerEntity>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetContainerResponse::FoundEntity(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetContainerResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetContainerResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetContainerResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_container_edit(
+ &self,
+ param_edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetContainerEditResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/container/edit/{edit_id}",
+ self.base_path,
+ edit_id = utf8_percent_encode(&param_edit_id.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::EntityEdit>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetContainerEditResponse::FoundEdit(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetContainerEditResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetContainerEditResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetContainerEditResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_container_history(
+ &self,
+ param_ident: String,
+ param_limit: Option<i64>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetContainerHistoryResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/container/{ident}/history",
+ self.base_path,
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_limit) = param_limit {
+ query_string.append_pair("limit", &param_limit.to_string());
+ }
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<Vec<models::EntityHistoryEntry>>(
+ body,
+ )
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| {
+ GetContainerHistoryResponse::FoundEntityHistory(body)
+ }),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetContainerHistoryResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetContainerHistoryResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetContainerHistoryResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_container_redirects(
+ &self,
+ param_ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetContainerRedirectsResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/container/{ident}/redirects",
+ self.base_path,
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<Vec<String>>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| {
+ GetContainerRedirectsResponse::FoundEntityRedirects(body)
+ }),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetContainerRedirectsResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetContainerRedirectsResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetContainerRedirectsResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_container_revision(
+ &self,
+ param_rev_id: String,
+ param_expand: Option<String>,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetContainerRevisionResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/container/rev/{rev_id}",
+ self.base_path,
+ rev_id = utf8_percent_encode(&param_rev_id.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_expand) = param_expand {
+ query_string.append_pair("expand", &param_expand.to_string());
+ }
+ if let Some(param_hide) = param_hide {
+ query_string.append_pair("hide", &param_hide.to_string());
+ }
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ContainerEntity>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| {
+ GetContainerRevisionResponse::FoundEntityRevision(body)
+ }),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetContainerRevisionResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetContainerRevisionResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetContainerRevisionResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_creator(
+ &self,
+ param_ident: String,
+ param_expand: Option<String>,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetCreatorResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/creator/{ident}",
+ self.base_path,
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_expand) = param_expand {
+ query_string.append_pair("expand", &param_expand.to_string());
+ }
+ if let Some(param_hide) = param_hide {
+ query_string.append_pair("hide", &param_hide.to_string());
+ }
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::CreatorEntity>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetCreatorResponse::FoundEntity(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetCreatorResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetCreatorResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetCreatorResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_creator_edit(
+ &self,
+ param_edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetCreatorEditResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/creator/edit/{edit_id}",
+ self.base_path,
+ edit_id = utf8_percent_encode(&param_edit_id.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::EntityEdit>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetCreatorEditResponse::FoundEdit(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetCreatorEditResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetCreatorEditResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetCreatorEditResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_creator_history(
+ &self,
+ param_ident: String,
+ param_limit: Option<i64>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetCreatorHistoryResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/creator/{ident}/history",
+ self.base_path,
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_limit) = param_limit {
+ query_string.append_pair("limit", &param_limit.to_string());
+ }
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<Vec<models::EntityHistoryEntry>>(
+ body,
+ )
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| {
+ GetCreatorHistoryResponse::FoundEntityHistory(body)
+ }),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetCreatorHistoryResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetCreatorHistoryResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetCreatorHistoryResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_creator_redirects(
+ &self,
+ param_ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetCreatorRedirectsResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/creator/{ident}/redirects",
+ self.base_path,
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<Vec<String>>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| {
+ GetCreatorRedirectsResponse::FoundEntityRedirects(body)
+ }),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetCreatorRedirectsResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetCreatorRedirectsResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetCreatorRedirectsResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_creator_releases(
+ &self,
+ param_ident: String,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetCreatorReleasesResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/creator/{ident}/releases",
+ self.base_path,
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_hide) = param_hide {
+ query_string.append_pair("hide", &param_hide.to_string());
+ }
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<Vec<models::ReleaseEntity>>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetCreatorReleasesResponse::Found(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetCreatorReleasesResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetCreatorReleasesResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetCreatorReleasesResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_creator_revision(
+ &self,
+ param_rev_id: String,
+ param_expand: Option<String>,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetCreatorRevisionResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/creator/rev/{rev_id}",
+ self.base_path,
+ rev_id = utf8_percent_encode(&param_rev_id.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_expand) = param_expand {
+ query_string.append_pair("expand", &param_expand.to_string());
+ }
+ if let Some(param_hide) = param_hide {
+ query_string.append_pair("hide", &param_hide.to_string());
+ }
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::CreatorEntity>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| {
+ GetCreatorRevisionResponse::FoundEntityRevision(body)
+ }),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetCreatorRevisionResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetCreatorRevisionResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetCreatorRevisionResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_editgroup(
+ &self,
+ param_editgroup_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetEditgroupResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/editgroup/{editgroup_id}",
+ self.base_path,
+ editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::Editgroup>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetEditgroupResponse::Found(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetEditgroupResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetEditgroupResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetEditgroupResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_editgroup_annotations(
+ &self,
+ param_editgroup_id: String,
+ param_expand: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetEditgroupAnnotationsResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/editgroup/{editgroup_id}/annotations",
+ self.base_path,
+ editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_expand) = param_expand {
+ query_string.append_pair("expand", &param_expand.to_string());
+ }
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<Vec<models::EditgroupAnnotation>>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ GetEditgroupAnnotationsResponse::Success
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ GetEditgroupAnnotationsResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ GetEditgroupAnnotationsResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ GetEditgroupAnnotationsResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ GetEditgroupAnnotationsResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ GetEditgroupAnnotationsResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn get_editgroups_reviewable(
+ &self,
+ param_expand: Option<String>,
+ param_limit: Option<i64>,
+ param_before: Option<chrono::DateTime<chrono::Utc>>,
+ param_since: Option<chrono::DateTime<chrono::Utc>>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetEditgroupsReviewableResponse, Error = ApiError> + Send> {
+ let mut uri = format!("{}/v0/editgroup/reviewable", self.base_path);
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_expand) = param_expand {
+ query_string.append_pair("expand", &param_expand.to_string());
+ }
+ if let Some(param_limit) = param_limit {
+ query_string.append_pair("limit", &param_limit.to_string());
+ }
+ if let Some(param_before) = param_before {
+ query_string.append_pair("before", &param_before.to_string());
+ }
+ if let Some(param_since) = param_since {
+ query_string.append_pair("since", &param_since.to_string());
+ }
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<Vec<models::Editgroup>>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetEditgroupsReviewableResponse::Found(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetEditgroupsReviewableResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetEditgroupsReviewableResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| {
+ GetEditgroupsReviewableResponse::GenericError(body)
+ }),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_editor(
+ &self,
+ param_editor_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetEditorResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/editor/{editor_id}",
+ self.base_path,
+ editor_id = utf8_percent_encode(&param_editor_id.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::Editor>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetEditorResponse::Found(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetEditorResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetEditorResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetEditorResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_editor_annotations(
+ &self,
+ param_editor_id: String,
+ param_limit: Option<i64>,
+ param_before: Option<chrono::DateTime<chrono::Utc>>,
+ param_since: Option<chrono::DateTime<chrono::Utc>>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetEditorAnnotationsResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/editor/{editor_id}/annotations",
+ self.base_path,
+ editor_id = utf8_percent_encode(&param_editor_id.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_limit) = param_limit {
+ query_string.append_pair("limit", &param_limit.to_string());
+ }
+ if let Some(param_before) = param_before {
+ query_string.append_pair("before", &param_before.to_string());
+ }
+ if let Some(param_since) = param_since {
+ query_string.append_pair("since", &param_since.to_string());
+ }
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<Vec<models::EditgroupAnnotation>>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ GetEditorAnnotationsResponse::Success
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ GetEditorAnnotationsResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ GetEditorAnnotationsResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ GetEditorAnnotationsResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ GetEditorAnnotationsResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ GetEditorAnnotationsResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn get_editor_editgroups(
+ &self,
+ param_editor_id: String,
+ param_limit: Option<i64>,
+ param_before: Option<chrono::DateTime<chrono::Utc>>,
+ param_since: Option<chrono::DateTime<chrono::Utc>>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetEditorEditgroupsResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/editor/{editor_id}/editgroups",
+ self.base_path,
+ editor_id = utf8_percent_encode(&param_editor_id.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_limit) = param_limit {
+ query_string.append_pair("limit", &param_limit.to_string());
+ }
+ if let Some(param_before) = param_before {
+ query_string.append_pair("before", &param_before.to_string());
+ }
+ if let Some(param_since) = param_since {
+ query_string.append_pair("since", &param_since.to_string());
+ }
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<Vec<models::Editgroup>>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetEditorEditgroupsResponse::Found(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetEditorEditgroupsResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetEditorEditgroupsResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetEditorEditgroupsResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_file(
+ &self,
+ param_ident: String,
+ param_expand: Option<String>,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetFileResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/file/{ident}",
+ self.base_path,
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_expand) = param_expand {
+ query_string.append_pair("expand", &param_expand.to_string());
+ }
+ if let Some(param_hide) = param_hide {
+ query_string.append_pair("hide", &param_hide.to_string());
+ }
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::FileEntity>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetFileResponse::FoundEntity(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetFileResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetFileResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetFileResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_file_edit(
+ &self,
+ param_edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetFileEditResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/file/edit/{edit_id}",
+ self.base_path,
+ edit_id = utf8_percent_encode(&param_edit_id.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::EntityEdit>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetFileEditResponse::FoundEdit(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetFileEditResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetFileEditResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetFileEditResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_file_history(
+ &self,
+ param_ident: String,
+ param_limit: Option<i64>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetFileHistoryResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/file/{ident}/history",
+ self.base_path,
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_limit) = param_limit {
+ query_string.append_pair("limit", &param_limit.to_string());
+ }
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<Vec<models::EntityHistoryEntry>>(
+ body,
+ )
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetFileHistoryResponse::FoundEntityHistory(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetFileHistoryResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetFileHistoryResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetFileHistoryResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_file_redirects(
+ &self,
+ param_ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetFileRedirectsResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/file/{ident}/redirects",
+ self.base_path,
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<Vec<String>>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| {
+ GetFileRedirectsResponse::FoundEntityRedirects(body)
+ }),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetFileRedirectsResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetFileRedirectsResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetFileRedirectsResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_file_revision(
+ &self,
+ param_rev_id: String,
+ param_expand: Option<String>,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetFileRevisionResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/file/rev/{rev_id}",
+ self.base_path,
+ rev_id = utf8_percent_encode(&param_rev_id.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_expand) = param_expand {
+ query_string.append_pair("expand", &param_expand.to_string());
+ }
+ if let Some(param_hide) = param_hide {
+ query_string.append_pair("hide", &param_hide.to_string());
+ }
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::FileEntity>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| {
+ GetFileRevisionResponse::FoundEntityRevision(body)
+ }),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetFileRevisionResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetFileRevisionResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetFileRevisionResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_fileset(
+ &self,
+ param_ident: String,
+ param_expand: Option<String>,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetFilesetResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/fileset/{ident}",
+ self.base_path,
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_expand) = param_expand {
+ query_string.append_pair("expand", &param_expand.to_string());
+ }
+ if let Some(param_hide) = param_hide {
+ query_string.append_pair("hide", &param_hide.to_string());
+ }
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::FilesetEntity>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetFilesetResponse::FoundEntity(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetFilesetResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetFilesetResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetFilesetResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_fileset_edit(
+ &self,
+ param_edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetFilesetEditResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/fileset/edit/{edit_id}",
+ self.base_path,
+ edit_id = utf8_percent_encode(&param_edit_id.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::EntityEdit>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetFilesetEditResponse::FoundEdit(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetFilesetEditResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetFilesetEditResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetFilesetEditResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_fileset_history(
+ &self,
+ param_ident: String,
+ param_limit: Option<i64>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetFilesetHistoryResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/fileset/{ident}/history",
+ self.base_path,
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_limit) = param_limit {
+ query_string.append_pair("limit", &param_limit.to_string());
+ }
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<Vec<models::EntityHistoryEntry>>(
+ body,
+ )
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| {
+ GetFilesetHistoryResponse::FoundEntityHistory(body)
+ }),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetFilesetHistoryResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetFilesetHistoryResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetFilesetHistoryResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_fileset_redirects(
+ &self,
+ param_ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetFilesetRedirectsResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/fileset/{ident}/redirects",
+ self.base_path,
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<Vec<String>>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| {
+ GetFilesetRedirectsResponse::FoundEntityRedirects(body)
+ }),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetFilesetRedirectsResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetFilesetRedirectsResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetFilesetRedirectsResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_fileset_revision(
+ &self,
+ param_rev_id: String,
+ param_expand: Option<String>,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetFilesetRevisionResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/fileset/rev/{rev_id}",
+ self.base_path,
+ rev_id = utf8_percent_encode(&param_rev_id.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_expand) = param_expand {
+ query_string.append_pair("expand", &param_expand.to_string());
+ }
+ if let Some(param_hide) = param_hide {
+ query_string.append_pair("hide", &param_hide.to_string());
+ }
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::FilesetEntity>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| {
+ GetFilesetRevisionResponse::FoundEntityRevision(body)
+ }),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetFilesetRevisionResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetFilesetRevisionResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetFilesetRevisionResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_release(
+ &self,
+ param_ident: String,
+ param_expand: Option<String>,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetReleaseResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/release/{ident}",
+ self.base_path,
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_expand) = param_expand {
+ query_string.append_pair("expand", &param_expand.to_string());
+ }
+ if let Some(param_hide) = param_hide {
+ query_string.append_pair("hide", &param_hide.to_string());
+ }
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ReleaseEntity>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetReleaseResponse::FoundEntity(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetReleaseResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetReleaseResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetReleaseResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_release_edit(
+ &self,
+ param_edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetReleaseEditResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/release/edit/{edit_id}",
+ self.base_path,
+ edit_id = utf8_percent_encode(&param_edit_id.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::EntityEdit>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetReleaseEditResponse::FoundEdit(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetReleaseEditResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetReleaseEditResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetReleaseEditResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_release_files(
+ &self,
+ param_ident: String,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetReleaseFilesResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/release/{ident}/files",
+ self.base_path,
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_hide) = param_hide {
+ query_string.append_pair("hide", &param_hide.to_string());
+ }
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<Vec<models::FileEntity>>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetReleaseFilesResponse::Found(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetReleaseFilesResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetReleaseFilesResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetReleaseFilesResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_release_filesets(
+ &self,
+ param_ident: String,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetReleaseFilesetsResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/release/{ident}/filesets",
+ self.base_path,
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_hide) = param_hide {
+ query_string.append_pair("hide", &param_hide.to_string());
+ }
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<Vec<models::FilesetEntity>>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetReleaseFilesetsResponse::Found(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetReleaseFilesetsResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetReleaseFilesetsResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetReleaseFilesetsResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_release_history(
+ &self,
+ param_ident: String,
+ param_limit: Option<i64>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetReleaseHistoryResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/release/{ident}/history",
+ self.base_path,
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_limit) = param_limit {
+ query_string.append_pair("limit", &param_limit.to_string());
+ }
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<Vec<models::EntityHistoryEntry>>(
+ body,
+ )
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| {
+ GetReleaseHistoryResponse::FoundEntityHistory(body)
+ }),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetReleaseHistoryResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetReleaseHistoryResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetReleaseHistoryResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_release_redirects(
+ &self,
+ param_ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetReleaseRedirectsResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/release/{ident}/redirects",
+ self.base_path,
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<Vec<String>>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| {
+ GetReleaseRedirectsResponse::FoundEntityRedirects(body)
+ }),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetReleaseRedirectsResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetReleaseRedirectsResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetReleaseRedirectsResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_release_revision(
+ &self,
+ param_rev_id: String,
+ param_expand: Option<String>,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetReleaseRevisionResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/release/rev/{rev_id}",
+ self.base_path,
+ rev_id = utf8_percent_encode(&param_rev_id.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_expand) = param_expand {
+ query_string.append_pair("expand", &param_expand.to_string());
+ }
+ if let Some(param_hide) = param_hide {
+ query_string.append_pair("hide", &param_hide.to_string());
+ }
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ReleaseEntity>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| {
+ GetReleaseRevisionResponse::FoundEntityRevision(body)
+ }),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetReleaseRevisionResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetReleaseRevisionResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetReleaseRevisionResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_release_webcaptures(
+ &self,
+ param_ident: String,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetReleaseWebcapturesResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/release/{ident}/webcaptures",
+ self.base_path,
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_hide) = param_hide {
+ query_string.append_pair("hide", &param_hide.to_string());
+ }
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<Vec<models::WebcaptureEntity>>(
+ body,
+ )
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetReleaseWebcapturesResponse::Found(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetReleaseWebcapturesResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetReleaseWebcapturesResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetReleaseWebcapturesResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_webcapture(
+ &self,
+ param_ident: String,
+ param_expand: Option<String>,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetWebcaptureResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/webcapture/{ident}",
+ self.base_path,
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_expand) = param_expand {
+ query_string.append_pair("expand", &param_expand.to_string());
+ }
+ if let Some(param_hide) = param_hide {
+ query_string.append_pair("hide", &param_hide.to_string());
+ }
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::WebcaptureEntity>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetWebcaptureResponse::FoundEntity(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetWebcaptureResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetWebcaptureResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetWebcaptureResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_webcapture_edit(
+ &self,
+ param_edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetWebcaptureEditResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/webcapture/edit/{edit_id}",
+ self.base_path,
+ edit_id = utf8_percent_encode(&param_edit_id.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::EntityEdit>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetWebcaptureEditResponse::FoundEdit(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetWebcaptureEditResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetWebcaptureEditResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetWebcaptureEditResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_webcapture_history(
+ &self,
+ param_ident: String,
+ param_limit: Option<i64>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetWebcaptureHistoryResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/webcapture/{ident}/history",
+ self.base_path,
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_limit) = param_limit {
+ query_string.append_pair("limit", &param_limit.to_string());
+ }
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<Vec<models::EntityHistoryEntry>>(
+ body,
+ )
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| {
+ GetWebcaptureHistoryResponse::FoundEntityHistory(body)
+ }),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetWebcaptureHistoryResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetWebcaptureHistoryResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetWebcaptureHistoryResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_webcapture_redirects(
+ &self,
+ param_ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetWebcaptureRedirectsResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/webcapture/{ident}/redirects",
+ self.base_path,
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<Vec<String>>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| {
+ GetWebcaptureRedirectsResponse::FoundEntityRedirects(body)
+ }),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetWebcaptureRedirectsResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetWebcaptureRedirectsResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| {
+ GetWebcaptureRedirectsResponse::GenericError(body)
+ }),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_webcapture_revision(
+ &self,
+ param_rev_id: String,
+ param_expand: Option<String>,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetWebcaptureRevisionResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/webcapture/rev/{rev_id}",
+ self.base_path,
+ rev_id = utf8_percent_encode(&param_rev_id.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_expand) = param_expand {
+ query_string.append_pair("expand", &param_expand.to_string());
+ }
+ if let Some(param_hide) = param_hide {
+ query_string.append_pair("hide", &param_hide.to_string());
+ }
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::WebcaptureEntity>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| {
+ GetWebcaptureRevisionResponse::FoundEntityRevision(body)
+ }),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetWebcaptureRevisionResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetWebcaptureRevisionResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetWebcaptureRevisionResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_work(
+ &self,
+ param_ident: String,
+ param_expand: Option<String>,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetWorkResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/work/{ident}",
+ self.base_path,
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_expand) = param_expand {
+ query_string.append_pair("expand", &param_expand.to_string());
+ }
+ if let Some(param_hide) = param_hide {
+ query_string.append_pair("hide", &param_hide.to_string());
+ }
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::WorkEntity>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetWorkResponse::FoundEntity(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetWorkResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetWorkResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetWorkResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_work_edit(
+ &self,
+ param_edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetWorkEditResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/work/edit/{edit_id}",
+ self.base_path,
+ edit_id = utf8_percent_encode(&param_edit_id.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::EntityEdit>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetWorkEditResponse::FoundEdit(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetWorkEditResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetWorkEditResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetWorkEditResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_work_history(
+ &self,
+ param_ident: String,
+ param_limit: Option<i64>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetWorkHistoryResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/work/{ident}/history",
+ self.base_path,
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_limit) = param_limit {
+ query_string.append_pair("limit", &param_limit.to_string());
+ }
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<Vec<models::EntityHistoryEntry>>(
+ body,
+ )
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetWorkHistoryResponse::FoundEntityHistory(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetWorkHistoryResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetWorkHistoryResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetWorkHistoryResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_work_redirects(
+ &self,
+ param_ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetWorkRedirectsResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/work/{ident}/redirects",
+ self.base_path,
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<Vec<String>>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| {
+ GetWorkRedirectsResponse::FoundEntityRedirects(body)
+ }),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetWorkRedirectsResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetWorkRedirectsResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetWorkRedirectsResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_work_releases(
+ &self,
+ param_ident: String,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetWorkReleasesResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/work/{ident}/releases",
+ self.base_path,
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_hide) = param_hide {
+ query_string.append_pair("hide", &param_hide.to_string());
+ }
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<Vec<models::ReleaseEntity>>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetWorkReleasesResponse::Found(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetWorkReleasesResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetWorkReleasesResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetWorkReleasesResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn get_work_revision(
+ &self,
+ param_rev_id: String,
+ param_expand: Option<String>,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetWorkRevisionResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/work/rev/{rev_id}",
+ self.base_path,
+ rev_id = utf8_percent_encode(&param_rev_id.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_expand) = param_expand {
+ query_string.append_pair("expand", &param_expand.to_string());
+ }
+ if let Some(param_hide) = param_hide {
+ query_string.append_pair("hide", &param_hide.to_string());
+ }
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::WorkEntity>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| {
+ GetWorkRevisionResponse::FoundEntityRevision(body)
+ }),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetWorkRevisionResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetWorkRevisionResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| GetWorkRevisionResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn lookup_container(
+ &self,
+ param_issnl: Option<String>,
+ param_wikidata_qid: Option<String>,
+ param_expand: Option<String>,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = LookupContainerResponse, Error = ApiError> + Send> {
+ let mut uri = format!("{}/v0/container/lookup", self.base_path);
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_issnl) = param_issnl {
+ query_string.append_pair("issnl", &param_issnl.to_string());
+ }
+ if let Some(param_wikidata_qid) = param_wikidata_qid {
+ query_string.append_pair("wikidata_qid", &param_wikidata_qid.to_string());
+ }
+ if let Some(param_expand) = param_expand {
+ query_string.append_pair("expand", &param_expand.to_string());
+ }
+ if let Some(param_hide) = param_hide {
+ query_string.append_pair("hide", &param_hide.to_string());
+ }
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ContainerEntity>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| LookupContainerResponse::FoundEntity(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| LookupContainerResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| LookupContainerResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| LookupContainerResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn lookup_creator(
+ &self,
+ param_orcid: Option<String>,
+ param_wikidata_qid: Option<String>,
+ param_expand: Option<String>,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = LookupCreatorResponse, Error = ApiError> + Send> {
+ let mut uri = format!("{}/v0/creator/lookup", self.base_path);
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_orcid) = param_orcid {
+ query_string.append_pair("orcid", &param_orcid.to_string());
+ }
+ if let Some(param_wikidata_qid) = param_wikidata_qid {
+ query_string.append_pair("wikidata_qid", &param_wikidata_qid.to_string());
+ }
+ if let Some(param_expand) = param_expand {
+ query_string.append_pair("expand", &param_expand.to_string());
+ }
+ if let Some(param_hide) = param_hide {
+ query_string.append_pair("hide", &param_hide.to_string());
+ }
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::CreatorEntity>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| LookupCreatorResponse::FoundEntity(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| LookupCreatorResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| LookupCreatorResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| LookupCreatorResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn lookup_file(
+ &self,
+ param_md5: Option<String>,
+ param_sha1: Option<String>,
+ param_sha256: Option<String>,
+ param_expand: Option<String>,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = LookupFileResponse, Error = ApiError> + Send> {
+ let mut uri = format!("{}/v0/file/lookup", self.base_path);
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_md5) = param_md5 {
+ query_string.append_pair("md5", &param_md5.to_string());
+ }
+ if let Some(param_sha1) = param_sha1 {
+ query_string.append_pair("sha1", &param_sha1.to_string());
+ }
+ if let Some(param_sha256) = param_sha256 {
+ query_string.append_pair("sha256", &param_sha256.to_string());
+ }
+ if let Some(param_expand) = param_expand {
+ query_string.append_pair("expand", &param_expand.to_string());
+ }
+ if let Some(param_hide) = param_hide {
+ query_string.append_pair("hide", &param_hide.to_string());
+ }
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::FileEntity>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| LookupFileResponse::FoundEntity(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| LookupFileResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| LookupFileResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| LookupFileResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn lookup_release(
+ &self,
+ param_doi: Option<String>,
+ param_wikidata_qid: Option<String>,
+ param_isbn13: Option<String>,
+ param_pmid: Option<String>,
+ param_pmcid: Option<String>,
+ param_core: Option<String>,
+ param_arxiv: Option<String>,
+ param_jstor: Option<String>,
+ param_ark: Option<String>,
+ param_mag: Option<String>,
+ param_expand: Option<String>,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = LookupReleaseResponse, Error = ApiError> + Send> {
+ let mut uri = format!("{}/v0/release/lookup", self.base_path);
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_doi) = param_doi {
+ query_string.append_pair("doi", &param_doi.to_string());
+ }
+ if let Some(param_wikidata_qid) = param_wikidata_qid {
+ query_string.append_pair("wikidata_qid", &param_wikidata_qid.to_string());
+ }
+ if let Some(param_isbn13) = param_isbn13 {
+ query_string.append_pair("isbn13", &param_isbn13.to_string());
+ }
+ if let Some(param_pmid) = param_pmid {
+ query_string.append_pair("pmid", &param_pmid.to_string());
+ }
+ if let Some(param_pmcid) = param_pmcid {
+ query_string.append_pair("pmcid", &param_pmcid.to_string());
+ }
+ if let Some(param_core) = param_core {
+ query_string.append_pair("core", &param_core.to_string());
+ }
+ if let Some(param_arxiv) = param_arxiv {
+ query_string.append_pair("arxiv", &param_arxiv.to_string());
+ }
+ if let Some(param_jstor) = param_jstor {
+ query_string.append_pair("jstor", &param_jstor.to_string());
+ }
+ if let Some(param_ark) = param_ark {
+ query_string.append_pair("ark", &param_ark.to_string());
+ }
+ if let Some(param_mag) = param_mag {
+ query_string.append_pair("mag", &param_mag.to_string());
+ }
+ if let Some(param_expand) = param_expand {
+ query_string.append_pair("expand", &param_expand.to_string());
+ }
+ if let Some(param_hide) = param_hide {
+ query_string.append_pair("hide", &param_hide.to_string());
+ }
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ Box::new(
+ self.client_service
+ .request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ReleaseEntity>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| LookupReleaseResponse::FoundEntity(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| LookupReleaseResponse::BadRequest(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| LookupReleaseResponse::NotFound(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body.concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body| {
+ str::from_utf8(&body)
+ .map_err(|e| {
+ ApiError(format!("Response was not valid UTF8: {}", e))
+ })
+ .and_then(|body| {
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ })
+ })
+ .map(move |body| LookupReleaseResponse::GenericError(body)),
+ ) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body().take(100).concat2().then(move |body| {
+ future::err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) =>
+ Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ }
+ )))
+ })) as Box<dyn Future<Item = _, Error = _> + Send>
+ }
+ }),
+ )
+ }
+
+ fn update_container(
+ &self,
+ param_editgroup_id: String,
+ param_ident: String,
+ param_entity: models::ContainerEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = UpdateContainerResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/editgroup/{editgroup_id}/container/{ident}",
+ self.base_path,
+ editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), ID_ENCODE_SET),
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("PUT")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let body = serde_json::to_string(&param_entity).expect("impossible to fail to serialize");
+ *request.body_mut() = Body::from(body);
+
+ let header = "application/json";
+ request.headers_mut().insert(
+ CONTENT_TYPE,
+ match HeaderValue::from_str(header) {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ ))))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::EntityEdit>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateContainerResponse::UpdatedEntity
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateContainerResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateContainerResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateContainerResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateContainerResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateContainerResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn update_creator(
+ &self,
+ param_editgroup_id: String,
+ param_ident: String,
+ param_entity: models::CreatorEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = UpdateCreatorResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/editgroup/{editgroup_id}/creator/{ident}",
+ self.base_path,
+ editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), ID_ENCODE_SET),
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("PUT")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let body = serde_json::to_string(&param_entity).expect("impossible to fail to serialize");
+ *request.body_mut() = Body::from(body);
+
+ let header = "application/json";
+ request.headers_mut().insert(
+ CONTENT_TYPE,
+ match HeaderValue::from_str(header) {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ ))))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::EntityEdit>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateCreatorResponse::UpdatedEntity
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateCreatorResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateCreatorResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateCreatorResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateCreatorResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateCreatorResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn update_editgroup(
+ &self,
+ param_editgroup_id: String,
+ param_editgroup: models::Editgroup,
+ param_submit: Option<bool>,
+ context: &C,
+ ) -> Box<dyn Future<Item = UpdateEditgroupResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/editgroup/{editgroup_id}",
+ self.base_path,
+ editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_submit) = param_submit {
+ query_string.append_pair("submit", &param_submit.to_string());
+ }
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("PUT")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let body =
+ serde_json::to_string(&param_editgroup).expect("impossible to fail to serialize");
+ *request.body_mut() = Body::from(body);
+
+ let header = "application/json";
+ request.headers_mut().insert(
+ CONTENT_TYPE,
+ match HeaderValue::from_str(header) {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ ))))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::Editgroup>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateEditgroupResponse::UpdatedEditgroup
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateEditgroupResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateEditgroupResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateEditgroupResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateEditgroupResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateEditgroupResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn update_editor(
+ &self,
+ param_editor_id: String,
+ param_editor: models::Editor,
+ context: &C,
+ ) -> Box<dyn Future<Item = UpdateEditorResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/editor/{editor_id}",
+ self.base_path,
+ editor_id = utf8_percent_encode(&param_editor_id.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("PUT")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let body = serde_json::to_string(&param_editor).expect("impossible to fail to serialize");
+ *request.body_mut() = Body::from(body);
+
+ let header = "application/json";
+ request.headers_mut().insert(
+ CONTENT_TYPE,
+ match HeaderValue::from_str(header) {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ ))))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::Editor>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateEditorResponse::UpdatedEditor
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateEditorResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateEditorResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateEditorResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateEditorResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateEditorResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn update_file(
+ &self,
+ param_editgroup_id: String,
+ param_ident: String,
+ param_entity: models::FileEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = UpdateFileResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/editgroup/{editgroup_id}/file/{ident}",
+ self.base_path,
+ editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), ID_ENCODE_SET),
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("PUT")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let body = serde_json::to_string(&param_entity).expect("impossible to fail to serialize");
+ *request.body_mut() = Body::from(body);
+
+ let header = "application/json";
+ request.headers_mut().insert(
+ CONTENT_TYPE,
+ match HeaderValue::from_str(header) {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ ))))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::EntityEdit>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateFileResponse::UpdatedEntity
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateFileResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateFileResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateFileResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateFileResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateFileResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn update_fileset(
+ &self,
+ param_editgroup_id: String,
+ param_ident: String,
+ param_entity: models::FilesetEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = UpdateFilesetResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/editgroup/{editgroup_id}/fileset/{ident}",
+ self.base_path,
+ editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), ID_ENCODE_SET),
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("PUT")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let body = serde_json::to_string(&param_entity).expect("impossible to fail to serialize");
+ *request.body_mut() = Body::from(body);
+
+ let header = "application/json";
+ request.headers_mut().insert(
+ CONTENT_TYPE,
+ match HeaderValue::from_str(header) {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ ))))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::EntityEdit>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateFilesetResponse::UpdatedEntity
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateFilesetResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateFilesetResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateFilesetResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateFilesetResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateFilesetResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn update_release(
+ &self,
+ param_editgroup_id: String,
+ param_ident: String,
+ param_entity: models::ReleaseEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = UpdateReleaseResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/editgroup/{editgroup_id}/release/{ident}",
+ self.base_path,
+ editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), ID_ENCODE_SET),
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("PUT")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let body = serde_json::to_string(&param_entity).expect("impossible to fail to serialize");
+ *request.body_mut() = Body::from(body);
+
+ let header = "application/json";
+ request.headers_mut().insert(
+ CONTENT_TYPE,
+ match HeaderValue::from_str(header) {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ ))))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::EntityEdit>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateReleaseResponse::UpdatedEntity
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateReleaseResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateReleaseResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateReleaseResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateReleaseResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateReleaseResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn update_webcapture(
+ &self,
+ param_editgroup_id: String,
+ param_ident: String,
+ param_entity: models::WebcaptureEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = UpdateWebcaptureResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/editgroup/{editgroup_id}/webcapture/{ident}",
+ self.base_path,
+ editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), ID_ENCODE_SET),
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("PUT")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let body = serde_json::to_string(&param_entity).expect("impossible to fail to serialize");
+ *request.body_mut() = Body::from(body);
+
+ let header = "application/json";
+ request.headers_mut().insert(
+ CONTENT_TYPE,
+ match HeaderValue::from_str(header) {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ ))))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::EntityEdit>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateWebcaptureResponse::UpdatedEntity
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateWebcaptureResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateWebcaptureResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateWebcaptureResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateWebcaptureResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateWebcaptureResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+
+ fn update_work(
+ &self,
+ param_editgroup_id: String,
+ param_ident: String,
+ param_entity: models::WorkEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = UpdateWorkResponse, Error = ApiError> + Send> {
+ let mut uri = format!(
+ "{}/v0/editgroup/{editgroup_id}/work/{ident}",
+ self.base_path,
+ editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), ID_ENCODE_SET),
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
+ let query_string_str = query_string.finish();
+ if !query_string_str.is_empty() {
+ uri += "?";
+ uri += &query_string_str;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to build URI: {}",
+ err
+ ))))
+ }
+ };
+
+ let mut request = match hyper::Request::builder()
+ .method("PUT")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create request: {}",
+ e
+ ))))
+ }
+ };
+
+ let body = serde_json::to_string(&param_entity).expect("impossible to fail to serialize");
+
+ *request.body_mut() = Body::from(body);
+
+ let header = "application/json";
+ request.headers_mut().insert(
+ CONTENT_TYPE,
+ match HeaderValue::from_str(header) {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ ))))
+ }
+ },
+ );
+
+ let header = HeaderValue::from_str(
+ (context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ ))))
+ }
+ },
+ );
+
+ if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ _ => {}
+ }
+ }
+
+ Box::new(self.client_service.request(request)
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .and_then(|mut response| {
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::EntityEdit>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateWorkResponse::UpdatedEntity
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 400 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateWorkResponse::BadRequest
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 401 => {
+ let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) {
+ Some(response_www_authenticate) => response_www_authenticate.clone(),
+ None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box<dyn Future<Item=_, Error=_> + Send>,
+ };
+ let response_www_authenticate = match TryInto::<header::IntoHeaderValue<String>>::try_into(response_www_authenticate) {
+ Ok(value) => value,
+ Err(e) => {
+ return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box<dyn Future<Item=_, Error=_> + Send>;
+ },
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateWorkResponse::NotAuthorized
+ {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ }
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 403 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateWorkResponse::Forbidden
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 404 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateWorkResponse::NotFound
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ 500 => {
+ let body = response.into_body();
+ Box::new(
+ body
+ .concat2()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .and_then(|body|
+ str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
+ .and_then(|body|
+ serde_json::from_str::<models::ErrorResponse>(body)
+ .map_err(|e| e.into())
+ )
+ )
+ .map(move |body| {
+ UpdateWorkResponse::GenericError
+ (body)
+ })
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ },
+ code => {
+ let headers = response.headers().clone();
+ Box::new(response.into_body()
+ .take(100)
+ .concat2()
+ .then(move |body|
+ future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(ref body) => match str::from_utf8(body) {
+ Ok(body) => Cow::from(body),
+ Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ })))
+ )
+ ) as Box<dyn Future<Item=_, Error=_> + Send>
+ }
+ }
+ }))
+ }
+}
diff --git a/rust/fatcat-openapi/src/context.rs b/rust/fatcat-openapi/src/context.rs
new file mode 100644
index 00000000..1af57be1
--- /dev/null
+++ b/rust/fatcat-openapi/src/context.rs
@@ -0,0 +1,135 @@
+use crate::Api;
+use futures::Future;
+use hyper;
+use hyper::header::HeaderName;
+use hyper::{body::Payload, service::Service, Error, Request, Response, StatusCode};
+use std::default::Default;
+use std::io;
+use std::marker::PhantomData;
+use swagger::auth::{AuthData, Authorization, Bearer, Scopes};
+use swagger::context::ContextualPayload;
+use swagger::{EmptyContext, Has, Pop, Push, XSpanIdString};
+use url::form_urlencoded;
+
+pub struct MakeAddContext<T, A> {
+ inner: T,
+ marker: PhantomData<A>,
+}
+
+impl<T, A, B, C, D> MakeAddContext<T, A>
+where
+ A: Default + Push<XSpanIdString, Result = B>,
+ B: Push<Option<AuthData>, Result = C>,
+ C: Push<Option<Authorization>, Result = D>,
+{
+ pub fn new(inner: T) -> MakeAddContext<T, A> {
+ MakeAddContext {
+ inner,
+ marker: PhantomData,
+ }
+ }
+}
+
+// Make a service that adds context.
+impl<'a, T, SC, A, B, C, D, E, ME, S, OB, F> hyper::service::MakeService<&'a SC>
+ for MakeAddContext<T, A>
+where
+ A: Default + Push<XSpanIdString, Result = B>,
+ B: Push<Option<AuthData>, Result = C>,
+ C: Push<Option<Authorization>, Result = D>,
+ D: Send + 'static,
+ T: hyper::service::MakeService<
+ &'a SC,
+ Error = E,
+ MakeError = ME,
+ Service = S,
+ ReqBody = ContextualPayload<hyper::Body, D>,
+ ResBody = OB,
+ Future = F,
+ >,
+ S: Service<Error = E, ReqBody = ContextualPayload<hyper::Body, D>, ResBody = OB> + 'static,
+ ME: swagger::ErrorBound,
+ E: swagger::ErrorBound,
+ F: Future<Item = S, Error = ME> + Send + 'static,
+ S::Future: Send,
+ OB: Payload,
+{
+ type ReqBody = hyper::Body;
+ type ResBody = OB;
+ type Error = E;
+ type MakeError = ME;
+ type Service = AddContext<S, A>;
+ type Future = Box<dyn Future<Item = Self::Service, Error = ME> + Send + 'static>;
+
+ fn make_service(&mut self, ctx: &'a SC) -> Self::Future {
+ Box::new(self.inner.make_service(ctx).map(|s| AddContext::new(s)))
+ }
+}
+
+/// Middleware to extract authentication data from request
+pub struct AddContext<T, A> {
+ inner: T,
+ marker: PhantomData<A>,
+}
+
+impl<T, A, B, C, D> AddContext<T, A>
+where
+ A: Default + Push<XSpanIdString, Result = B>,
+ B: Push<Option<AuthData>, Result = C>,
+ C: Push<Option<Authorization>, Result = D>,
+ T: Service,
+{
+ pub fn new(inner: T) -> AddContext<T, A> {
+ AddContext {
+ inner,
+ marker: PhantomData,
+ }
+ }
+}
+
+impl<T, A, B, C, D> Service for AddContext<T, A>
+where
+ A: Default + Push<XSpanIdString, Result = B>,
+ B: Push<Option<AuthData>, Result = C>,
+ C: Push<Option<Authorization>, Result = D>,
+ D: Send + 'static,
+ T: Service<ReqBody = ContextualPayload<hyper::Body, D>>,
+ T::Future: Future<Item = Response<T::ResBody>, Error = T::Error> + Send + 'static,
+{
+ type ReqBody = hyper::Body;
+ type ResBody = T::ResBody;
+ type Error = T::Error;
+ type Future = Box<dyn Future<Item = Response<T::ResBody>, Error = T::Error> + Send + 'static>;
+
+ fn call(&mut self, req: Request<Self::ReqBody>) -> Self::Future {
+ let context = A::default().push(XSpanIdString::get_or_generate(&req));
+ let (head, body) = req.into_parts();
+ let headers = head.headers.clone();
+
+ {
+ use swagger::auth::api_key_from_header;
+
+ if let Some(header) = api_key_from_header(&headers, "Authorization") {
+ let auth_data = AuthData::ApiKey(header);
+ let context = context.push(Some(auth_data));
+ let context = context.push(None::<Authorization>);
+
+ let body = ContextualPayload {
+ inner: body,
+ context: context,
+ };
+
+ return Box::new(self.inner.call(hyper::Request::from_parts(head, body)));
+ }
+ }
+
+ let context = context.push(None::<AuthData>);
+ let context = context.push(None::<Authorization>);
+ let body = ContextualPayload {
+ inner: body,
+ context: context,
+ };
+
+ Box::new(self.inner.call(hyper::Request::from_parts(head, body)))
+ }
+}
diff --git a/rust/fatcat-openapi/src/header.rs b/rust/fatcat-openapi/src/header.rs
new file mode 100644
index 00000000..7589ab08
--- /dev/null
+++ b/rust/fatcat-openapi/src/header.rs
@@ -0,0 +1,197 @@
+use chrono::{DateTime, Utc};
+use hyper::header::HeaderValue;
+use std::convert::TryFrom;
+use std::fmt;
+use std::ops::Deref;
+
+/// A struct to allow homogeneous conversion into a HeaderValue. We can't
+/// implement the From/Into trait on HeaderValue because we don't own
+/// either of the types.
+#[derive(Debug, Clone)]
+pub(crate) struct IntoHeaderValue<T>(pub T);
+
+// Generic implementations
+
+impl<T> Deref for IntoHeaderValue<T> {
+ type Target = T;
+
+ fn deref(&self) -> &T {
+ &self.0
+ }
+}
+
+// Derive for each TryFrom<T> in hyper::header::HeaderValue
+
+macro_rules! ihv_generate {
+ ($t:ident) => {
+ impl TryFrom<HeaderValue> for IntoHeaderValue<$t> {
+ type Error = String;
+
+ fn try_from(hdr_value: HeaderValue) -> Result<Self, Self::Error> {
+ match hdr_value.to_str() {
+ Ok(hdr_value) => match hdr_value.parse::<$t>() {
+ Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
+ Err(e) => Err(format!(
+ "Unable to parse {} as a string: {}",
+ stringify!($t),
+ e
+ )),
+ },
+ Err(e) => Err(format!(
+ "Unable to parse header {:?} as a string - {}",
+ hdr_value, e
+ )),
+ }
+ }
+ }
+
+ impl TryFrom<IntoHeaderValue<$t>> for HeaderValue {
+ type Error = String;
+
+ fn try_from(hdr_value: IntoHeaderValue<$t>) -> Result<Self, Self::Error> {
+ Ok(hdr_value.0.into())
+ }
+ }
+ };
+}
+
+ihv_generate!(u64);
+ihv_generate!(i64);
+ihv_generate!(i16);
+ihv_generate!(u16);
+ihv_generate!(u32);
+ihv_generate!(usize);
+ihv_generate!(isize);
+ihv_generate!(i32);
+
+// Custom derivations
+
+// Vec<String>
+
+impl TryFrom<HeaderValue> for IntoHeaderValue<Vec<String>> {
+ type Error = String;
+
+ fn try_from(hdr_value: HeaderValue) -> Result<Self, Self::Error> {
+ match hdr_value.to_str() {
+ Ok(hdr_value) => Ok(IntoHeaderValue(
+ hdr_value
+ .split(',')
+ .filter_map(|x| match x.trim() {
+ "" => None,
+ y => Some(y.to_string()),
+ })
+ .collect(),
+ )),
+ Err(e) => Err(format!(
+ "Unable to parse header: {:?} as a string - {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+impl TryFrom<IntoHeaderValue<Vec<String>>> for HeaderValue {
+ type Error = String;
+
+ fn try_from(hdr_value: IntoHeaderValue<Vec<String>>) -> Result<Self, Self::Error> {
+ match HeaderValue::from_str(&hdr_value.0.join(", ")) {
+ Ok(hdr_value) => Ok(hdr_value),
+ Err(e) => Err(format!(
+ "Unable to convert {:?} into a header - {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+// String
+
+impl TryFrom<HeaderValue> for IntoHeaderValue<String> {
+ type Error = String;
+
+ fn try_from(hdr_value: HeaderValue) -> Result<Self, Self::Error> {
+ match hdr_value.to_str() {
+ Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value.to_string())),
+ Err(e) => Err(format!("Unable to convert header {:?} to {}", hdr_value, e)),
+ }
+ }
+}
+
+impl TryFrom<IntoHeaderValue<String>> for HeaderValue {
+ type Error = String;
+
+ fn try_from(hdr_value: IntoHeaderValue<String>) -> Result<Self, Self::Error> {
+ match HeaderValue::from_str(&hdr_value.0) {
+ Ok(hdr_value) => Ok(hdr_value),
+ Err(e) => Err(format!(
+ "Unable to convert {:?} from a header {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+// bool
+impl TryFrom<HeaderValue> for IntoHeaderValue<bool> {
+ type Error = String;
+
+ fn try_from(hdr_value: HeaderValue) -> Result<Self, Self::Error> {
+ match hdr_value.to_str() {
+ Ok(hdr_value) => match hdr_value.parse() {
+ Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
+ Err(e) => Err(format!("Unable to parse bool from {} - {}", hdr_value, e)),
+ },
+ Err(e) => Err(format!(
+ "Unable to convert {:?} from a header {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+impl TryFrom<IntoHeaderValue<bool>> for HeaderValue {
+ type Error = String;
+
+ fn try_from(hdr_value: IntoHeaderValue<bool>) -> Result<Self, Self::Error> {
+ match HeaderValue::from_str(&hdr_value.0.to_string()) {
+ Ok(hdr_value) => Ok(hdr_value),
+ Err(e) => Err(format!(
+ "Unable to convert: {:?} into a header: {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+// DateTime
+
+impl TryFrom<HeaderValue> for IntoHeaderValue<DateTime<Utc>> {
+ type Error = String;
+
+ fn try_from(hdr_value: HeaderValue) -> Result<Self, Self::Error> {
+ match hdr_value.to_str() {
+ Ok(hdr_value) => match DateTime::parse_from_rfc3339(hdr_value) {
+ Ok(date) => Ok(IntoHeaderValue(date.with_timezone(&Utc))),
+ Err(e) => Err(format!("Unable to parse: {} as date - {}", hdr_value, e)),
+ },
+ Err(e) => Err(format!(
+ "Unable to convert header {:?} to string {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+impl TryFrom<IntoHeaderValue<DateTime<Utc>>> for HeaderValue {
+ type Error = String;
+
+ fn try_from(hdr_value: IntoHeaderValue<DateTime<Utc>>) -> Result<Self, Self::Error> {
+ match HeaderValue::from_str(hdr_value.0.to_rfc3339().as_str()) {
+ Ok(hdr_value) => Ok(hdr_value),
+ Err(e) => Err(format!(
+ "Unable to convert {:?} to a header: {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
diff --git a/rust/fatcat-openapi/src/lib.rs b/rust/fatcat-openapi/src/lib.rs
index 59255193..164c0beb 100644
--- a/rust/fatcat-openapi/src/lib.rs
+++ b/rust/fatcat-openapi/src/lib.rs
@@ -1,45 +1,58 @@
-#![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;
+#![allow(
+ missing_docs,
+ trivial_casts,
+ unused_variables,
+ unused_mut,
+ unused_imports,
+ unused_extern_crates,
+ non_camel_case_types
+)]
use futures::Stream;
use std::io::Error;
-#[allow(unused_imports)]
-use std::collections::HashMap;
-
+#[deprecated(note = "Import futures directly")]
pub use futures::Future;
+#[deprecated(note = "Import swagger-rs directly")]
+pub use swagger::{ApiError, ContextWrapper};
-#[cfg(any(feature = "client", feature = "server"))]
-mod mimetypes;
+pub const BASE_PATH: &'static str = "/v0";
+pub const API_VERSION: &'static str = "0.3.1";
-pub use swagger::{ApiError, Context, ContextWrapper};
+#[derive(Debug, PartialEq)]
+#[must_use]
+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)]
+#[must_use]
pub enum AuthCheckResponse {
/// Success
Success(models::Success),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Authorized
- NotAuthorized { body: models::ErrorResponse, www_authenticate: String },
+ NotAuthorized {
+ body: models::ErrorResponse,
+ www_authenticate: String,
+ },
/// Forbidden
Forbidden(models::ErrorResponse),
/// Generic Error
@@ -47,6 +60,7 @@ pub enum AuthCheckResponse {
}
#[derive(Debug, PartialEq)]
+#[must_use]
pub enum AuthOidcResponse {
/// Found
Found(models::AuthOidcResult),
@@ -55,7 +69,10 @@ pub enum AuthOidcResponse {
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Authorized
- NotAuthorized { body: models::ErrorResponse, www_authenticate: String },
+ NotAuthorized {
+ body: models::ErrorResponse,
+ www_authenticate: String,
+ },
/// Forbidden
Forbidden(models::ErrorResponse),
/// Conflict
@@ -65,13 +82,17 @@ pub enum AuthOidcResponse {
}
#[derive(Debug, PartialEq)]
+#[must_use]
pub enum CreateAuthTokenResponse {
/// Success
Success(models::AuthTokenResult),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Authorized
- NotAuthorized { body: models::ErrorResponse, www_authenticate: String },
+ NotAuthorized {
+ body: models::ErrorResponse,
+ www_authenticate: String,
+ },
/// Forbidden
Forbidden(models::ErrorResponse),
/// Generic Error
@@ -79,35 +100,17 @@ pub enum CreateAuthTokenResponse {
}
#[derive(Debug, PartialEq)]
-pub enum GetChangelogResponse {
- /// Success
- Success(Vec<models::ChangelogEntry>),
- /// 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)]
+#[must_use]
pub enum CreateContainerResponse {
/// Created Entity
CreatedEntity(models::EntityEdit),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Authorized
- NotAuthorized { body: models::ErrorResponse, www_authenticate: String },
+ NotAuthorized {
+ body: models::ErrorResponse,
+ www_authenticate: String,
+ },
/// Forbidden
Forbidden(models::ErrorResponse),
/// Not Found
@@ -117,13 +120,17 @@ pub enum CreateContainerResponse {
}
#[derive(Debug, PartialEq)]
+#[must_use]
pub enum CreateContainerAutoBatchResponse {
/// Created Editgroup
CreatedEditgroup(models::Editgroup),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Authorized
- NotAuthorized { body: models::ErrorResponse, www_authenticate: String },
+ NotAuthorized {
+ body: models::ErrorResponse,
+ www_authenticate: String,
+ },
/// Forbidden
Forbidden(models::ErrorResponse),
/// Not Found
@@ -133,13 +140,17 @@ pub enum CreateContainerAutoBatchResponse {
}
#[derive(Debug, PartialEq)]
-pub enum DeleteContainerResponse {
- /// Deleted Entity
- DeletedEntity(models::EntityEdit),
+#[must_use]
+pub enum CreateCreatorResponse {
+ /// Created Entity
+ CreatedEntity(models::EntityEdit),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Authorized
- NotAuthorized { body: models::ErrorResponse, www_authenticate: String },
+ NotAuthorized {
+ body: models::ErrorResponse,
+ www_authenticate: String,
+ },
/// Forbidden
Forbidden(models::ErrorResponse),
/// Not Found
@@ -149,13 +160,17 @@ pub enum DeleteContainerResponse {
}
#[derive(Debug, PartialEq)]
-pub enum DeleteContainerEditResponse {
- /// Deleted Edit
- DeletedEdit(models::Success),
+#[must_use]
+pub enum CreateCreatorAutoBatchResponse {
+ /// Created Editgroup
+ CreatedEditgroup(models::Editgroup),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Authorized
- NotAuthorized { body: models::ErrorResponse, www_authenticate: String },
+ NotAuthorized {
+ body: models::ErrorResponse,
+ www_authenticate: String,
+ },
/// Forbidden
Forbidden(models::ErrorResponse),
/// Not Found
@@ -165,23 +180,19 @@ pub enum DeleteContainerEditResponse {
}
#[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),
+#[must_use]
+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
@@ -189,11 +200,19 @@ pub enum GetContainerEditResponse {
}
#[derive(Debug, PartialEq)]
-pub enum GetContainerHistoryResponse {
- /// Found Entity History
- FoundEntityHistory(Vec<models::EntityHistoryEntry>),
+#[must_use]
+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
@@ -201,11 +220,19 @@ pub enum GetContainerHistoryResponse {
}
#[derive(Debug, PartialEq)]
-pub enum GetContainerRedirectsResponse {
- /// Found Entity Redirects
- FoundEntityRedirects(Vec<String>),
+#[must_use]
+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
@@ -213,11 +240,19 @@ pub enum GetContainerRedirectsResponse {
}
#[derive(Debug, PartialEq)]
-pub enum GetContainerRevisionResponse {
- /// Found Entity Revision
- FoundEntityRevision(models::ContainerEntity),
+#[must_use]
+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
@@ -225,11 +260,19 @@ pub enum GetContainerRevisionResponse {
}
#[derive(Debug, PartialEq)]
-pub enum LookupContainerResponse {
- /// Found Entity
- FoundEntity(models::ContainerEntity),
+#[must_use]
+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
@@ -237,13 +280,17 @@ pub enum LookupContainerResponse {
}
#[derive(Debug, PartialEq)]
-pub enum UpdateContainerResponse {
- /// Updated Entity
- UpdatedEntity(models::EntityEdit),
+#[must_use]
+pub enum CreateFilesetAutoBatchResponse {
+ /// Created Editgroup
+ CreatedEditgroup(models::Editgroup),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Authorized
- NotAuthorized { body: models::ErrorResponse, www_authenticate: String },
+ NotAuthorized {
+ body: models::ErrorResponse,
+ www_authenticate: String,
+ },
/// Forbidden
Forbidden(models::ErrorResponse),
/// Not Found
@@ -253,13 +300,17 @@ pub enum UpdateContainerResponse {
}
#[derive(Debug, PartialEq)]
-pub enum CreateCreatorResponse {
+#[must_use]
+pub enum CreateReleaseResponse {
/// Created Entity
CreatedEntity(models::EntityEdit),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Authorized
- NotAuthorized { body: models::ErrorResponse, www_authenticate: String },
+ NotAuthorized {
+ body: models::ErrorResponse,
+ www_authenticate: String,
+ },
/// Forbidden
Forbidden(models::ErrorResponse),
/// Not Found
@@ -269,13 +320,17 @@ pub enum CreateCreatorResponse {
}
#[derive(Debug, PartialEq)]
-pub enum CreateCreatorAutoBatchResponse {
+#[must_use]
+pub enum CreateReleaseAutoBatchResponse {
/// Created Editgroup
CreatedEditgroup(models::Editgroup),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Authorized
- NotAuthorized { body: models::ErrorResponse, www_authenticate: String },
+ NotAuthorized {
+ body: models::ErrorResponse,
+ www_authenticate: String,
+ },
/// Forbidden
Forbidden(models::ErrorResponse),
/// Not Found
@@ -285,13 +340,17 @@ pub enum CreateCreatorAutoBatchResponse {
}
#[derive(Debug, PartialEq)]
-pub enum DeleteCreatorResponse {
- /// Deleted Entity
- DeletedEntity(models::EntityEdit),
+#[must_use]
+pub enum CreateWebcaptureResponse {
+ /// Created Entity
+ CreatedEntity(models::EntityEdit),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Authorized
- NotAuthorized { body: models::ErrorResponse, www_authenticate: String },
+ NotAuthorized {
+ body: models::ErrorResponse,
+ www_authenticate: String,
+ },
/// Forbidden
Forbidden(models::ErrorResponse),
/// Not Found
@@ -301,13 +360,17 @@ pub enum DeleteCreatorResponse {
}
#[derive(Debug, PartialEq)]
-pub enum DeleteCreatorEditResponse {
- /// Deleted Edit
- DeletedEdit(models::Success),
+#[must_use]
+pub enum CreateWebcaptureAutoBatchResponse {
+ /// Created Editgroup
+ CreatedEditgroup(models::Editgroup),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Authorized
- NotAuthorized { body: models::ErrorResponse, www_authenticate: String },
+ NotAuthorized {
+ body: models::ErrorResponse,
+ www_authenticate: String,
+ },
/// Forbidden
Forbidden(models::ErrorResponse),
/// Not Found
@@ -317,11 +380,19 @@ pub enum DeleteCreatorEditResponse {
}
#[derive(Debug, PartialEq)]
-pub enum GetCreatorResponse {
- /// Found Entity
- FoundEntity(models::CreatorEntity),
+#[must_use]
+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
@@ -329,11 +400,19 @@ pub enum GetCreatorResponse {
}
#[derive(Debug, PartialEq)]
-pub enum GetCreatorEditResponse {
- /// Found Edit
- FoundEdit(models::EntityEdit),
+#[must_use]
+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
@@ -341,11 +420,19 @@ pub enum GetCreatorEditResponse {
}
#[derive(Debug, PartialEq)]
-pub enum GetCreatorHistoryResponse {
- /// Found Entity History
- FoundEntityHistory(Vec<models::EntityHistoryEntry>),
+#[must_use]
+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
@@ -353,11 +440,19 @@ pub enum GetCreatorHistoryResponse {
}
#[derive(Debug, PartialEq)]
-pub enum GetCreatorRedirectsResponse {
- /// Found Entity Redirects
- FoundEntityRedirects(Vec<String>),
+#[must_use]
+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
@@ -365,11 +460,19 @@ pub enum GetCreatorRedirectsResponse {
}
#[derive(Debug, PartialEq)]
-pub enum GetCreatorReleasesResponse {
- /// Found
- Found(Vec<models::ReleaseEntity>),
+#[must_use]
+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
@@ -377,11 +480,19 @@ pub enum GetCreatorReleasesResponse {
}
#[derive(Debug, PartialEq)]
-pub enum GetCreatorRevisionResponse {
- /// Found Entity Revision
- FoundEntityRevision(models::CreatorEntity),
+#[must_use]
+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
@@ -389,11 +500,19 @@ pub enum GetCreatorRevisionResponse {
}
#[derive(Debug, PartialEq)]
-pub enum LookupCreatorResponse {
- /// Found Entity
- FoundEntity(models::CreatorEntity),
+#[must_use]
+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
@@ -401,13 +520,17 @@ pub enum LookupCreatorResponse {
}
#[derive(Debug, PartialEq)]
-pub enum UpdateCreatorResponse {
- /// Updated Entity
- UpdatedEntity(models::EntityEdit),
+#[must_use]
+pub enum DeleteFileEditResponse {
+ /// Deleted Edit
+ DeletedEdit(models::Success),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Authorized
- NotAuthorized { body: models::ErrorResponse, www_authenticate: String },
+ NotAuthorized {
+ body: models::ErrorResponse,
+ www_authenticate: String,
+ },
/// Forbidden
Forbidden(models::ErrorResponse),
/// Not Found
@@ -417,31 +540,37 @@ pub enum UpdateCreatorResponse {
}
#[derive(Debug, PartialEq)]
-pub enum AcceptEditgroupResponse {
- /// Merged Successfully
- MergedSuccessfully(models::Success),
+#[must_use]
+pub enum DeleteFilesetResponse {
+ /// Deleted Entity
+ DeletedEntity(models::EntityEdit),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Authorized
- NotAuthorized { body: models::ErrorResponse, www_authenticate: String },
+ 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),
+#[must_use]
+pub enum DeleteFilesetEditResponse {
+ /// Deleted Edit
+ DeletedEdit(models::Success),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Authorized
- NotAuthorized { body: models::ErrorResponse, www_authenticate: String },
+ NotAuthorized {
+ body: models::ErrorResponse,
+ www_authenticate: String,
+ },
/// Forbidden
Forbidden(models::ErrorResponse),
/// Not Found
@@ -451,13 +580,17 @@ pub enum CreateEditgroupResponse {
}
#[derive(Debug, PartialEq)]
-pub enum CreateEditgroupAnnotationResponse {
- /// Created
- Created(models::EditgroupAnnotation),
+#[must_use]
+pub enum DeleteReleaseResponse {
+ /// Deleted Entity
+ DeletedEntity(models::EntityEdit),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Authorized
- NotAuthorized { body: models::ErrorResponse, www_authenticate: String },
+ NotAuthorized {
+ body: models::ErrorResponse,
+ www_authenticate: String,
+ },
/// Forbidden
Forbidden(models::ErrorResponse),
/// Not Found
@@ -467,11 +600,19 @@ pub enum CreateEditgroupAnnotationResponse {
}
#[derive(Debug, PartialEq)]
-pub enum GetEditgroupResponse {
- /// Found
- Found(models::Editgroup),
+#[must_use]
+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
@@ -479,13 +620,17 @@ pub enum GetEditgroupResponse {
}
#[derive(Debug, PartialEq)]
-pub enum GetEditgroupAnnotationsResponse {
- /// Success
- Success(Vec<models::EditgroupAnnotation>),
+#[must_use]
+pub enum DeleteWebcaptureResponse {
+ /// Deleted Entity
+ DeletedEntity(models::EntityEdit),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Authorized
- NotAuthorized { body: models::ErrorResponse, www_authenticate: String },
+ NotAuthorized {
+ body: models::ErrorResponse,
+ www_authenticate: String,
+ },
/// Forbidden
Forbidden(models::ErrorResponse),
/// Not Found
@@ -495,11 +640,19 @@ pub enum GetEditgroupAnnotationsResponse {
}
#[derive(Debug, PartialEq)]
-pub enum GetEditgroupsReviewableResponse {
- /// Found
- Found(Vec<models::Editgroup>),
+#[must_use]
+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
@@ -507,13 +660,17 @@ pub enum GetEditgroupsReviewableResponse {
}
#[derive(Debug, PartialEq)]
-pub enum UpdateEditgroupResponse {
- /// Updated Editgroup
- UpdatedEditgroup(models::Editgroup),
+#[must_use]
+pub enum DeleteWorkResponse {
+ /// Deleted Entity
+ DeletedEntity(models::EntityEdit),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Authorized
- NotAuthorized { body: models::ErrorResponse, www_authenticate: String },
+ NotAuthorized {
+ body: models::ErrorResponse,
+ www_authenticate: String,
+ },
/// Forbidden
Forbidden(models::ErrorResponse),
/// Not Found
@@ -523,11 +680,19 @@ pub enum UpdateEditgroupResponse {
}
#[derive(Debug, PartialEq)]
-pub enum GetEditorResponse {
- /// Found
- Found(models::Editor),
+#[must_use]
+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
@@ -535,25 +700,21 @@ pub enum GetEditorResponse {
}
#[derive(Debug, PartialEq)]
-pub enum GetEditorAnnotationsResponse {
+#[must_use]
+pub enum GetChangelogResponse {
/// Success
- Success(Vec<models::EditgroupAnnotation>),
+ Success(Vec<models::ChangelogEntry>),
/// 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 GetEditorEditgroupsResponse {
- /// Found
- Found(Vec<models::Editgroup>),
+#[must_use]
+pub enum GetChangelogEntryResponse {
+ /// Found Changelog Entry
+ FoundChangelogEntry(models::ChangelogEntry),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Found
@@ -563,15 +724,12 @@ pub enum GetEditorEditgroupsResponse {
}
#[derive(Debug, PartialEq)]
-pub enum UpdateEditorResponse {
- /// Updated Editor
- UpdatedEditor(models::Editor),
+#[must_use]
+pub enum GetContainerResponse {
+ /// Found Entity
+ FoundEntity(models::ContainerEntity),
/// 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
@@ -579,15 +737,12 @@ pub enum UpdateEditorResponse {
}
#[derive(Debug, PartialEq)]
-pub enum CreateFileResponse {
- /// Created Entity
- CreatedEntity(models::EntityEdit),
+#[must_use]
+pub enum GetContainerEditResponse {
+ /// Found Edit
+ FoundEdit(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
@@ -595,15 +750,12 @@ pub enum CreateFileResponse {
}
#[derive(Debug, PartialEq)]
-pub enum CreateFileAutoBatchResponse {
- /// Created Editgroup
- CreatedEditgroup(models::Editgroup),
+#[must_use]
+pub enum GetContainerHistoryResponse {
+ /// Found Entity History
+ FoundEntityHistory(Vec<models::EntityHistoryEntry>),
/// 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
@@ -611,15 +763,12 @@ pub enum CreateFileAutoBatchResponse {
}
#[derive(Debug, PartialEq)]
-pub enum DeleteFileResponse {
- /// Deleted Entity
- DeletedEntity(models::EntityEdit),
+#[must_use]
+pub enum GetContainerRedirectsResponse {
+ /// Found Entity Redirects
+ FoundEntityRedirects(Vec<String>),
/// 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
@@ -627,15 +776,12 @@ pub enum DeleteFileResponse {
}
#[derive(Debug, PartialEq)]
-pub enum DeleteFileEditResponse {
- /// Deleted Edit
- DeletedEdit(models::Success),
+#[must_use]
+pub enum GetContainerRevisionResponse {
+ /// Found Entity Revision
+ FoundEntityRevision(models::ContainerEntity),
/// 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
@@ -643,9 +789,10 @@ pub enum DeleteFileEditResponse {
}
#[derive(Debug, PartialEq)]
-pub enum GetFileResponse {
+#[must_use]
+pub enum GetCreatorResponse {
/// Found Entity
- FoundEntity(models::FileEntity),
+ FoundEntity(models::CreatorEntity),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Found
@@ -655,7 +802,8 @@ pub enum GetFileResponse {
}
#[derive(Debug, PartialEq)]
-pub enum GetFileEditResponse {
+#[must_use]
+pub enum GetCreatorEditResponse {
/// Found Edit
FoundEdit(models::EntityEdit),
/// Bad Request
@@ -667,7 +815,8 @@ pub enum GetFileEditResponse {
}
#[derive(Debug, PartialEq)]
-pub enum GetFileHistoryResponse {
+#[must_use]
+pub enum GetCreatorHistoryResponse {
/// Found Entity History
FoundEntityHistory(Vec<models::EntityHistoryEntry>),
/// Bad Request
@@ -679,7 +828,8 @@ pub enum GetFileHistoryResponse {
}
#[derive(Debug, PartialEq)]
-pub enum GetFileRedirectsResponse {
+#[must_use]
+pub enum GetCreatorRedirectsResponse {
/// Found Entity Redirects
FoundEntityRedirects(Vec<String>),
/// Bad Request
@@ -691,9 +841,23 @@ pub enum GetFileRedirectsResponse {
}
#[derive(Debug, PartialEq)]
-pub enum GetFileRevisionResponse {
+#[must_use]
+pub enum GetCreatorReleasesResponse {
+ /// Found
+ Found(Vec<models::ReleaseEntity>),
+ /// Bad Request
+ BadRequest(models::ErrorResponse),
+ /// Not Found
+ NotFound(models::ErrorResponse),
+ /// Generic Error
+ GenericError(models::ErrorResponse),
+}
+
+#[derive(Debug, PartialEq)]
+#[must_use]
+pub enum GetCreatorRevisionResponse {
/// Found Entity Revision
- FoundEntityRevision(models::FileEntity),
+ FoundEntityRevision(models::CreatorEntity),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Found
@@ -703,9 +867,10 @@ pub enum GetFileRevisionResponse {
}
#[derive(Debug, PartialEq)]
-pub enum LookupFileResponse {
- /// Found Entity
- FoundEntity(models::FileEntity),
+#[must_use]
+pub enum GetEditgroupResponse {
+ /// Found
+ Found(models::Editgroup),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Found
@@ -715,13 +880,17 @@ pub enum LookupFileResponse {
}
#[derive(Debug, PartialEq)]
-pub enum UpdateFileResponse {
- /// Updated Entity
- UpdatedEntity(models::EntityEdit),
+#[must_use]
+pub enum GetEditgroupAnnotationsResponse {
+ /// Success
+ Success(Vec<models::EditgroupAnnotation>),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Authorized
- NotAuthorized { body: models::ErrorResponse, www_authenticate: String },
+ NotAuthorized {
+ body: models::ErrorResponse,
+ www_authenticate: String,
+ },
/// Forbidden
Forbidden(models::ErrorResponse),
/// Not Found
@@ -731,15 +900,12 @@ pub enum UpdateFileResponse {
}
#[derive(Debug, PartialEq)]
-pub enum CreateFilesetResponse {
- /// Created Entity
- CreatedEntity(models::EntityEdit),
+#[must_use]
+pub enum GetEditgroupsReviewableResponse {
+ /// Found
+ Found(Vec<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
@@ -747,15 +913,12 @@ pub enum CreateFilesetResponse {
}
#[derive(Debug, PartialEq)]
-pub enum CreateFilesetAutoBatchResponse {
- /// Created Editgroup
- CreatedEditgroup(models::Editgroup),
+#[must_use]
+pub enum GetEditorResponse {
+ /// Found
+ Found(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
@@ -763,13 +926,17 @@ pub enum CreateFilesetAutoBatchResponse {
}
#[derive(Debug, PartialEq)]
-pub enum DeleteFilesetResponse {
- /// Deleted Entity
- DeletedEntity(models::EntityEdit),
+#[must_use]
+pub enum GetEditorAnnotationsResponse {
+ /// Success
+ Success(Vec<models::EditgroupAnnotation>),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Authorized
- NotAuthorized { body: models::ErrorResponse, www_authenticate: String },
+ NotAuthorized {
+ body: models::ErrorResponse,
+ www_authenticate: String,
+ },
/// Forbidden
Forbidden(models::ErrorResponse),
/// Not Found
@@ -779,15 +946,12 @@ pub enum DeleteFilesetResponse {
}
#[derive(Debug, PartialEq)]
-pub enum DeleteFilesetEditResponse {
- /// Deleted Edit
- DeletedEdit(models::Success),
+#[must_use]
+pub enum GetEditorEditgroupsResponse {
+ /// Found
+ Found(Vec<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
@@ -795,9 +959,10 @@ pub enum DeleteFilesetEditResponse {
}
#[derive(Debug, PartialEq)]
-pub enum GetFilesetResponse {
+#[must_use]
+pub enum GetFileResponse {
/// Found Entity
- FoundEntity(models::FilesetEntity),
+ FoundEntity(models::FileEntity),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Found
@@ -807,7 +972,8 @@ pub enum GetFilesetResponse {
}
#[derive(Debug, PartialEq)]
-pub enum GetFilesetEditResponse {
+#[must_use]
+pub enum GetFileEditResponse {
/// Found Edit
FoundEdit(models::EntityEdit),
/// Bad Request
@@ -819,7 +985,8 @@ pub enum GetFilesetEditResponse {
}
#[derive(Debug, PartialEq)]
-pub enum GetFilesetHistoryResponse {
+#[must_use]
+pub enum GetFileHistoryResponse {
/// Found Entity History
FoundEntityHistory(Vec<models::EntityHistoryEntry>),
/// Bad Request
@@ -831,7 +998,8 @@ pub enum GetFilesetHistoryResponse {
}
#[derive(Debug, PartialEq)]
-pub enum GetFilesetRedirectsResponse {
+#[must_use]
+pub enum GetFileRedirectsResponse {
/// Found Entity Redirects
FoundEntityRedirects(Vec<String>),
/// Bad Request
@@ -843,9 +1011,10 @@ pub enum GetFilesetRedirectsResponse {
}
#[derive(Debug, PartialEq)]
-pub enum GetFilesetRevisionResponse {
+#[must_use]
+pub enum GetFileRevisionResponse {
/// Found Entity Revision
- FoundEntityRevision(models::FilesetEntity),
+ FoundEntityRevision(models::FileEntity),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Found
@@ -855,15 +1024,12 @@ pub enum GetFilesetRevisionResponse {
}
#[derive(Debug, PartialEq)]
-pub enum UpdateFilesetResponse {
- /// Updated Entity
- UpdatedEntity(models::EntityEdit),
+#[must_use]
+pub enum GetFilesetResponse {
+ /// Found Entity
+ FoundEntity(models::FilesetEntity),
/// 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
@@ -871,15 +1037,12 @@ pub enum UpdateFilesetResponse {
}
#[derive(Debug, PartialEq)]
-pub enum CreateReleaseResponse {
- /// Created Entity
- CreatedEntity(models::EntityEdit),
+#[must_use]
+pub enum GetFilesetEditResponse {
+ /// Found Edit
+ FoundEdit(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
@@ -887,15 +1050,12 @@ pub enum CreateReleaseResponse {
}
#[derive(Debug, PartialEq)]
-pub enum CreateReleaseAutoBatchResponse {
- /// Created Editgroup
- CreatedEditgroup(models::Editgroup),
+#[must_use]
+pub enum GetFilesetHistoryResponse {
+ /// Found Entity History
+ FoundEntityHistory(Vec<models::EntityHistoryEntry>),
/// 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
@@ -903,15 +1063,12 @@ pub enum CreateReleaseAutoBatchResponse {
}
#[derive(Debug, PartialEq)]
-pub enum DeleteReleaseResponse {
- /// Deleted Entity
- DeletedEntity(models::EntityEdit),
+#[must_use]
+pub enum GetFilesetRedirectsResponse {
+ /// Found Entity Redirects
+ FoundEntityRedirects(Vec<String>),
/// 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
@@ -919,15 +1076,12 @@ pub enum DeleteReleaseResponse {
}
#[derive(Debug, PartialEq)]
-pub enum DeleteReleaseEditResponse {
- /// Deleted Edit
- DeletedEdit(models::Success),
+#[must_use]
+pub enum GetFilesetRevisionResponse {
+ /// Found Entity Revision
+ FoundEntityRevision(models::FilesetEntity),
/// 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
@@ -935,6 +1089,7 @@ pub enum DeleteReleaseEditResponse {
}
#[derive(Debug, PartialEq)]
+#[must_use]
pub enum GetReleaseResponse {
/// Found Entity
FoundEntity(models::ReleaseEntity),
@@ -947,6 +1102,7 @@ pub enum GetReleaseResponse {
}
#[derive(Debug, PartialEq)]
+#[must_use]
pub enum GetReleaseEditResponse {
/// Found Edit
FoundEdit(models::EntityEdit),
@@ -959,6 +1115,7 @@ pub enum GetReleaseEditResponse {
}
#[derive(Debug, PartialEq)]
+#[must_use]
pub enum GetReleaseFilesResponse {
/// Found
Found(Vec<models::FileEntity>),
@@ -971,6 +1128,7 @@ pub enum GetReleaseFilesResponse {
}
#[derive(Debug, PartialEq)]
+#[must_use]
pub enum GetReleaseFilesetsResponse {
/// Found
Found(Vec<models::FilesetEntity>),
@@ -983,6 +1141,7 @@ pub enum GetReleaseFilesetsResponse {
}
#[derive(Debug, PartialEq)]
+#[must_use]
pub enum GetReleaseHistoryResponse {
/// Found Entity History
FoundEntityHistory(Vec<models::EntityHistoryEntry>),
@@ -995,6 +1154,7 @@ pub enum GetReleaseHistoryResponse {
}
#[derive(Debug, PartialEq)]
+#[must_use]
pub enum GetReleaseRedirectsResponse {
/// Found Entity Redirects
FoundEntityRedirects(Vec<String>),
@@ -1007,6 +1167,7 @@ pub enum GetReleaseRedirectsResponse {
}
#[derive(Debug, PartialEq)]
+#[must_use]
pub enum GetReleaseRevisionResponse {
/// Found Entity Revision
FoundEntityRevision(models::ReleaseEntity),
@@ -1019,6 +1180,7 @@ pub enum GetReleaseRevisionResponse {
}
#[derive(Debug, PartialEq)]
+#[must_use]
pub enum GetReleaseWebcapturesResponse {
/// Found
Found(Vec<models::WebcaptureEntity>),
@@ -1031,9 +1193,10 @@ pub enum GetReleaseWebcapturesResponse {
}
#[derive(Debug, PartialEq)]
-pub enum LookupReleaseResponse {
+#[must_use]
+pub enum GetWebcaptureResponse {
/// Found Entity
- FoundEntity(models::ReleaseEntity),
+ FoundEntity(models::WebcaptureEntity),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Found
@@ -1043,15 +1206,12 @@ pub enum LookupReleaseResponse {
}
#[derive(Debug, PartialEq)]
-pub enum UpdateReleaseResponse {
- /// Updated Entity
- UpdatedEntity(models::EntityEdit),
+#[must_use]
+pub enum GetWebcaptureEditResponse {
+ /// Found Edit
+ FoundEdit(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
@@ -1059,15 +1219,12 @@ pub enum UpdateReleaseResponse {
}
#[derive(Debug, PartialEq)]
-pub enum CreateWebcaptureResponse {
- /// Created Entity
- CreatedEntity(models::EntityEdit),
+#[must_use]
+pub enum GetWebcaptureHistoryResponse {
+ /// Found Entity History
+ FoundEntityHistory(Vec<models::EntityHistoryEntry>),
/// 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
@@ -1075,15 +1232,12 @@ pub enum CreateWebcaptureResponse {
}
#[derive(Debug, PartialEq)]
-pub enum CreateWebcaptureAutoBatchResponse {
- /// Created Editgroup
- CreatedEditgroup(models::Editgroup),
+#[must_use]
+pub enum GetWebcaptureRedirectsResponse {
+ /// Found Entity Redirects
+ FoundEntityRedirects(Vec<String>),
/// 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
@@ -1091,15 +1245,12 @@ pub enum CreateWebcaptureAutoBatchResponse {
}
#[derive(Debug, PartialEq)]
-pub enum DeleteWebcaptureResponse {
- /// Deleted Entity
- DeletedEntity(models::EntityEdit),
+#[must_use]
+pub enum GetWebcaptureRevisionResponse {
+ /// Found Entity Revision
+ FoundEntityRevision(models::WebcaptureEntity),
/// 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
@@ -1107,15 +1258,12 @@ pub enum DeleteWebcaptureResponse {
}
#[derive(Debug, PartialEq)]
-pub enum DeleteWebcaptureEditResponse {
- /// Deleted Edit
- DeletedEdit(models::Success),
+#[must_use]
+pub enum GetWorkResponse {
+ /// Found Entity
+ FoundEntity(models::WorkEntity),
/// 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
@@ -1123,9 +1271,10 @@ pub enum DeleteWebcaptureEditResponse {
}
#[derive(Debug, PartialEq)]
-pub enum GetWebcaptureResponse {
- /// Found Entity
- FoundEntity(models::WebcaptureEntity),
+#[must_use]
+pub enum GetWorkEditResponse {
+ /// Found Edit
+ FoundEdit(models::EntityEdit),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Found
@@ -1135,9 +1284,10 @@ pub enum GetWebcaptureResponse {
}
#[derive(Debug, PartialEq)]
-pub enum GetWebcaptureEditResponse {
- /// Found Edit
- FoundEdit(models::EntityEdit),
+#[must_use]
+pub enum GetWorkHistoryResponse {
+ /// Found Entity History
+ FoundEntityHistory(Vec<models::EntityHistoryEntry>),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Found
@@ -1147,9 +1297,10 @@ pub enum GetWebcaptureEditResponse {
}
#[derive(Debug, PartialEq)]
-pub enum GetWebcaptureHistoryResponse {
- /// Found Entity History
- FoundEntityHistory(Vec<models::EntityHistoryEntry>),
+#[must_use]
+pub enum GetWorkRedirectsResponse {
+ /// Found Entity Redirects
+ FoundEntityRedirects(Vec<String>),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Found
@@ -1159,9 +1310,10 @@ pub enum GetWebcaptureHistoryResponse {
}
#[derive(Debug, PartialEq)]
-pub enum GetWebcaptureRedirectsResponse {
- /// Found Entity Redirects
- FoundEntityRedirects(Vec<String>),
+#[must_use]
+pub enum GetWorkReleasesResponse {
+ /// Found
+ Found(Vec<models::ReleaseEntity>),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Found
@@ -1171,9 +1323,10 @@ pub enum GetWebcaptureRedirectsResponse {
}
#[derive(Debug, PartialEq)]
-pub enum GetWebcaptureRevisionResponse {
+#[must_use]
+pub enum GetWorkRevisionResponse {
/// Found Entity Revision
- FoundEntityRevision(models::WebcaptureEntity),
+ FoundEntityRevision(models::WorkEntity),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Found
@@ -1183,15 +1336,12 @@ pub enum GetWebcaptureRevisionResponse {
}
#[derive(Debug, PartialEq)]
-pub enum UpdateWebcaptureResponse {
- /// Updated Entity
- UpdatedEntity(models::EntityEdit),
+#[must_use]
+pub enum LookupContainerResponse {
+ /// Found Entity
+ FoundEntity(models::ContainerEntity),
/// 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
@@ -1199,15 +1349,12 @@ pub enum UpdateWebcaptureResponse {
}
#[derive(Debug, PartialEq)]
-pub enum CreateWorkResponse {
- /// Created Entity
- CreatedEntity(models::EntityEdit),
+#[must_use]
+pub enum LookupCreatorResponse {
+ /// Found Entity
+ FoundEntity(models::CreatorEntity),
/// 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
@@ -1215,15 +1362,12 @@ pub enum CreateWorkResponse {
}
#[derive(Debug, PartialEq)]
-pub enum CreateWorkAutoBatchResponse {
- /// Created Editgroup
- CreatedEditgroup(models::Editgroup),
+#[must_use]
+pub enum LookupFileResponse {
+ /// Found Entity
+ FoundEntity(models::FileEntity),
/// 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
@@ -1231,13 +1375,30 @@ pub enum CreateWorkAutoBatchResponse {
}
#[derive(Debug, PartialEq)]
-pub enum DeleteWorkResponse {
- /// Deleted Entity
- DeletedEntity(models::EntityEdit),
+#[must_use]
+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)]
+#[must_use]
+pub enum UpdateContainerResponse {
+ /// Updated Entity
+ UpdatedEntity(models::EntityEdit),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Authorized
- NotAuthorized { body: models::ErrorResponse, www_authenticate: String },
+ NotAuthorized {
+ body: models::ErrorResponse,
+ www_authenticate: String,
+ },
/// Forbidden
Forbidden(models::ErrorResponse),
/// Not Found
@@ -1247,13 +1408,17 @@ pub enum DeleteWorkResponse {
}
#[derive(Debug, PartialEq)]
-pub enum DeleteWorkEditResponse {
- /// Deleted Edit
- DeletedEdit(models::Success),
+#[must_use]
+pub enum UpdateCreatorResponse {
+ /// Updated Entity
+ UpdatedEntity(models::EntityEdit),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Authorized
- NotAuthorized { body: models::ErrorResponse, www_authenticate: String },
+ NotAuthorized {
+ body: models::ErrorResponse,
+ www_authenticate: String,
+ },
/// Forbidden
Forbidden(models::ErrorResponse),
/// Not Found
@@ -1263,11 +1428,19 @@ pub enum DeleteWorkEditResponse {
}
#[derive(Debug, PartialEq)]
-pub enum GetWorkResponse {
- /// Found Entity
- FoundEntity(models::WorkEntity),
+#[must_use]
+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
@@ -1275,11 +1448,19 @@ pub enum GetWorkResponse {
}
#[derive(Debug, PartialEq)]
-pub enum GetWorkEditResponse {
- /// Found Edit
- FoundEdit(models::EntityEdit),
+#[must_use]
+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
@@ -1287,11 +1468,19 @@ pub enum GetWorkEditResponse {
}
#[derive(Debug, PartialEq)]
-pub enum GetWorkHistoryResponse {
- /// Found Entity History
- FoundEntityHistory(Vec<models::EntityHistoryEntry>),
+#[must_use]
+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
@@ -1299,11 +1488,19 @@ pub enum GetWorkHistoryResponse {
}
#[derive(Debug, PartialEq)]
-pub enum GetWorkRedirectsResponse {
- /// Found Entity Redirects
- FoundEntityRedirects(Vec<String>),
+#[must_use]
+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
@@ -1311,11 +1508,19 @@ pub enum GetWorkRedirectsResponse {
}
#[derive(Debug, PartialEq)]
-pub enum GetWorkReleasesResponse {
- /// Found
- Found(Vec<models::ReleaseEntity>),
+#[must_use]
+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
@@ -1323,11 +1528,19 @@ pub enum GetWorkReleasesResponse {
}
#[derive(Debug, PartialEq)]
-pub enum GetWorkRevisionResponse {
- /// Found Entity Revision
- FoundEntityRevision(models::WorkEntity),
+#[must_use]
+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
@@ -1335,13 +1548,17 @@ pub enum GetWorkRevisionResponse {
}
#[derive(Debug, PartialEq)]
+#[must_use]
pub enum UpdateWorkResponse {
/// Updated Entity
UpdatedEntity(models::EntityEdit),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Authorized
- NotAuthorized { body: models::ErrorResponse, www_authenticate: String },
+ NotAuthorized {
+ body: models::ErrorResponse,
+ www_authenticate: String,
+ },
/// Forbidden
Forbidden(models::ErrorResponse),
/// Not Found
@@ -1351,91 +1568,335 @@ pub enum UpdateWorkResponse {
}
/// API
-pub trait Api {
- fn auth_check(&self, role: Option<String>, context: &Context) -> Box<dyn Future<Item = AuthCheckResponse, Error = ApiError> + Send>;
+pub trait Api<C> {
+ fn accept_editgroup(
+ &self,
+ editgroup_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = AcceptEditgroupResponse, Error = ApiError> + Send>;
+
+ fn auth_check(
+ &self,
+ role: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = AuthCheckResponse, Error = ApiError> + Send>;
+
+ fn auth_oidc(
+ &self,
+ oidc_params: models::AuthOidc,
+ context: &C,
+ ) -> Box<dyn Future<Item = AuthOidcResponse, Error = ApiError> + Send>;
+
+ fn create_auth_token(
+ &self,
+ editor_id: String,
+ duration_seconds: Option<i32>,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateAuthTokenResponse, Error = ApiError> + Send>;
+
+ fn create_container(
+ &self,
+ editgroup_id: String,
+ entity: models::ContainerEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateContainerResponse, Error = ApiError> + Send>;
+
+ fn create_container_auto_batch(
+ &self,
+ auto_batch: models::ContainerAutoBatch,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateContainerAutoBatchResponse, Error = ApiError> + Send>;
+
+ fn create_creator(
+ &self,
+ editgroup_id: String,
+ entity: models::CreatorEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateCreatorResponse, Error = ApiError> + Send>;
- fn auth_oidc(&self, oidc_params: models::AuthOidc, context: &Context) -> Box<dyn Future<Item = AuthOidcResponse, Error = ApiError> + Send>;
+ fn create_creator_auto_batch(
+ &self,
+ auto_batch: models::CreatorAutoBatch,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateCreatorAutoBatchResponse, Error = ApiError> + Send>;
- fn create_auth_token(&self, editor_id: String, duration_seconds: Option<i32>, context: &Context) -> Box<dyn Future<Item = CreateAuthTokenResponse, Error = ApiError> + Send>;
+ fn create_editgroup(
+ &self,
+ editgroup: models::Editgroup,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateEditgroupResponse, Error = ApiError> + Send>;
- fn get_changelog(&self, limit: Option<i64>, context: &Context) -> Box<dyn Future<Item = GetChangelogResponse, Error = ApiError> + Send>;
+ fn create_editgroup_annotation(
+ &self,
+ editgroup_id: String,
+ annotation: models::EditgroupAnnotation,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateEditgroupAnnotationResponse, Error = ApiError> + Send>;
- fn get_changelog_entry(&self, index: i64, context: &Context) -> Box<dyn Future<Item = GetChangelogEntryResponse, Error = ApiError> + Send>;
+ fn create_file(
+ &self,
+ editgroup_id: String,
+ entity: models::FileEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateFileResponse, Error = ApiError> + Send>;
- fn create_container(&self, editgroup_id: String, entity: models::ContainerEntity, context: &Context) -> Box<dyn Future<Item = CreateContainerResponse, Error = ApiError> + Send>;
+ fn create_file_auto_batch(
+ &self,
+ auto_batch: models::FileAutoBatch,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateFileAutoBatchResponse, Error = ApiError> + Send>;
- fn create_container_auto_batch(&self, auto_batch: models::ContainerAutoBatch, context: &Context) -> Box<dyn Future<Item = CreateContainerAutoBatchResponse, Error = ApiError> + Send>;
+ fn create_fileset(
+ &self,
+ editgroup_id: String,
+ entity: models::FilesetEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateFilesetResponse, Error = ApiError> + Send>;
- fn delete_container(&self, editgroup_id: String, ident: String, context: &Context) -> Box<dyn Future<Item = DeleteContainerResponse, Error = ApiError> + Send>;
+ fn create_fileset_auto_batch(
+ &self,
+ auto_batch: models::FilesetAutoBatch,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateFilesetAutoBatchResponse, Error = ApiError> + Send>;
- fn delete_container_edit(&self, editgroup_id: String, edit_id: String, context: &Context) -> Box<dyn Future<Item = DeleteContainerEditResponse, Error = ApiError> + Send>;
+ fn create_release(
+ &self,
+ editgroup_id: String,
+ entity: models::ReleaseEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateReleaseResponse, Error = ApiError> + Send>;
- fn get_container(&self, ident: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetContainerResponse, Error = ApiError> + Send>;
+ fn create_release_auto_batch(
+ &self,
+ auto_batch: models::ReleaseAutoBatch,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateReleaseAutoBatchResponse, Error = ApiError> + Send>;
- fn get_container_edit(&self, edit_id: String, context: &Context) -> Box<dyn Future<Item = GetContainerEditResponse, Error = ApiError> + Send>;
+ fn create_webcapture(
+ &self,
+ editgroup_id: String,
+ entity: models::WebcaptureEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateWebcaptureResponse, Error = ApiError> + Send>;
- fn get_container_history(&self, ident: String, limit: Option<i64>, context: &Context) -> Box<dyn Future<Item = GetContainerHistoryResponse, Error = ApiError> + Send>;
+ fn create_webcapture_auto_batch(
+ &self,
+ auto_batch: models::WebcaptureAutoBatch,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateWebcaptureAutoBatchResponse, Error = ApiError> + Send>;
- fn get_container_redirects(&self, ident: String, context: &Context) -> Box<dyn Future<Item = GetContainerRedirectsResponse, Error = ApiError> + Send>;
+ fn create_work(
+ &self,
+ editgroup_id: String,
+ entity: models::WorkEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateWorkResponse, Error = ApiError> + Send>;
- fn get_container_revision(&self, rev_id: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetContainerRevisionResponse, Error = ApiError> + Send>;
+ fn create_work_auto_batch(
+ &self,
+ auto_batch: models::WorkAutoBatch,
+ context: &C,
+ ) -> Box<dyn Future<Item = CreateWorkAutoBatchResponse, Error = ApiError> + Send>;
- fn lookup_container(
+ fn delete_container(
&self,
- issnl: Option<String>,
- wikidata_qid: Option<String>,
- expand: Option<String>,
- hide: Option<String>,
- context: &Context,
- ) -> Box<dyn Future<Item = LookupContainerResponse, Error = ApiError> + Send>;
+ editgroup_id: String,
+ ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteContainerResponse, Error = ApiError> + Send>;
- fn update_container(&self, editgroup_id: String, ident: String, entity: models::ContainerEntity, context: &Context) -> Box<dyn Future<Item = UpdateContainerResponse, Error = ApiError> + Send>;
+ fn delete_container_edit(
+ &self,
+ editgroup_id: String,
+ edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteContainerEditResponse, Error = ApiError> + Send>;
- fn create_creator(&self, editgroup_id: String, entity: models::CreatorEntity, context: &Context) -> Box<dyn Future<Item = CreateCreatorResponse, Error = ApiError> + Send>;
+ fn delete_creator(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteCreatorResponse, Error = ApiError> + Send>;
- fn create_creator_auto_batch(&self, auto_batch: models::CreatorAutoBatch, context: &Context) -> Box<dyn Future<Item = CreateCreatorAutoBatchResponse, Error = ApiError> + Send>;
+ fn delete_creator_edit(
+ &self,
+ editgroup_id: String,
+ edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteCreatorEditResponse, Error = ApiError> + Send>;
- fn delete_creator(&self, editgroup_id: String, ident: String, context: &Context) -> Box<dyn Future<Item = DeleteCreatorResponse, Error = ApiError> + Send>;
+ fn delete_file(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteFileResponse, Error = ApiError> + Send>;
- fn delete_creator_edit(&self, editgroup_id: String, edit_id: String, context: &Context) -> Box<dyn Future<Item = DeleteCreatorEditResponse, Error = ApiError> + Send>;
+ fn delete_file_edit(
+ &self,
+ editgroup_id: String,
+ edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteFileEditResponse, Error = ApiError> + Send>;
- fn get_creator(&self, ident: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetCreatorResponse, Error = ApiError> + Send>;
+ fn delete_fileset(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteFilesetResponse, Error = ApiError> + Send>;
- fn get_creator_edit(&self, edit_id: String, context: &Context) -> Box<dyn Future<Item = GetCreatorEditResponse, Error = ApiError> + Send>;
+ fn delete_fileset_edit(
+ &self,
+ editgroup_id: String,
+ edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteFilesetEditResponse, Error = ApiError> + Send>;
- fn get_creator_history(&self, ident: String, limit: Option<i64>, context: &Context) -> Box<dyn Future<Item = GetCreatorHistoryResponse, Error = ApiError> + Send>;
+ fn delete_release(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteReleaseResponse, Error = ApiError> + Send>;
- fn get_creator_redirects(&self, ident: String, context: &Context) -> Box<dyn Future<Item = GetCreatorRedirectsResponse, Error = ApiError> + Send>;
+ fn delete_release_edit(
+ &self,
+ editgroup_id: String,
+ edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteReleaseEditResponse, Error = ApiError> + Send>;
- fn get_creator_releases(&self, ident: String, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetCreatorReleasesResponse, Error = ApiError> + Send>;
+ fn delete_webcapture(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteWebcaptureResponse, Error = ApiError> + Send>;
- fn get_creator_revision(&self, rev_id: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetCreatorRevisionResponse, Error = ApiError> + Send>;
+ fn delete_webcapture_edit(
+ &self,
+ editgroup_id: String,
+ edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteWebcaptureEditResponse, Error = ApiError> + Send>;
- fn lookup_creator(
+ fn delete_work(
&self,
- orcid: Option<String>,
- wikidata_qid: Option<String>,
+ editgroup_id: String,
+ ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteWorkResponse, Error = ApiError> + Send>;
+
+ fn delete_work_edit(
+ &self,
+ editgroup_id: String,
+ edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = DeleteWorkEditResponse, Error = ApiError> + Send>;
+
+ fn get_changelog(
+ &self,
+ limit: Option<i64>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetChangelogResponse, Error = ApiError> + Send>;
+
+ fn get_changelog_entry(
+ &self,
+ index: i64,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetChangelogEntryResponse, Error = ApiError> + Send>;
+
+ fn get_container(
+ &self,
+ ident: String,
expand: Option<String>,
hide: Option<String>,
- context: &Context,
- ) -> Box<dyn Future<Item = LookupCreatorResponse, Error = ApiError> + Send>;
+ context: &C,
+ ) -> Box<dyn Future<Item = GetContainerResponse, Error = ApiError> + Send>;
+
+ fn get_container_edit(
+ &self,
+ edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetContainerEditResponse, Error = ApiError> + Send>;
+
+ fn get_container_history(
+ &self,
+ ident: String,
+ limit: Option<i64>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetContainerHistoryResponse, Error = ApiError> + Send>;
- fn update_creator(&self, editgroup_id: String, ident: String, entity: models::CreatorEntity, context: &Context) -> Box<dyn Future<Item = UpdateCreatorResponse, Error = ApiError> + Send>;
+ fn get_container_redirects(
+ &self,
+ ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetContainerRedirectsResponse, Error = ApiError> + Send>;
- fn accept_editgroup(&self, editgroup_id: String, context: &Context) -> Box<dyn Future<Item = AcceptEditgroupResponse, Error = ApiError> + Send>;
+ fn get_container_revision(
+ &self,
+ rev_id: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetContainerRevisionResponse, Error = ApiError> + Send>;
- fn create_editgroup(&self, editgroup: models::Editgroup, context: &Context) -> Box<dyn Future<Item = CreateEditgroupResponse, Error = ApiError> + Send>;
+ fn get_creator(
+ &self,
+ ident: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetCreatorResponse, Error = ApiError> + Send>;
- fn create_editgroup_annotation(
+ fn get_creator_edit(
&self,
- editgroup_id: String,
- annotation: models::EditgroupAnnotation,
- context: &Context,
- ) -> Box<dyn Future<Item = CreateEditgroupAnnotationResponse, Error = ApiError> + Send>;
+ edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetCreatorEditResponse, Error = ApiError> + Send>;
+
+ fn get_creator_history(
+ &self,
+ ident: String,
+ limit: Option<i64>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetCreatorHistoryResponse, Error = ApiError> + Send>;
+
+ fn get_creator_redirects(
+ &self,
+ ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetCreatorRedirectsResponse, Error = ApiError> + Send>;
+
+ fn get_creator_releases(
+ &self,
+ ident: String,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetCreatorReleasesResponse, Error = ApiError> + Send>;
+
+ fn get_creator_revision(
+ &self,
+ rev_id: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetCreatorRevisionResponse, Error = ApiError> + Send>;
- fn get_editgroup(&self, editgroup_id: String, context: &Context) -> Box<dyn Future<Item = GetEditgroupResponse, Error = ApiError> + Send>;
+ fn get_editgroup(
+ &self,
+ editgroup_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetEditgroupResponse, Error = ApiError> + Send>;
- fn get_editgroup_annotations(&self, editgroup_id: String, expand: Option<String>, context: &Context) -> Box<dyn Future<Item = GetEditgroupAnnotationsResponse, Error = ApiError> + Send>;
+ fn get_editgroup_annotations(
+ &self,
+ editgroup_id: String,
+ expand: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetEditgroupAnnotationsResponse, Error = ApiError> + Send>;
fn get_editgroups_reviewable(
&self,
@@ -1443,13 +1904,14 @@ pub trait Api {
limit: Option<i64>,
before: Option<chrono::DateTime<chrono::Utc>>,
since: Option<chrono::DateTime<chrono::Utc>>,
- context: &Context,
+ context: &C,
) -> Box<dyn Future<Item = GetEditgroupsReviewableResponse, Error = ApiError> + Send>;
- fn update_editgroup(&self, editgroup_id: String, editgroup: models::Editgroup, submit: Option<bool>, context: &Context)
- -> Box<dyn Future<Item = UpdateEditgroupResponse, Error = ApiError> + Send>;
-
- fn get_editor(&self, editor_id: String, context: &Context) -> Box<dyn Future<Item = GetEditorResponse, Error = ApiError> + Send>;
+ fn get_editor(
+ &self,
+ editor_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetEditorResponse, Error = ApiError> + Send>;
fn get_editor_annotations(
&self,
@@ -1457,7 +1919,7 @@ pub trait Api {
limit: Option<i64>,
before: Option<chrono::DateTime<chrono::Utc>>,
since: Option<chrono::DateTime<chrono::Utc>>,
- context: &Context,
+ context: &C,
) -> Box<dyn Future<Item = GetEditorAnnotationsResponse, Error = ApiError> + Send>;
fn get_editor_editgroups(
@@ -1466,84 +1928,239 @@ pub trait Api {
limit: Option<i64>,
before: Option<chrono::DateTime<chrono::Utc>>,
since: Option<chrono::DateTime<chrono::Utc>>,
- context: &Context,
+ context: &C,
) -> Box<dyn Future<Item = GetEditorEditgroupsResponse, Error = ApiError> + Send>;
- fn update_editor(&self, editor_id: String, editor: models::Editor, context: &Context) -> Box<dyn Future<Item = UpdateEditorResponse, Error = ApiError> + Send>;
-
- fn create_file(&self, editgroup_id: String, entity: models::FileEntity, context: &Context) -> Box<dyn Future<Item = CreateFileResponse, Error = ApiError> + Send>;
+ fn get_file(
+ &self,
+ ident: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetFileResponse, Error = ApiError> + Send>;
- fn create_file_auto_batch(&self, auto_batch: models::FileAutoBatch, context: &Context) -> Box<dyn Future<Item = CreateFileAutoBatchResponse, Error = ApiError> + Send>;
+ fn get_file_edit(
+ &self,
+ edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetFileEditResponse, Error = ApiError> + Send>;
- fn delete_file(&self, editgroup_id: String, ident: String, context: &Context) -> Box<dyn Future<Item = DeleteFileResponse, Error = ApiError> + Send>;
+ fn get_file_history(
+ &self,
+ ident: String,
+ limit: Option<i64>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetFileHistoryResponse, Error = ApiError> + Send>;
- fn delete_file_edit(&self, editgroup_id: String, edit_id: String, context: &Context) -> Box<dyn Future<Item = DeleteFileEditResponse, Error = ApiError> + Send>;
+ fn get_file_redirects(
+ &self,
+ ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetFileRedirectsResponse, Error = ApiError> + Send>;
- fn get_file(&self, ident: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetFileResponse, Error = ApiError> + Send>;
+ fn get_file_revision(
+ &self,
+ rev_id: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetFileRevisionResponse, Error = ApiError> + Send>;
- fn get_file_edit(&self, edit_id: String, context: &Context) -> Box<dyn Future<Item = GetFileEditResponse, Error = ApiError> + Send>;
+ fn get_fileset(
+ &self,
+ ident: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetFilesetResponse, Error = ApiError> + Send>;
- fn get_file_history(&self, ident: String, limit: Option<i64>, context: &Context) -> Box<dyn Future<Item = GetFileHistoryResponse, Error = ApiError> + Send>;
+ fn get_fileset_edit(
+ &self,
+ edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetFilesetEditResponse, Error = ApiError> + Send>;
- fn get_file_redirects(&self, ident: String, context: &Context) -> Box<dyn Future<Item = GetFileRedirectsResponse, Error = ApiError> + Send>;
+ fn get_fileset_history(
+ &self,
+ ident: String,
+ limit: Option<i64>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetFilesetHistoryResponse, Error = ApiError> + Send>;
- fn get_file_revision(&self, rev_id: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetFileRevisionResponse, Error = ApiError> + Send>;
+ fn get_fileset_redirects(
+ &self,
+ ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetFilesetRedirectsResponse, Error = ApiError> + Send>;
- fn lookup_file(
+ fn get_fileset_revision(
&self,
- md5: Option<String>,
- sha1: Option<String>,
- sha256: Option<String>,
+ rev_id: String,
expand: Option<String>,
hide: Option<String>,
- context: &Context,
- ) -> Box<dyn Future<Item = LookupFileResponse, Error = ApiError> + Send>;
+ context: &C,
+ ) -> Box<dyn Future<Item = GetFilesetRevisionResponse, Error = ApiError> + Send>;
- fn update_file(&self, editgroup_id: String, ident: String, entity: models::FileEntity, context: &Context) -> Box<dyn Future<Item = UpdateFileResponse, Error = ApiError> + Send>;
-
- fn create_fileset(&self, editgroup_id: String, entity: models::FilesetEntity, context: &Context) -> Box<dyn Future<Item = CreateFilesetResponse, Error = ApiError> + Send>;
+ fn get_release(
+ &self,
+ ident: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetReleaseResponse, Error = ApiError> + Send>;
- fn create_fileset_auto_batch(&self, auto_batch: models::FilesetAutoBatch, context: &Context) -> Box<dyn Future<Item = CreateFilesetAutoBatchResponse, Error = ApiError> + Send>;
+ fn get_release_edit(
+ &self,
+ edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetReleaseEditResponse, Error = ApiError> + Send>;
- fn delete_fileset(&self, editgroup_id: String, ident: String, context: &Context) -> Box<dyn Future<Item = DeleteFilesetResponse, Error = ApiError> + Send>;
+ fn get_release_files(
+ &self,
+ ident: String,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetReleaseFilesResponse, Error = ApiError> + Send>;
- fn delete_fileset_edit(&self, editgroup_id: String, edit_id: String, context: &Context) -> Box<dyn Future<Item = DeleteFilesetEditResponse, Error = ApiError> + Send>;
+ fn get_release_filesets(
+ &self,
+ ident: String,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetReleaseFilesetsResponse, Error = ApiError> + Send>;
- fn get_fileset(&self, ident: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetFilesetResponse, Error = ApiError> + Send>;
+ fn get_release_history(
+ &self,
+ ident: String,
+ limit: Option<i64>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetReleaseHistoryResponse, Error = ApiError> + Send>;
- fn get_fileset_edit(&self, edit_id: String, context: &Context) -> Box<dyn Future<Item = GetFilesetEditResponse, Error = ApiError> + Send>;
+ fn get_release_redirects(
+ &self,
+ ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetReleaseRedirectsResponse, Error = ApiError> + Send>;
- fn get_fileset_history(&self, ident: String, limit: Option<i64>, context: &Context) -> Box<dyn Future<Item = GetFilesetHistoryResponse, Error = ApiError> + Send>;
+ fn get_release_revision(
+ &self,
+ rev_id: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetReleaseRevisionResponse, Error = ApiError> + Send>;
- fn get_fileset_redirects(&self, ident: String, context: &Context) -> Box<dyn Future<Item = GetFilesetRedirectsResponse, Error = ApiError> + Send>;
+ fn get_release_webcaptures(
+ &self,
+ ident: String,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetReleaseWebcapturesResponse, Error = ApiError> + Send>;
- fn get_fileset_revision(&self, rev_id: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetFilesetRevisionResponse, Error = ApiError> + Send>;
+ fn get_webcapture(
+ &self,
+ ident: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetWebcaptureResponse, Error = ApiError> + Send>;
- fn update_fileset(&self, editgroup_id: String, ident: String, entity: models::FilesetEntity, context: &Context) -> Box<dyn Future<Item = UpdateFilesetResponse, Error = ApiError> + Send>;
+ fn get_webcapture_edit(
+ &self,
+ edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetWebcaptureEditResponse, Error = ApiError> + Send>;
- fn create_release(&self, editgroup_id: String, entity: models::ReleaseEntity, context: &Context) -> Box<dyn Future<Item = CreateReleaseResponse, Error = ApiError> + Send>;
+ fn get_webcapture_history(
+ &self,
+ ident: String,
+ limit: Option<i64>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetWebcaptureHistoryResponse, Error = ApiError> + Send>;
- fn create_release_auto_batch(&self, auto_batch: models::ReleaseAutoBatch, context: &Context) -> Box<dyn Future<Item = CreateReleaseAutoBatchResponse, Error = ApiError> + Send>;
+ fn get_webcapture_redirects(
+ &self,
+ ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetWebcaptureRedirectsResponse, Error = ApiError> + Send>;
- fn delete_release(&self, editgroup_id: String, ident: String, context: &Context) -> Box<dyn Future<Item = DeleteReleaseResponse, Error = ApiError> + Send>;
+ fn get_webcapture_revision(
+ &self,
+ rev_id: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetWebcaptureRevisionResponse, Error = ApiError> + Send>;
- fn delete_release_edit(&self, editgroup_id: String, edit_id: String, context: &Context) -> Box<dyn Future<Item = DeleteReleaseEditResponse, Error = ApiError> + Send>;
+ fn get_work(
+ &self,
+ ident: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetWorkResponse, Error = ApiError> + Send>;
- fn get_release(&self, ident: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetReleaseResponse, Error = ApiError> + Send>;
+ fn get_work_edit(
+ &self,
+ edit_id: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetWorkEditResponse, Error = ApiError> + Send>;
- fn get_release_edit(&self, edit_id: String, context: &Context) -> Box<dyn Future<Item = GetReleaseEditResponse, Error = ApiError> + Send>;
+ fn get_work_history(
+ &self,
+ ident: String,
+ limit: Option<i64>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetWorkHistoryResponse, Error = ApiError> + Send>;
- fn get_release_files(&self, ident: String, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetReleaseFilesResponse, Error = ApiError> + Send>;
+ fn get_work_redirects(
+ &self,
+ ident: String,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetWorkRedirectsResponse, Error = ApiError> + Send>;
- fn get_release_filesets(&self, ident: String, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetReleaseFilesetsResponse, Error = ApiError> + Send>;
+ fn get_work_releases(
+ &self,
+ ident: String,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetWorkReleasesResponse, Error = ApiError> + Send>;
- fn get_release_history(&self, ident: String, limit: Option<i64>, context: &Context) -> Box<dyn Future<Item = GetReleaseHistoryResponse, Error = ApiError> + Send>;
+ fn get_work_revision(
+ &self,
+ rev_id: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = GetWorkRevisionResponse, Error = ApiError> + Send>;
- fn get_release_redirects(&self, ident: String, context: &Context) -> Box<dyn Future<Item = GetReleaseRedirectsResponse, Error = ApiError> + Send>;
+ fn lookup_container(
+ &self,
+ issnl: Option<String>,
+ wikidata_qid: Option<String>,
+ expand: Option<String>,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = LookupContainerResponse, Error = ApiError> + Send>;
- fn get_release_revision(&self, rev_id: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetReleaseRevisionResponse, Error = ApiError> + Send>;
+ fn lookup_creator(
+ &self,
+ orcid: Option<String>,
+ wikidata_qid: Option<String>,
+ expand: Option<String>,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = LookupCreatorResponse, Error = ApiError> + Send>;
- fn get_release_webcaptures(&self, ident: String, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetReleaseWebcapturesResponse, Error = ApiError> + Send>;
+ fn lookup_file(
+ &self,
+ md5: Option<String>,
+ sha1: Option<String>,
+ sha256: Option<String>,
+ expand: Option<String>,
+ hide: Option<String>,
+ context: &C,
+ ) -> Box<dyn Future<Item = LookupFileResponse, Error = ApiError> + Send>;
fn lookup_release(
&self,
@@ -1559,139 +2176,362 @@ pub trait Api {
mag: Option<String>,
expand: Option<String>,
hide: Option<String>,
- context: &Context,
+ context: &C,
) -> Box<dyn Future<Item = LookupReleaseResponse, Error = ApiError> + Send>;
- fn update_release(&self, editgroup_id: String, ident: String, entity: models::ReleaseEntity, context: &Context) -> Box<dyn Future<Item = UpdateReleaseResponse, Error = ApiError> + Send>;
+ fn update_container(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ entity: models::ContainerEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = UpdateContainerResponse, Error = ApiError> + Send>;
- fn create_webcapture(&self, editgroup_id: String, entity: models::WebcaptureEntity, context: &Context) -> Box<dyn Future<Item = CreateWebcaptureResponse, Error = ApiError> + Send>;
+ fn update_creator(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ entity: models::CreatorEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = UpdateCreatorResponse, Error = ApiError> + Send>;
- fn create_webcapture_auto_batch(&self, auto_batch: models::WebcaptureAutoBatch, context: &Context) -> Box<dyn Future<Item = CreateWebcaptureAutoBatchResponse, Error = ApiError> + Send>;
+ fn update_editgroup(
+ &self,
+ editgroup_id: String,
+ editgroup: models::Editgroup,
+ submit: Option<bool>,
+ context: &C,
+ ) -> Box<dyn Future<Item = UpdateEditgroupResponse, Error = ApiError> + Send>;
- fn delete_webcapture(&self, editgroup_id: String, ident: String, context: &Context) -> Box<dyn Future<Item = DeleteWebcaptureResponse, Error = ApiError> + Send>;
+ fn update_editor(
+ &self,
+ editor_id: String,
+ editor: models::Editor,
+ context: &C,
+ ) -> Box<dyn Future<Item = UpdateEditorResponse, Error = ApiError> + Send>;
- fn delete_webcapture_edit(&self, editgroup_id: String, edit_id: String, context: &Context) -> Box<dyn Future<Item = DeleteWebcaptureEditResponse, Error = ApiError> + Send>;
+ fn update_file(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ entity: models::FileEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = UpdateFileResponse, Error = ApiError> + Send>;
- fn get_webcapture(&self, ident: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetWebcaptureResponse, Error = ApiError> + Send>;
+ fn update_fileset(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ entity: models::FilesetEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = UpdateFilesetResponse, Error = ApiError> + Send>;
- fn get_webcapture_edit(&self, edit_id: String, context: &Context) -> Box<dyn Future<Item = GetWebcaptureEditResponse, Error = ApiError> + Send>;
+ fn update_release(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ entity: models::ReleaseEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = UpdateReleaseResponse, Error = ApiError> + Send>;
- fn get_webcapture_history(&self, ident: String, limit: Option<i64>, context: &Context) -> Box<dyn Future<Item = GetWebcaptureHistoryResponse, Error = ApiError> + Send>;
+ fn update_webcapture(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ entity: models::WebcaptureEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = UpdateWebcaptureResponse, Error = ApiError> + Send>;
- fn get_webcapture_redirects(&self, ident: String, context: &Context) -> Box<dyn Future<Item = GetWebcaptureRedirectsResponse, Error = ApiError> + Send>;
+ fn update_work(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ entity: models::WorkEntity,
+ context: &C,
+ ) -> Box<dyn Future<Item = UpdateWorkResponse, Error = ApiError> + Send>;
+}
- fn get_webcapture_revision(
+/// API without a `Context`
+pub trait ApiNoContext {
+ fn accept_editgroup(
&self,
- rev_id: String,
- expand: Option<String>,
- hide: Option<String>,
- context: &Context,
- ) -> Box<dyn Future<Item = GetWebcaptureRevisionResponse, Error = ApiError> + Send>;
+ editgroup_id: String,
+ ) -> Box<dyn Future<Item = AcceptEditgroupResponse, Error = ApiError> + Send>;
- fn update_webcapture(&self, editgroup_id: String, ident: String, entity: models::WebcaptureEntity, context: &Context) -> Box<dyn Future<Item = UpdateWebcaptureResponse, Error = ApiError> + Send>;
+ fn auth_check(
+ &self,
+ role: Option<String>,
+ ) -> Box<dyn Future<Item = AuthCheckResponse, Error = ApiError> + Send>;
- fn create_work(&self, editgroup_id: String, entity: models::WorkEntity, context: &Context) -> Box<dyn Future<Item = CreateWorkResponse, Error = ApiError> + Send>;
+ fn auth_oidc(
+ &self,
+ oidc_params: models::AuthOidc,
+ ) -> Box<dyn Future<Item = AuthOidcResponse, Error = ApiError> + Send>;
- fn create_work_auto_batch(&self, auto_batch: models::WorkAutoBatch, context: &Context) -> Box<dyn Future<Item = CreateWorkAutoBatchResponse, Error = ApiError> + Send>;
+ fn create_auth_token(
+ &self,
+ editor_id: String,
+ duration_seconds: Option<i32>,
+ ) -> Box<dyn Future<Item = CreateAuthTokenResponse, Error = ApiError> + Send>;
- fn delete_work(&self, editgroup_id: String, ident: String, context: &Context) -> Box<dyn Future<Item = DeleteWorkResponse, Error = ApiError> + Send>;
+ fn create_container(
+ &self,
+ editgroup_id: String,
+ entity: models::ContainerEntity,
+ ) -> Box<dyn Future<Item = CreateContainerResponse, Error = ApiError> + Send>;
- fn delete_work_edit(&self, editgroup_id: String, edit_id: String, context: &Context) -> Box<dyn Future<Item = DeleteWorkEditResponse, Error = ApiError> + Send>;
+ fn create_container_auto_batch(
+ &self,
+ auto_batch: models::ContainerAutoBatch,
+ ) -> Box<dyn Future<Item = CreateContainerAutoBatchResponse, Error = ApiError> + Send>;
- fn get_work(&self, ident: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetWorkResponse, Error = ApiError> + Send>;
+ fn create_creator(
+ &self,
+ editgroup_id: String,
+ entity: models::CreatorEntity,
+ ) -> Box<dyn Future<Item = CreateCreatorResponse, Error = ApiError> + Send>;
- fn get_work_edit(&self, edit_id: String, context: &Context) -> Box<dyn Future<Item = GetWorkEditResponse, Error = ApiError> + Send>;
+ fn create_creator_auto_batch(
+ &self,
+ auto_batch: models::CreatorAutoBatch,
+ ) -> Box<dyn Future<Item = CreateCreatorAutoBatchResponse, Error = ApiError> + Send>;
- fn get_work_history(&self, ident: String, limit: Option<i64>, context: &Context) -> Box<dyn Future<Item = GetWorkHistoryResponse, Error = ApiError> + Send>;
+ fn create_editgroup(
+ &self,
+ editgroup: models::Editgroup,
+ ) -> Box<dyn Future<Item = CreateEditgroupResponse, Error = ApiError> + Send>;
- fn get_work_redirects(&self, ident: String, context: &Context) -> Box<dyn Future<Item = GetWorkRedirectsResponse, Error = ApiError> + Send>;
+ fn create_editgroup_annotation(
+ &self,
+ editgroup_id: String,
+ annotation: models::EditgroupAnnotation,
+ ) -> Box<dyn Future<Item = CreateEditgroupAnnotationResponse, Error = ApiError> + Send>;
- fn get_work_releases(&self, ident: String, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetWorkReleasesResponse, Error = ApiError> + Send>;
+ fn create_file(
+ &self,
+ editgroup_id: String,
+ entity: models::FileEntity,
+ ) -> Box<dyn Future<Item = CreateFileResponse, Error = ApiError> + Send>;
- fn get_work_revision(&self, rev_id: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<dyn Future<Item = GetWorkRevisionResponse, Error = ApiError> + Send>;
+ fn create_file_auto_batch(
+ &self,
+ auto_batch: models::FileAutoBatch,
+ ) -> Box<dyn Future<Item = CreateFileAutoBatchResponse, Error = ApiError> + Send>;
- fn update_work(&self, editgroup_id: String, ident: String, entity: models::WorkEntity, context: &Context) -> Box<dyn Future<Item = UpdateWorkResponse, Error = ApiError> + Send>;
-}
+ fn create_fileset(
+ &self,
+ editgroup_id: String,
+ entity: models::FilesetEntity,
+ ) -> Box<dyn Future<Item = CreateFilesetResponse, Error = ApiError> + Send>;
-/// API without a `Context`
-pub trait ApiNoContext {
- fn auth_check(&self, role: Option<String>) -> Box<dyn Future<Item = AuthCheckResponse, Error = ApiError> + Send>;
+ fn create_fileset_auto_batch(
+ &self,
+ auto_batch: models::FilesetAutoBatch,
+ ) -> Box<dyn Future<Item = CreateFilesetAutoBatchResponse, Error = ApiError> + Send>;
- fn auth_oidc(&self, oidc_params: models::AuthOidc) -> Box<dyn Future<Item = AuthOidcResponse, Error = ApiError> + Send>;
+ fn create_release(
+ &self,
+ editgroup_id: String,
+ entity: models::ReleaseEntity,
+ ) -> Box<dyn Future<Item = CreateReleaseResponse, Error = ApiError> + Send>;
- fn create_auth_token(&self, editor_id: String, duration_seconds: Option<i32>) -> Box<dyn Future<Item = CreateAuthTokenResponse, Error = ApiError> + Send>;
+ fn create_release_auto_batch(
+ &self,
+ auto_batch: models::ReleaseAutoBatch,
+ ) -> Box<dyn Future<Item = CreateReleaseAutoBatchResponse, Error = ApiError> + Send>;
- fn get_changelog(&self, limit: Option<i64>) -> Box<dyn Future<Item = GetChangelogResponse, Error = ApiError> + Send>;
+ fn create_webcapture(
+ &self,
+ editgroup_id: String,
+ entity: models::WebcaptureEntity,
+ ) -> Box<dyn Future<Item = CreateWebcaptureResponse, Error = ApiError> + Send>;
- fn get_changelog_entry(&self, index: i64) -> Box<dyn Future<Item = GetChangelogEntryResponse, Error = ApiError> + Send>;
+ fn create_webcapture_auto_batch(
+ &self,
+ auto_batch: models::WebcaptureAutoBatch,
+ ) -> Box<dyn Future<Item = CreateWebcaptureAutoBatchResponse, Error = ApiError> + Send>;
- fn create_container(&self, editgroup_id: String, entity: models::ContainerEntity) -> Box<dyn Future<Item = CreateContainerResponse, Error = ApiError> + Send>;
+ fn create_work(
+ &self,
+ editgroup_id: String,
+ entity: models::WorkEntity,
+ ) -> Box<dyn Future<Item = CreateWorkResponse, Error = ApiError> + Send>;
- fn create_container_auto_batch(&self, auto_batch: models::ContainerAutoBatch) -> Box<dyn Future<Item = CreateContainerAutoBatchResponse, Error = ApiError> + Send>;
+ fn create_work_auto_batch(
+ &self,
+ auto_batch: models::WorkAutoBatch,
+ ) -> Box<dyn Future<Item = CreateWorkAutoBatchResponse, Error = ApiError> + Send>;
- fn delete_container(&self, editgroup_id: String, ident: String) -> Box<dyn Future<Item = DeleteContainerResponse, Error = ApiError> + Send>;
+ fn delete_container(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ ) -> Box<dyn Future<Item = DeleteContainerResponse, Error = ApiError> + Send>;
- fn delete_container_edit(&self, editgroup_id: String, edit_id: String) -> Box<dyn Future<Item = DeleteContainerEditResponse, Error = ApiError> + Send>;
+ fn delete_container_edit(
+ &self,
+ editgroup_id: String,
+ edit_id: String,
+ ) -> Box<dyn Future<Item = DeleteContainerEditResponse, Error = ApiError> + Send>;
- fn get_container(&self, ident: String, expand: Option<String>, hide: Option<String>) -> Box<dyn Future<Item = GetContainerResponse, Error = ApiError> + Send>;
+ fn delete_creator(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ ) -> Box<dyn Future<Item = DeleteCreatorResponse, Error = ApiError> + Send>;
- fn get_container_edit(&self, edit_id: String) -> Box<dyn Future<Item = GetContainerEditResponse, Error = ApiError> + Send>;
+ fn delete_creator_edit(
+ &self,
+ editgroup_id: String,
+ edit_id: String,
+ ) -> Box<dyn Future<Item = DeleteCreatorEditResponse, Error = ApiError> + Send>;
- fn get_container_history(&self, ident: String, limit: Option<i64>) -> Box<dyn Future<Item = GetContainerHistoryResponse, Error = ApiError> + Send>;
+ fn delete_file(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ ) -> Box<dyn Future<Item = DeleteFileResponse, Error = ApiError> + Send>;
- fn get_container_redirects(&self, ident: String) -> Box<dyn Future<Item = GetContainerRedirectsResponse, Error = ApiError> + Send>;
+ fn delete_file_edit(
+ &self,
+ editgroup_id: String,
+ edit_id: String,
+ ) -> Box<dyn Future<Item = DeleteFileEditResponse, Error = ApiError> + Send>;
- fn get_container_revision(&self, rev_id: String, expand: Option<String>, hide: Option<String>) -> Box<dyn Future<Item = GetContainerRevisionResponse, Error = ApiError> + Send>;
+ fn delete_fileset(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ ) -> Box<dyn Future<Item = DeleteFilesetResponse, Error = ApiError> + Send>;
- fn lookup_container(
+ fn delete_fileset_edit(
&self,
- issnl: Option<String>,
- wikidata_qid: Option<String>,
- expand: Option<String>,
- hide: Option<String>,
- ) -> Box<dyn Future<Item = LookupContainerResponse, Error = ApiError> + Send>;
+ editgroup_id: String,
+ edit_id: String,
+ ) -> Box<dyn Future<Item = DeleteFilesetEditResponse, Error = ApiError> + Send>;
- fn update_container(&self, editgroup_id: String, ident: String, entity: models::ContainerEntity) -> Box<dyn Future<Item = UpdateContainerResponse, Error = ApiError> + Send>;
+ fn delete_release(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ ) -> Box<dyn Future<Item = DeleteReleaseResponse, Error = ApiError> + Send>;
- fn create_creator(&self, editgroup_id: String, entity: models::CreatorEntity) -> Box<dyn Future<Item = CreateCreatorResponse, Error = ApiError> + Send>;
+ fn delete_release_edit(
+ &self,
+ editgroup_id: String,
+ edit_id: String,
+ ) -> Box<dyn Future<Item = DeleteReleaseEditResponse, Error = ApiError> + Send>;
+
+ fn delete_webcapture(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ ) -> Box<dyn Future<Item = DeleteWebcaptureResponse, Error = ApiError> + Send>;
- fn create_creator_auto_batch(&self, auto_batch: models::CreatorAutoBatch) -> Box<dyn Future<Item = CreateCreatorAutoBatchResponse, Error = ApiError> + Send>;
+ fn delete_webcapture_edit(
+ &self,
+ editgroup_id: String,
+ edit_id: String,
+ ) -> Box<dyn Future<Item = DeleteWebcaptureEditResponse, Error = ApiError> + Send>;
- fn delete_creator(&self, editgroup_id: String, ident: String) -> Box<dyn Future<Item = DeleteCreatorResponse, Error = ApiError> + Send>;
+ fn delete_work(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ ) -> Box<dyn Future<Item = DeleteWorkResponse, Error = ApiError> + Send>;
- fn delete_creator_edit(&self, editgroup_id: String, edit_id: String) -> Box<dyn Future<Item = DeleteCreatorEditResponse, Error = ApiError> + Send>;
+ fn delete_work_edit(
+ &self,
+ editgroup_id: String,
+ edit_id: String,
+ ) -> Box<dyn Future<Item = DeleteWorkEditResponse, Error = ApiError> + Send>;
- fn get_creator(&self, ident: String, expand: Option<String>, hide: Option<String>) -> Box<dyn Future<Item = GetCreatorResponse, Error = ApiError> + Send>;
+ fn get_changelog(
+ &self,
+ limit: Option<i64>,
+ ) -> Box<dyn Future<Item = GetChangelogResponse, Error = ApiError> + Send>;
- fn get_creator_edit(&self, edit_id: String) -> Box<dyn Future<Item = GetCreatorEditResponse, Error = ApiError> + Send>;
+ fn get_changelog_entry(
+ &self,
+ index: i64,
+ ) -> Box<dyn Future<Item = GetChangelogEntryResponse, Error = ApiError> + Send>;
- fn get_creator_history(&self, ident: String, limit: Option<i64>) -> Box<dyn Future<Item = GetCreatorHistoryResponse, Error = ApiError> + Send>;
+ fn get_container(
+ &self,
+ ident: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ ) -> Box<dyn Future<Item = GetContainerResponse, Error = ApiError> + Send>;
- fn get_creator_redirects(&self, ident: String) -> Box<dyn Future<Item = GetCreatorRedirectsResponse, Error = ApiError> + Send>;
+ fn get_container_edit(
+ &self,
+ edit_id: String,
+ ) -> Box<dyn Future<Item = GetContainerEditResponse, Error = ApiError> + Send>;
- fn get_creator_releases(&self, ident: String, hide: Option<String>) -> Box<dyn Future<Item = GetCreatorReleasesResponse, Error = ApiError> + Send>;
+ fn get_container_history(
+ &self,
+ ident: String,
+ limit: Option<i64>,
+ ) -> Box<dyn Future<Item = GetContainerHistoryResponse, Error = ApiError> + Send>;
- fn get_creator_revision(&self, rev_id: String, expand: Option<String>, hide: Option<String>) -> Box<dyn Future<Item = GetCreatorRevisionResponse, Error = ApiError> + Send>;
+ fn get_container_redirects(
+ &self,
+ ident: String,
+ ) -> Box<dyn Future<Item = GetContainerRedirectsResponse, Error = ApiError> + Send>;
- fn lookup_creator(
+ fn get_container_revision(
&self,
- orcid: Option<String>,
- wikidata_qid: Option<String>,
+ rev_id: String,
expand: Option<String>,
hide: Option<String>,
- ) -> Box<dyn Future<Item = LookupCreatorResponse, Error = ApiError> + Send>;
+ ) -> Box<dyn Future<Item = GetContainerRevisionResponse, Error = ApiError> + Send>;
- fn update_creator(&self, editgroup_id: String, ident: String, entity: models::CreatorEntity) -> Box<dyn Future<Item = UpdateCreatorResponse, Error = ApiError> + Send>;
+ fn get_creator(
+ &self,
+ ident: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ ) -> Box<dyn Future<Item = GetCreatorResponse, Error = ApiError> + Send>;
- fn accept_editgroup(&self, editgroup_id: String) -> Box<dyn Future<Item = AcceptEditgroupResponse, Error = ApiError> + Send>;
+ fn get_creator_edit(
+ &self,
+ edit_id: String,
+ ) -> Box<dyn Future<Item = GetCreatorEditResponse, Error = ApiError> + Send>;
- fn create_editgroup(&self, editgroup: models::Editgroup) -> Box<dyn Future<Item = CreateEditgroupResponse, Error = ApiError> + Send>;
+ fn get_creator_history(
+ &self,
+ ident: String,
+ limit: Option<i64>,
+ ) -> Box<dyn Future<Item = GetCreatorHistoryResponse, Error = ApiError> + Send>;
- fn create_editgroup_annotation(&self, editgroup_id: String, annotation: models::EditgroupAnnotation) -> Box<dyn Future<Item = CreateEditgroupAnnotationResponse, Error = ApiError> + Send>;
+ fn get_creator_redirects(
+ &self,
+ ident: String,
+ ) -> Box<dyn Future<Item = GetCreatorRedirectsResponse, Error = ApiError> + Send>;
- fn get_editgroup(&self, editgroup_id: String) -> Box<dyn Future<Item = GetEditgroupResponse, Error = ApiError> + Send>;
+ fn get_creator_releases(
+ &self,
+ ident: String,
+ hide: Option<String>,
+ ) -> Box<dyn Future<Item = GetCreatorReleasesResponse, Error = ApiError> + Send>;
- fn get_editgroup_annotations(&self, editgroup_id: String, expand: Option<String>) -> Box<dyn Future<Item = GetEditgroupAnnotationsResponse, Error = ApiError> + Send>;
+ fn get_creator_revision(
+ &self,
+ rev_id: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ ) -> Box<dyn Future<Item = GetCreatorRevisionResponse, Error = ApiError> + Send>;
+
+ fn get_editgroup(
+ &self,
+ editgroup_id: String,
+ ) -> Box<dyn Future<Item = GetEditgroupResponse, Error = ApiError> + Send>;
+
+ fn get_editgroup_annotations(
+ &self,
+ editgroup_id: String,
+ expand: Option<String>,
+ ) -> Box<dyn Future<Item = GetEditgroupAnnotationsResponse, Error = ApiError> + Send>;
fn get_editgroups_reviewable(
&self,
@@ -1701,9 +2541,10 @@ pub trait ApiNoContext {
since: Option<chrono::DateTime<chrono::Utc>>,
) -> Box<dyn Future<Item = GetEditgroupsReviewableResponse, Error = ApiError> + Send>;
- fn update_editgroup(&self, editgroup_id: String, editgroup: models::Editgroup, submit: Option<bool>) -> Box<dyn Future<Item = UpdateEditgroupResponse, Error = ApiError> + Send>;
-
- fn get_editor(&self, editor_id: String) -> Box<dyn Future<Item = GetEditorResponse, Error = ApiError> + Send>;
+ fn get_editor(
+ &self,
+ editor_id: String,
+ ) -> Box<dyn Future<Item = GetEditorResponse, Error = ApiError> + Send>;
fn get_editor_annotations(
&self,
@@ -1721,80 +2562,204 @@ pub trait ApiNoContext {
since: Option<chrono::DateTime<chrono::Utc>>,
) -> Box<dyn Future<Item = GetEditorEditgroupsResponse, Error = ApiError> + Send>;
- fn update_editor(&self, editor_id: String, editor: models::Editor) -> Box<dyn Future<Item = UpdateEditorResponse, Error = ApiError> + Send>;
-
- fn create_file(&self, editgroup_id: String, entity: models::FileEntity) -> Box<dyn Future<Item = CreateFileResponse, Error = ApiError> + Send>;
+ fn get_file(
+ &self,
+ ident: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ ) -> Box<dyn Future<Item = GetFileResponse, Error = ApiError> + Send>;
- fn create_file_auto_batch(&self, auto_batch: models::FileAutoBatch) -> Box<dyn Future<Item = CreateFileAutoBatchResponse, Error = ApiError> + Send>;
+ fn get_file_edit(
+ &self,
+ edit_id: String,
+ ) -> Box<dyn Future<Item = GetFileEditResponse, Error = ApiError> + Send>;
- fn delete_file(&self, editgroup_id: String, ident: String) -> Box<dyn Future<Item = DeleteFileResponse, Error = ApiError> + Send>;
+ fn get_file_history(
+ &self,
+ ident: String,
+ limit: Option<i64>,
+ ) -> Box<dyn Future<Item = GetFileHistoryResponse, Error = ApiError> + Send>;
- fn delete_file_edit(&self, editgroup_id: String, edit_id: String) -> Box<dyn Future<Item = DeleteFileEditResponse, Error = ApiError> + Send>;
+ fn get_file_redirects(
+ &self,
+ ident: String,
+ ) -> Box<dyn Future<Item = GetFileRedirectsResponse, Error = ApiError> + Send>;
- fn get_file(&self, ident: String, expand: Option<String>, hide: Option<String>) -> Box<dyn Future<Item = GetFileResponse, Error = ApiError> + Send>;
+ fn get_file_revision(
+ &self,
+ rev_id: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ ) -> Box<dyn Future<Item = GetFileRevisionResponse, Error = ApiError> + Send>;
- fn get_file_edit(&self, edit_id: String) -> Box<dyn Future<Item = GetFileEditResponse, Error = ApiError> + Send>;
+ fn get_fileset(
+ &self,
+ ident: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ ) -> Box<dyn Future<Item = GetFilesetResponse, Error = ApiError> + Send>;
- fn get_file_history(&self, ident: String, limit: Option<i64>) -> Box<dyn Future<Item = GetFileHistoryResponse, Error = ApiError> + Send>;
+ fn get_fileset_edit(
+ &self,
+ edit_id: String,
+ ) -> Box<dyn Future<Item = GetFilesetEditResponse, Error = ApiError> + Send>;
- fn get_file_redirects(&self, ident: String) -> Box<dyn Future<Item = GetFileRedirectsResponse, Error = ApiError> + Send>;
+ fn get_fileset_history(
+ &self,
+ ident: String,
+ limit: Option<i64>,
+ ) -> Box<dyn Future<Item = GetFilesetHistoryResponse, Error = ApiError> + Send>;
- fn get_file_revision(&self, rev_id: String, expand: Option<String>, hide: Option<String>) -> Box<dyn Future<Item = GetFileRevisionResponse, Error = ApiError> + Send>;
+ fn get_fileset_redirects(
+ &self,
+ ident: String,
+ ) -> Box<dyn Future<Item = GetFilesetRedirectsResponse, Error = ApiError> + Send>;
- fn lookup_file(
+ fn get_fileset_revision(
&self,
- md5: Option<String>,
- sha1: Option<String>,
- sha256: Option<String>,
+ rev_id: String,
expand: Option<String>,
hide: Option<String>,
- ) -> Box<dyn Future<Item = LookupFileResponse, Error = ApiError> + Send>;
+ ) -> Box<dyn Future<Item = GetFilesetRevisionResponse, Error = ApiError> + Send>;
- fn update_file(&self, editgroup_id: String, ident: String, entity: models::FileEntity) -> Box<dyn Future<Item = UpdateFileResponse, Error = ApiError> + Send>;
-
- fn create_fileset(&self, editgroup_id: String, entity: models::FilesetEntity) -> Box<dyn Future<Item = CreateFilesetResponse, Error = ApiError> + Send>;
+ fn get_release(
+ &self,
+ ident: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ ) -> Box<dyn Future<Item = GetReleaseResponse, Error = ApiError> + Send>;
- fn create_fileset_auto_batch(&self, auto_batch: models::FilesetAutoBatch) -> Box<dyn Future<Item = CreateFilesetAutoBatchResponse, Error = ApiError> + Send>;
+ fn get_release_edit(
+ &self,
+ edit_id: String,
+ ) -> Box<dyn Future<Item = GetReleaseEditResponse, Error = ApiError> + Send>;
- fn delete_fileset(&self, editgroup_id: String, ident: String) -> Box<dyn Future<Item = DeleteFilesetResponse, Error = ApiError> + Send>;
+ fn get_release_files(
+ &self,
+ ident: String,
+ hide: Option<String>,
+ ) -> Box<dyn Future<Item = GetReleaseFilesResponse, Error = ApiError> + Send>;
- fn delete_fileset_edit(&self, editgroup_id: String, edit_id: String) -> Box<dyn Future<Item = DeleteFilesetEditResponse, Error = ApiError> + Send>;
+ fn get_release_filesets(
+ &self,
+ ident: String,
+ hide: Option<String>,
+ ) -> Box<dyn Future<Item = GetReleaseFilesetsResponse, Error = ApiError> + Send>;
- fn get_fileset(&self, ident: String, expand: Option<String>, hide: Option<String>) -> Box<dyn Future<Item = GetFilesetResponse, Error = ApiError> + Send>;
+ fn get_release_history(
+ &self,
+ ident: String,
+ limit: Option<i64>,
+ ) -> Box<dyn Future<Item = GetReleaseHistoryResponse, Error = ApiError> + Send>;
- fn get_fileset_edit(&self, edit_id: String) -> Box<dyn Future<Item = GetFilesetEditResponse, Error = ApiError> + Send>;
+ fn get_release_redirects(
+ &self,
+ ident: String,
+ ) -> Box<dyn Future<Item = GetReleaseRedirectsResponse, Error = ApiError> + Send>;
- fn get_fileset_history(&self, ident: String, limit: Option<i64>) -> Box<dyn Future<Item = GetFilesetHistoryResponse, Error = ApiError> + Send>;
+ fn get_release_revision(
+ &self,
+ rev_id: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ ) -> Box<dyn Future<Item = GetReleaseRevisionResponse, Error = ApiError> + Send>;
- fn get_fileset_redirects(&self, ident: String) -> Box<dyn Future<Item = GetFilesetRedirectsResponse, Error = ApiError> + Send>;
+ fn get_release_webcaptures(
+ &self,
+ ident: String,
+ hide: Option<String>,
+ ) -> Box<dyn Future<Item = GetReleaseWebcapturesResponse, Error = ApiError> + Send>;
- fn get_fileset_revision(&self, rev_id: String, expand: Option<String>, hide: Option<String>) -> Box<dyn Future<Item = GetFilesetRevisionResponse, Error = ApiError> + Send>;
+ fn get_webcapture(
+ &self,
+ ident: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ ) -> Box<dyn Future<Item = GetWebcaptureResponse, Error = ApiError> + Send>;
- fn update_fileset(&self, editgroup_id: String, ident: String, entity: models::FilesetEntity) -> Box<dyn Future<Item = UpdateFilesetResponse, Error = ApiError> + Send>;
+ fn get_webcapture_edit(
+ &self,
+ edit_id: String,
+ ) -> Box<dyn Future<Item = GetWebcaptureEditResponse, Error = ApiError> + Send>;
- fn create_release(&self, editgroup_id: String, entity: models::ReleaseEntity) -> Box<dyn Future<Item = CreateReleaseResponse, Error = ApiError> + Send>;
+ fn get_webcapture_history(
+ &self,
+ ident: String,
+ limit: Option<i64>,
+ ) -> Box<dyn Future<Item = GetWebcaptureHistoryResponse, Error = ApiError> + Send>;
- fn create_release_auto_batch(&self, auto_batch: models::ReleaseAutoBatch) -> Box<dyn Future<Item = CreateReleaseAutoBatchResponse, Error = ApiError> + Send>;
+ fn get_webcapture_redirects(
+ &self,
+ ident: String,
+ ) -> Box<dyn Future<Item = GetWebcaptureRedirectsResponse, Error = ApiError> + Send>;
- fn delete_release(&self, editgroup_id: String, ident: String) -> Box<dyn Future<Item = DeleteReleaseResponse, Error = ApiError> + Send>;
+ fn get_webcapture_revision(
+ &self,
+ rev_id: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ ) -> Box<dyn Future<Item = GetWebcaptureRevisionResponse, Error = ApiError> + Send>;
- fn delete_release_edit(&self, editgroup_id: String, edit_id: String) -> Box<dyn Future<Item = DeleteReleaseEditResponse, Error = ApiError> + Send>;
+ fn get_work(
+ &self,
+ ident: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ ) -> Box<dyn Future<Item = GetWorkResponse, Error = ApiError> + Send>;
- fn get_release(&self, ident: String, expand: Option<String>, hide: Option<String>) -> Box<dyn Future<Item = GetReleaseResponse, Error = ApiError> + Send>;
+ fn get_work_edit(
+ &self,
+ edit_id: String,
+ ) -> Box<dyn Future<Item = GetWorkEditResponse, Error = ApiError> + Send>;
- fn get_release_edit(&self, edit_id: String) -> Box<dyn Future<Item = GetReleaseEditResponse, Error = ApiError> + Send>;
+ fn get_work_history(
+ &self,
+ ident: String,
+ limit: Option<i64>,
+ ) -> Box<dyn Future<Item = GetWorkHistoryResponse, Error = ApiError> + Send>;
- fn get_release_files(&self, ident: String, hide: Option<String>) -> Box<dyn Future<Item = GetReleaseFilesResponse, Error = ApiError> + Send>;
+ fn get_work_redirects(
+ &self,
+ ident: String,
+ ) -> Box<dyn Future<Item = GetWorkRedirectsResponse, Error = ApiError> + Send>;
- fn get_release_filesets(&self, ident: String, hide: Option<String>) -> Box<dyn Future<Item = GetReleaseFilesetsResponse, Error = ApiError> + Send>;
+ fn get_work_releases(
+ &self,
+ ident: String,
+ hide: Option<String>,
+ ) -> Box<dyn Future<Item = GetWorkReleasesResponse, Error = ApiError> + Send>;
- fn get_release_history(&self, ident: String, limit: Option<i64>) -> Box<dyn Future<Item = GetReleaseHistoryResponse, Error = ApiError> + Send>;
+ fn get_work_revision(
+ &self,
+ rev_id: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ ) -> Box<dyn Future<Item = GetWorkRevisionResponse, Error = ApiError> + Send>;
- fn get_release_redirects(&self, ident: String) -> Box<dyn Future<Item = GetReleaseRedirectsResponse, Error = ApiError> + Send>;
+ fn lookup_container(
+ &self,
+ issnl: Option<String>,
+ wikidata_qid: Option<String>,
+ expand: Option<String>,
+ hide: Option<String>,
+ ) -> Box<dyn Future<Item = LookupContainerResponse, Error = ApiError> + Send>;
- fn get_release_revision(&self, rev_id: String, expand: Option<String>, hide: Option<String>) -> Box<dyn Future<Item = GetReleaseRevisionResponse, Error = ApiError> + Send>;
+ fn lookup_creator(
+ &self,
+ orcid: Option<String>,
+ wikidata_qid: Option<String>,
+ expand: Option<String>,
+ hide: Option<String>,
+ ) -> Box<dyn Future<Item = LookupCreatorResponse, Error = ApiError> + Send>;
- fn get_release_webcaptures(&self, ident: String, hide: Option<String>) -> Box<dyn Future<Item = GetReleaseWebcapturesResponse, Error = ApiError> + Send>;
+ fn lookup_file(
+ &self,
+ md5: Option<String>,
+ sha1: Option<String>,
+ sha256: Option<String>,
+ expand: Option<String>,
+ hide: Option<String>,
+ ) -> Box<dyn Future<Item = LookupFileResponse, Error = ApiError> + Send>;
fn lookup_release(
&self,
@@ -1812,209 +2777,496 @@ pub trait ApiNoContext {
hide: Option<String>,
) -> Box<dyn Future<Item = LookupReleaseResponse, Error = ApiError> + Send>;
- fn update_release(&self, editgroup_id: String, ident: String, entity: models::ReleaseEntity) -> Box<dyn Future<Item = UpdateReleaseResponse, Error = ApiError> + Send>;
+ fn update_container(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ entity: models::ContainerEntity,
+ ) -> Box<dyn Future<Item = UpdateContainerResponse, Error = ApiError> + Send>;
- fn create_webcapture(&self, editgroup_id: String, entity: models::WebcaptureEntity) -> Box<dyn Future<Item = CreateWebcaptureResponse, Error = ApiError> + Send>;
+ fn update_creator(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ entity: models::CreatorEntity,
+ ) -> Box<dyn Future<Item = UpdateCreatorResponse, Error = ApiError> + Send>;
- fn create_webcapture_auto_batch(&self, auto_batch: models::WebcaptureAutoBatch) -> Box<dyn Future<Item = CreateWebcaptureAutoBatchResponse, Error = ApiError> + Send>;
+ fn update_editgroup(
+ &self,
+ editgroup_id: String,
+ editgroup: models::Editgroup,
+ submit: Option<bool>,
+ ) -> Box<dyn Future<Item = UpdateEditgroupResponse, Error = ApiError> + Send>;
- fn delete_webcapture(&self, editgroup_id: String, ident: String) -> Box<dyn Future<Item = DeleteWebcaptureResponse, Error = ApiError> + Send>;
+ fn update_editor(
+ &self,
+ editor_id: String,
+ editor: models::Editor,
+ ) -> Box<dyn Future<Item = UpdateEditorResponse, Error = ApiError> + Send>;
- fn delete_webcapture_edit(&self, editgroup_id: String, edit_id: String) -> Box<dyn Future<Item = DeleteWebcaptureEditResponse, Error = ApiError> + Send>;
+ fn update_file(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ entity: models::FileEntity,
+ ) -> Box<dyn Future<Item = UpdateFileResponse, Error = ApiError> + Send>;
- fn get_webcapture(&self, ident: String, expand: Option<String>, hide: Option<String>) -> Box<dyn Future<Item = GetWebcaptureResponse, Error = ApiError> + Send>;
+ fn update_fileset(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ entity: models::FilesetEntity,
+ ) -> Box<dyn Future<Item = UpdateFilesetResponse, Error = ApiError> + Send>;
- fn get_webcapture_edit(&self, edit_id: String) -> Box<dyn Future<Item = GetWebcaptureEditResponse, Error = ApiError> + Send>;
+ fn update_release(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ entity: models::ReleaseEntity,
+ ) -> Box<dyn Future<Item = UpdateReleaseResponse, Error = ApiError> + Send>;
+
+ fn update_webcapture(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ entity: models::WebcaptureEntity,
+ ) -> Box<dyn Future<Item = UpdateWebcaptureResponse, Error = ApiError> + Send>;
- fn get_webcapture_history(&self, ident: String, limit: Option<i64>) -> Box<dyn Future<Item = GetWebcaptureHistoryResponse, Error = ApiError> + Send>;
+ fn update_work(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ entity: models::WorkEntity,
+ ) -> Box<dyn Future<Item = UpdateWorkResponse, Error = ApiError> + Send>;
+}
+
+/// Trait to extend an API to make it easy to bind it to a context.
+pub trait ContextWrapperExt<'a, C>
+where
+ Self: Sized,
+{
+ /// Binds this API to a context.
+ fn with_context(self: &'a Self, context: C) -> ContextWrapper<'a, Self, C>;
+}
- fn get_webcapture_redirects(&self, ident: String) -> Box<dyn Future<Item = GetWebcaptureRedirectsResponse, Error = ApiError> + Send>;
+impl<'a, T: Api<C> + Sized, C> ContextWrapperExt<'a, C> for T {
+ fn with_context(self: &'a T, context: C) -> ContextWrapper<'a, T, C> {
+ ContextWrapper::<T, C>::new(self, context)
+ }
+}
- fn get_webcapture_revision(&self, rev_id: String, expand: Option<String>, hide: Option<String>) -> Box<dyn Future<Item = GetWebcaptureRevisionResponse, Error = ApiError> + Send>;
+impl<'a, T: Api<C>, C> ApiNoContext for ContextWrapper<'a, T, C> {
+ fn accept_editgroup(
+ &self,
+ editgroup_id: String,
+ ) -> Box<dyn Future<Item = AcceptEditgroupResponse, Error = ApiError> + Send> {
+ self.api().accept_editgroup(editgroup_id, &self.context())
+ }
- fn update_webcapture(&self, editgroup_id: String, ident: String, entity: models::WebcaptureEntity) -> Box<dyn Future<Item = UpdateWebcaptureResponse, Error = ApiError> + Send>;
+ fn auth_check(
+ &self,
+ role: Option<String>,
+ ) -> Box<dyn Future<Item = AuthCheckResponse, Error = ApiError> + Send> {
+ self.api().auth_check(role, &self.context())
+ }
- fn create_work(&self, editgroup_id: String, entity: models::WorkEntity) -> Box<dyn Future<Item = CreateWorkResponse, Error = ApiError> + Send>;
+ fn auth_oidc(
+ &self,
+ oidc_params: models::AuthOidc,
+ ) -> Box<dyn Future<Item = AuthOidcResponse, Error = ApiError> + Send> {
+ self.api().auth_oidc(oidc_params, &self.context())
+ }
- fn create_work_auto_batch(&self, auto_batch: models::WorkAutoBatch) -> Box<dyn Future<Item = CreateWorkAutoBatchResponse, Error = ApiError> + Send>;
+ fn create_auth_token(
+ &self,
+ editor_id: String,
+ duration_seconds: Option<i32>,
+ ) -> Box<dyn Future<Item = CreateAuthTokenResponse, Error = ApiError> + Send> {
+ self.api()
+ .create_auth_token(editor_id, duration_seconds, &self.context())
+ }
- fn delete_work(&self, editgroup_id: String, ident: String) -> Box<dyn Future<Item = DeleteWorkResponse, Error = ApiError> + Send>;
+ fn create_container(
+ &self,
+ editgroup_id: String,
+ entity: models::ContainerEntity,
+ ) -> Box<dyn Future<Item = CreateContainerResponse, Error = ApiError> + Send> {
+ self.api()
+ .create_container(editgroup_id, entity, &self.context())
+ }
- fn delete_work_edit(&self, editgroup_id: String, edit_id: String) -> Box<dyn Future<Item = DeleteWorkEditResponse, Error = ApiError> + Send>;
+ fn create_container_auto_batch(
+ &self,
+ auto_batch: models::ContainerAutoBatch,
+ ) -> Box<dyn Future<Item = CreateContainerAutoBatchResponse, Error = ApiError> + Send> {
+ self.api()
+ .create_container_auto_batch(auto_batch, &self.context())
+ }
- fn get_work(&self, ident: String, expand: Option<String>, hide: Option<String>) -> Box<dyn Future<Item = GetWorkResponse, Error = ApiError> + Send>;
+ fn create_creator(
+ &self,
+ editgroup_id: String,
+ entity: models::CreatorEntity,
+ ) -> Box<dyn Future<Item = CreateCreatorResponse, Error = ApiError> + Send> {
+ self.api()
+ .create_creator(editgroup_id, entity, &self.context())
+ }
- fn get_work_edit(&self, edit_id: String) -> Box<dyn Future<Item = GetWorkEditResponse, Error = ApiError> + Send>;
+ fn create_creator_auto_batch(
+ &self,
+ auto_batch: models::CreatorAutoBatch,
+ ) -> Box<dyn Future<Item = CreateCreatorAutoBatchResponse, Error = ApiError> + Send> {
+ self.api()
+ .create_creator_auto_batch(auto_batch, &self.context())
+ }
- fn get_work_history(&self, ident: String, limit: Option<i64>) -> Box<dyn Future<Item = GetWorkHistoryResponse, Error = ApiError> + Send>;
+ fn create_editgroup(
+ &self,
+ editgroup: models::Editgroup,
+ ) -> Box<dyn Future<Item = CreateEditgroupResponse, Error = ApiError> + Send> {
+ self.api().create_editgroup(editgroup, &self.context())
+ }
- fn get_work_redirects(&self, ident: String) -> Box<dyn Future<Item = GetWorkRedirectsResponse, Error = ApiError> + Send>;
+ fn create_editgroup_annotation(
+ &self,
+ editgroup_id: String,
+ annotation: models::EditgroupAnnotation,
+ ) -> Box<dyn Future<Item = CreateEditgroupAnnotationResponse, Error = ApiError> + Send> {
+ self.api()
+ .create_editgroup_annotation(editgroup_id, annotation, &self.context())
+ }
- fn get_work_releases(&self, ident: String, hide: Option<String>) -> Box<dyn Future<Item = GetWorkReleasesResponse, Error = ApiError> + Send>;
+ fn create_file(
+ &self,
+ editgroup_id: String,
+ entity: models::FileEntity,
+ ) -> Box<dyn Future<Item = CreateFileResponse, Error = ApiError> + Send> {
+ self.api()
+ .create_file(editgroup_id, entity, &self.context())
+ }
- fn get_work_revision(&self, rev_id: String, expand: Option<String>, hide: Option<String>) -> Box<dyn Future<Item = GetWorkRevisionResponse, Error = ApiError> + Send>;
+ fn create_file_auto_batch(
+ &self,
+ auto_batch: models::FileAutoBatch,
+ ) -> Box<dyn Future<Item = CreateFileAutoBatchResponse, Error = ApiError> + Send> {
+ self.api()
+ .create_file_auto_batch(auto_batch, &self.context())
+ }
- fn update_work(&self, editgroup_id: String, ident: String, entity: models::WorkEntity) -> Box<dyn Future<Item = UpdateWorkResponse, Error = ApiError> + Send>;
-}
+ fn create_fileset(
+ &self,
+ editgroup_id: String,
+ entity: models::FilesetEntity,
+ ) -> Box<dyn Future<Item = CreateFilesetResponse, Error = ApiError> + Send> {
+ self.api()
+ .create_fileset(editgroup_id, entity, &self.context())
+ }
-/// 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>;
-}
+ fn create_fileset_auto_batch(
+ &self,
+ auto_batch: models::FilesetAutoBatch,
+ ) -> Box<dyn Future<Item = CreateFilesetAutoBatchResponse, Error = ApiError> + Send> {
+ self.api()
+ .create_fileset_auto_batch(auto_batch, &self.context())
+ }
-impl<'a, T: Api + Sized> ContextWrapperExt<'a> for T {
- fn with_context(self: &'a T, context: Context) -> ContextWrapper<'a, T> {
- ContextWrapper::<T>::new(self, context)
+ fn create_release(
+ &self,
+ editgroup_id: String,
+ entity: models::ReleaseEntity,
+ ) -> Box<dyn Future<Item = CreateReleaseResponse, Error = ApiError> + Send> {
+ self.api()
+ .create_release(editgroup_id, entity, &self.context())
}
-}
-impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> {
- fn auth_check(&self, role: Option<String>) -> Box<dyn Future<Item = AuthCheckResponse, Error = ApiError> + Send> {
- self.api().auth_check(role, &self.context())
+ fn create_release_auto_batch(
+ &self,
+ auto_batch: models::ReleaseAutoBatch,
+ ) -> Box<dyn Future<Item = CreateReleaseAutoBatchResponse, Error = ApiError> + Send> {
+ self.api()
+ .create_release_auto_batch(auto_batch, &self.context())
}
- fn auth_oidc(&self, oidc_params: models::AuthOidc) -> Box<dyn Future<Item = AuthOidcResponse, Error = ApiError> + Send> {
- self.api().auth_oidc(oidc_params, &self.context())
+ fn create_webcapture(
+ &self,
+ editgroup_id: String,
+ entity: models::WebcaptureEntity,
+ ) -> Box<dyn Future<Item = CreateWebcaptureResponse, Error = ApiError> + Send> {
+ self.api()
+ .create_webcapture(editgroup_id, entity, &self.context())
}
- fn create_auth_token(&self, editor_id: String, duration_seconds: Option<i32>) -> Box<dyn Future<Item = CreateAuthTokenResponse, Error = ApiError> + Send> {
- self.api().create_auth_token(editor_id, duration_seconds, &self.context())
+ fn create_webcapture_auto_batch(
+ &self,
+ auto_batch: models::WebcaptureAutoBatch,
+ ) -> Box<dyn Future<Item = CreateWebcaptureAutoBatchResponse, Error = ApiError> + Send> {
+ self.api()
+ .create_webcapture_auto_batch(auto_batch, &self.context())
}
- fn get_changelog(&self, limit: Option<i64>) -> Box<dyn Future<Item = GetChangelogResponse, Error = ApiError> + Send> {
- self.api().get_changelog(limit, &self.context())
+ fn create_work(
+ &self,
+ editgroup_id: String,
+ entity: models::WorkEntity,
+ ) -> Box<dyn Future<Item = CreateWorkResponse, Error = ApiError> + Send> {
+ self.api()
+ .create_work(editgroup_id, entity, &self.context())
}
- fn get_changelog_entry(&self, index: i64) -> Box<dyn Future<Item = GetChangelogEntryResponse, Error = ApiError> + Send> {
- self.api().get_changelog_entry(index, &self.context())
+ fn create_work_auto_batch(
+ &self,
+ auto_batch: models::WorkAutoBatch,
+ ) -> Box<dyn Future<Item = CreateWorkAutoBatchResponse, Error = ApiError> + Send> {
+ self.api()
+ .create_work_auto_batch(auto_batch, &self.context())
}
- fn create_container(&self, editgroup_id: String, entity: models::ContainerEntity) -> Box<dyn Future<Item = CreateContainerResponse, Error = ApiError> + Send> {
- self.api().create_container(editgroup_id, entity, &self.context())
+ fn delete_container(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ ) -> Box<dyn Future<Item = DeleteContainerResponse, Error = ApiError> + Send> {
+ self.api()
+ .delete_container(editgroup_id, ident, &self.context())
}
- fn create_container_auto_batch(&self, auto_batch: models::ContainerAutoBatch) -> Box<dyn Future<Item = CreateContainerAutoBatchResponse, Error = ApiError> + Send> {
- self.api().create_container_auto_batch(auto_batch, &self.context())
+ fn delete_container_edit(
+ &self,
+ editgroup_id: String,
+ edit_id: String,
+ ) -> Box<dyn Future<Item = DeleteContainerEditResponse, Error = ApiError> + Send> {
+ self.api()
+ .delete_container_edit(editgroup_id, edit_id, &self.context())
}
- fn delete_container(&self, editgroup_id: String, ident: String) -> Box<dyn Future<Item = DeleteContainerResponse, Error = ApiError> + Send> {
- self.api().delete_container(editgroup_id, ident, &self.context())
+ fn delete_creator(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ ) -> Box<dyn Future<Item = DeleteCreatorResponse, Error = ApiError> + Send> {
+ self.api()
+ .delete_creator(editgroup_id, ident, &self.context())
}
- fn delete_container_edit(&self, editgroup_id: String, edit_id: String) -> Box<dyn Future<Item = DeleteContainerEditResponse, Error = ApiError> + Send> {
- self.api().delete_container_edit(editgroup_id, edit_id, &self.context())
+ fn delete_creator_edit(
+ &self,
+ editgroup_id: String,
+ edit_id: String,
+ ) -> Box<dyn Future<Item = DeleteCreatorEditResponse, Error = ApiError> + Send> {
+ self.api()
+ .delete_creator_edit(editgroup_id, edit_id, &self.context())
}
- fn get_container(&self, ident: String, expand: Option<String>, hide: Option<String>) -> Box<dyn Future<Item = GetContainerResponse, Error = ApiError> + Send> {
- self.api().get_container(ident, expand, hide, &self.context())
+ fn delete_file(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ ) -> Box<dyn Future<Item = DeleteFileResponse, Error = ApiError> + Send> {
+ self.api().delete_file(editgroup_id, ident, &self.context())
}
- fn get_container_edit(&self, edit_id: String) -> Box<dyn Future<Item = GetContainerEditResponse, Error = ApiError> + Send> {
- self.api().get_container_edit(edit_id, &self.context())
+ fn delete_file_edit(
+ &self,
+ editgroup_id: String,
+ edit_id: String,
+ ) -> Box<dyn Future<Item = DeleteFileEditResponse, Error = ApiError> + Send> {
+ self.api()
+ .delete_file_edit(editgroup_id, edit_id, &self.context())
}
- fn get_container_history(&self, ident: String, limit: Option<i64>) -> Box<dyn Future<Item = GetContainerHistoryResponse, Error = ApiError> + Send> {
- self.api().get_container_history(ident, limit, &self.context())
+ fn delete_fileset(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ ) -> Box<dyn Future<Item = DeleteFilesetResponse, Error = ApiError> + Send> {
+ self.api()
+ .delete_fileset(editgroup_id, ident, &self.context())
}
- fn get_container_redirects(&self, ident: String) -> Box<dyn Future<Item = GetContainerRedirectsResponse, Error = ApiError> + Send> {
- self.api().get_container_redirects(ident, &self.context())
+ fn delete_fileset_edit(
+ &self,
+ editgroup_id: String,
+ edit_id: String,
+ ) -> Box<dyn Future<Item = DeleteFilesetEditResponse, Error = ApiError> + Send> {
+ self.api()
+ .delete_fileset_edit(editgroup_id, edit_id, &self.context())
}
- fn get_container_revision(&self, rev_id: String, expand: Option<String>, hide: Option<String>) -> Box<dyn Future<Item = GetContainerRevisionResponse, Error = ApiError> + Send> {
- self.api().get_container_revision(rev_id, expand, hide, &self.context())
+ fn delete_release(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ ) -> Box<dyn Future<Item = DeleteReleaseResponse, Error = ApiError> + Send> {
+ self.api()
+ .delete_release(editgroup_id, ident, &self.context())
}
- fn lookup_container(
+ fn delete_release_edit(
&self,
- issnl: Option<String>,
- wikidata_qid: Option<String>,
- expand: Option<String>,
- hide: Option<String>,
- ) -> Box<dyn Future<Item = LookupContainerResponse, Error = ApiError> + Send> {
- self.api().lookup_container(issnl, wikidata_qid, expand, hide, &self.context())
+ editgroup_id: String,
+ edit_id: String,
+ ) -> Box<dyn Future<Item = DeleteReleaseEditResponse, Error = ApiError> + Send> {
+ self.api()
+ .delete_release_edit(editgroup_id, edit_id, &self.context())
}
- fn update_container(&self, editgroup_id: String, ident: String, entity: models::ContainerEntity) -> Box<dyn Future<Item = UpdateContainerResponse, Error = ApiError> + Send> {
- self.api().update_container(editgroup_id, ident, entity, &self.context())
+ fn delete_webcapture(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ ) -> Box<dyn Future<Item = DeleteWebcaptureResponse, Error = ApiError> + Send> {
+ self.api()
+ .delete_webcapture(editgroup_id, ident, &self.context())
}
- fn create_creator(&self, editgroup_id: String, entity: models::CreatorEntity) -> Box<dyn Future<Item = CreateCreatorResponse, Error = ApiError> + Send> {
- self.api().create_creator(editgroup_id, entity, &self.context())
+ fn delete_webcapture_edit(
+ &self,
+ editgroup_id: String,
+ edit_id: String,
+ ) -> Box<dyn Future<Item = DeleteWebcaptureEditResponse, Error = ApiError> + Send> {
+ self.api()
+ .delete_webcapture_edit(editgroup_id, edit_id, &self.context())
}
- fn create_creator_auto_batch(&self, auto_batch: models::CreatorAutoBatch) -> Box<dyn Future<Item = CreateCreatorAutoBatchResponse, Error = ApiError> + Send> {
- self.api().create_creator_auto_batch(auto_batch, &self.context())
+ fn delete_work(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ ) -> Box<dyn Future<Item = DeleteWorkResponse, Error = ApiError> + Send> {
+ self.api().delete_work(editgroup_id, ident, &self.context())
}
- fn delete_creator(&self, editgroup_id: String, ident: String) -> Box<dyn Future<Item = DeleteCreatorResponse, Error = ApiError> + Send> {
- self.api().delete_creator(editgroup_id, ident, &self.context())
+ fn delete_work_edit(
+ &self,
+ editgroup_id: String,
+ edit_id: String,
+ ) -> Box<dyn Future<Item = DeleteWorkEditResponse, Error = ApiError> + Send> {
+ self.api()
+ .delete_work_edit(editgroup_id, edit_id, &self.context())
}
- fn delete_creator_edit(&self, editgroup_id: String, edit_id: String) -> Box<dyn Future<Item = DeleteCreatorEditResponse, Error = ApiError> + Send> {
- self.api().delete_creator_edit(editgroup_id, edit_id, &self.context())
+ fn get_changelog(
+ &self,
+ limit: Option<i64>,
+ ) -> Box<dyn Future<Item = GetChangelogResponse, Error = ApiError> + Send> {
+ self.api().get_changelog(limit, &self.context())
}
- fn get_creator(&self, ident: String, expand: Option<String>, hide: Option<String>) -> Box<dyn Future<Item = GetCreatorResponse, Error = ApiError> + Send> {
- self.api().get_creator(ident, expand, hide, &self.context())
+ fn get_changelog_entry(
+ &self,
+ index: i64,
+ ) -> Box<dyn Future<Item = GetChangelogEntryResponse, Error = ApiError> + Send> {
+ self.api().get_changelog_entry(index, &self.context())
}
- fn get_creator_edit(&self, edit_id: String) -> Box<dyn Future<Item = GetCreatorEditResponse, Error = ApiError> + Send> {
- self.api().get_creator_edit(edit_id, &self.context())
+ fn get_container(
+ &self,
+ ident: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ ) -> Box<dyn Future<Item = GetContainerResponse, Error = ApiError> + Send> {
+ self.api()
+ .get_container(ident, expand, hide, &self.context())
}
- fn get_creator_history(&self, ident: String, limit: Option<i64>) -> Box<dyn Future<Item = GetCreatorHistoryResponse, Error = ApiError> + Send> {
- self.api().get_creator_history(ident, limit, &self.context())
+ fn get_container_edit(
+ &self,
+ edit_id: String,
+ ) -> Box<dyn Future<Item = GetContainerEditResponse, Error = ApiError> + Send> {
+ self.api().get_container_edit(edit_id, &self.context())
}
- fn get_creator_redirects(&self, ident: String) -> Box<dyn Future<Item = GetCreatorRedirectsResponse, Error = ApiError> + Send> {
- self.api().get_creator_redirects(ident, &self.context())
+ fn get_container_history(
+ &self,
+ ident: String,
+ limit: Option<i64>,
+ ) -> Box<dyn Future<Item = GetContainerHistoryResponse, Error = ApiError> + Send> {
+ self.api()
+ .get_container_history(ident, limit, &self.context())
}
- fn get_creator_releases(&self, ident: String, hide: Option<String>) -> Box<dyn Future<Item = GetCreatorReleasesResponse, Error = ApiError> + Send> {
- self.api().get_creator_releases(ident, hide, &self.context())
+ fn get_container_redirects(
+ &self,
+ ident: String,
+ ) -> Box<dyn Future<Item = GetContainerRedirectsResponse, Error = ApiError> + Send> {
+ self.api().get_container_redirects(ident, &self.context())
}
- fn get_creator_revision(&self, rev_id: String, expand: Option<String>, hide: Option<String>) -> Box<dyn Future<Item = GetCreatorRevisionResponse, Error = ApiError> + Send> {
- self.api().get_creator_revision(rev_id, expand, hide, &self.context())
+ fn get_container_revision(
+ &self,
+ rev_id: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ ) -> Box<dyn Future<Item = GetContainerRevisionResponse, Error = ApiError> + Send> {
+ self.api()
+ .get_container_revision(rev_id, expand, hide, &self.context())
}
- fn lookup_creator(
+ fn get_creator(
&self,
- orcid: Option<String>,
- wikidata_qid: Option<String>,
+ ident: String,
expand: Option<String>,
hide: Option<String>,
- ) -> Box<dyn Future<Item = LookupCreatorResponse, Error = ApiError> + Send> {
- self.api().lookup_creator(orcid, wikidata_qid, expand, hide, &self.context())
+ ) -> Box<dyn Future<Item = GetCreatorResponse, Error = ApiError> + Send> {
+ self.api().get_creator(ident, expand, hide, &self.context())
}
- fn update_creator(&self, editgroup_id: String, ident: String, entity: models::CreatorEntity) -> Box<dyn Future<Item = UpdateCreatorResponse, Error = ApiError> + Send> {
- self.api().update_creator(editgroup_id, ident, entity, &self.context())
+ fn get_creator_edit(
+ &self,
+ edit_id: String,
+ ) -> Box<dyn Future<Item = GetCreatorEditResponse, Error = ApiError> + Send> {
+ self.api().get_creator_edit(edit_id, &self.context())
}
- fn accept_editgroup(&self, editgroup_id: String) -> Box<dyn Future<Item = AcceptEditgroupResponse, Error = ApiError> + Send> {
- self.api().accept_editgroup(editgroup_id, &self.context())
+ fn get_creator_history(
+ &self,
+ ident: String,
+ limit: Option<i64>,
+ ) -> Box<dyn Future<Item = GetCreatorHistoryResponse, Error = ApiError> + Send> {
+ self.api()
+ .get_creator_history(ident, limit, &self.context())
}
- fn create_editgroup(&self, editgroup: models::Editgroup) -> Box<dyn Future<Item = CreateEditgroupResponse, Error = ApiError> + Send> {
- self.api().create_editgroup(editgroup, &self.context())
+ fn get_creator_redirects(
+ &self,
+ ident: String,
+ ) -> Box<dyn Future<Item = GetCreatorRedirectsResponse, Error = ApiError> + Send> {
+ self.api().get_creator_redirects(ident, &self.context())
}
- fn create_editgroup_annotation(&self, editgroup_id: String, annotation: models::EditgroupAnnotation) -> Box<dyn Future<Item = CreateEditgroupAnnotationResponse, Error = ApiError> + Send> {
- self.api().create_editgroup_annotation(editgroup_id, annotation, &self.context())
+ fn get_creator_releases(
+ &self,
+ ident: String,
+ hide: Option<String>,
+ ) -> Box<dyn Future<Item = GetCreatorReleasesResponse, Error = ApiError> + Send> {
+ self.api()
+ .get_creator_releases(ident, hide, &self.context())
}
- fn get_editgroup(&self, editgroup_id: String) -> Box<dyn Future<Item = GetEditgroupResponse, Error = ApiError> + Send> {
+ fn get_creator_revision(
+ &self,
+ rev_id: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ ) -> Box<dyn Future<Item = GetCreatorRevisionResponse, Error = ApiError> + Send> {
+ self.api()
+ .get_creator_revision(rev_id, expand, hide, &self.context())
+ }
+
+ fn get_editgroup(
+ &self,
+ editgroup_id: String,
+ ) -> Box<dyn Future<Item = GetEditgroupResponse, Error = ApiError> + Send> {
self.api().get_editgroup(editgroup_id, &self.context())
}
- fn get_editgroup_annotations(&self, editgroup_id: String, expand: Option<String>) -> Box<dyn Future<Item = GetEditgroupAnnotationsResponse, Error = ApiError> + Send> {
- self.api().get_editgroup_annotations(editgroup_id, expand, &self.context())
+ fn get_editgroup_annotations(
+ &self,
+ editgroup_id: String,
+ expand: Option<String>,
+ ) -> Box<dyn Future<Item = GetEditgroupAnnotationsResponse, Error = ApiError> + Send> {
+ self.api()
+ .get_editgroup_annotations(editgroup_id, expand, &self.context())
}
fn get_editgroups_reviewable(
@@ -2024,14 +3276,14 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> {
before: Option<chrono::DateTime<chrono::Utc>>,
since: Option<chrono::DateTime<chrono::Utc>>,
) -> Box<dyn Future<Item = GetEditgroupsReviewableResponse, Error = ApiError> + Send> {
- self.api().get_editgroups_reviewable(expand, limit, before, since, &self.context())
- }
-
- fn update_editgroup(&self, editgroup_id: String, editgroup: models::Editgroup, submit: Option<bool>) -> Box<dyn Future<Item = UpdateEditgroupResponse, Error = ApiError> + Send> {
- self.api().update_editgroup(editgroup_id, editgroup, submit, &self.context())
+ self.api()
+ .get_editgroups_reviewable(expand, limit, before, since, &self.context())
}
- fn get_editor(&self, editor_id: String) -> Box<dyn Future<Item = GetEditorResponse, Error = ApiError> + Send> {
+ fn get_editor(
+ &self,
+ editor_id: String,
+ ) -> Box<dyn Future<Item = GetEditorResponse, Error = ApiError> + Send> {
self.api().get_editor(editor_id, &self.context())
}
@@ -2042,7 +3294,8 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> {
before: Option<chrono::DateTime<chrono::Utc>>,
since: Option<chrono::DateTime<chrono::Utc>>,
) -> Box<dyn Future<Item = GetEditorAnnotationsResponse, Error = ApiError> + Send> {
- self.api().get_editor_annotations(editor_id, limit, before, since, &self.context())
+ self.api()
+ .get_editor_annotations(editor_id, limit, before, since, &self.context())
}
fn get_editor_editgroups(
@@ -2052,150 +3305,285 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> {
before: Option<chrono::DateTime<chrono::Utc>>,
since: Option<chrono::DateTime<chrono::Utc>>,
) -> Box<dyn Future<Item = GetEditorEditgroupsResponse, Error = ApiError> + Send> {
- self.api().get_editor_editgroups(editor_id, limit, before, since, &self.context())
- }
-
- fn update_editor(&self, editor_id: String, editor: models::Editor) -> Box<dyn Future<Item = UpdateEditorResponse, Error = ApiError> + Send> {
- self.api().update_editor(editor_id, editor, &self.context())
+ self.api()
+ .get_editor_editgroups(editor_id, limit, before, since, &self.context())
}
- fn create_file(&self, editgroup_id: String, entity: models::FileEntity) -> Box<dyn Future<Item = CreateFileResponse, Error = ApiError> + Send> {
- self.api().create_file(editgroup_id, entity, &self.context())
+ fn get_file(
+ &self,
+ ident: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ ) -> Box<dyn Future<Item = GetFileResponse, Error = ApiError> + Send> {
+ self.api().get_file(ident, expand, hide, &self.context())
}
- fn create_file_auto_batch(&self, auto_batch: models::FileAutoBatch) -> Box<dyn Future<Item = CreateFileAutoBatchResponse, Error = ApiError> + Send> {
- self.api().create_file_auto_batch(auto_batch, &self.context())
+ fn get_file_edit(
+ &self,
+ edit_id: String,
+ ) -> Box<dyn Future<Item = GetFileEditResponse, Error = ApiError> + Send> {
+ self.api().get_file_edit(edit_id, &self.context())
}
- fn delete_file(&self, editgroup_id: String, ident: String) -> Box<dyn Future<Item = DeleteFileResponse, Error = ApiError> + Send> {
- self.api().delete_file(editgroup_id, ident, &self.context())
+ fn get_file_history(
+ &self,
+ ident: String,
+ limit: Option<i64>,
+ ) -> Box<dyn Future<Item = GetFileHistoryResponse, Error = ApiError> + Send> {
+ self.api().get_file_history(ident, limit, &self.context())
}
- fn delete_file_edit(&self, editgroup_id: String, edit_id: String) -> Box<dyn Future<Item = DeleteFileEditResponse, Error = ApiError> + Send> {
- self.api().delete_file_edit(editgroup_id, edit_id, &self.context())
+ fn get_file_redirects(
+ &self,
+ ident: String,
+ ) -> Box<dyn Future<Item = GetFileRedirectsResponse, Error = ApiError> + Send> {
+ self.api().get_file_redirects(ident, &self.context())
}
- fn get_file(&self, ident: String, expand: Option<String>, hide: Option<String>) -> Box<dyn Future<Item = GetFileResponse, Error = ApiError> + Send> {
- self.api().get_file(ident, expand, hide, &self.context())
+ fn get_file_revision(
+ &self,
+ rev_id: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ ) -> Box<dyn Future<Item = GetFileRevisionResponse, Error = ApiError> + Send> {
+ self.api()
+ .get_file_revision(rev_id, expand, hide, &self.context())
}
- fn get_file_edit(&self, edit_id: String) -> Box<dyn Future<Item = GetFileEditResponse, Error = ApiError> + Send> {
- self.api().get_file_edit(edit_id, &self.context())
+ fn get_fileset(
+ &self,
+ ident: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ ) -> Box<dyn Future<Item = GetFilesetResponse, Error = ApiError> + Send> {
+ self.api().get_fileset(ident, expand, hide, &self.context())
}
- fn get_file_history(&self, ident: String, limit: Option<i64>) -> Box<dyn Future<Item = GetFileHistoryResponse, Error = ApiError> + Send> {
- self.api().get_file_history(ident, limit, &self.context())
+ fn get_fileset_edit(
+ &self,
+ edit_id: String,
+ ) -> Box<dyn Future<Item = GetFilesetEditResponse, Error = ApiError> + Send> {
+ self.api().get_fileset_edit(edit_id, &self.context())
}
- fn get_file_redirects(&self, ident: String) -> Box<dyn Future<Item = GetFileRedirectsResponse, Error = ApiError> + Send> {
- self.api().get_file_redirects(ident, &self.context())
+ fn get_fileset_history(
+ &self,
+ ident: String,
+ limit: Option<i64>,
+ ) -> Box<dyn Future<Item = GetFilesetHistoryResponse, Error = ApiError> + Send> {
+ self.api()
+ .get_fileset_history(ident, limit, &self.context())
}
- fn get_file_revision(&self, rev_id: String, expand: Option<String>, hide: Option<String>) -> Box<dyn Future<Item = GetFileRevisionResponse, Error = ApiError> + Send> {
- self.api().get_file_revision(rev_id, expand, hide, &self.context())
+ fn get_fileset_redirects(
+ &self,
+ ident: String,
+ ) -> Box<dyn Future<Item = GetFilesetRedirectsResponse, Error = ApiError> + Send> {
+ self.api().get_fileset_redirects(ident, &self.context())
}
- fn lookup_file(
+ fn get_fileset_revision(
&self,
- md5: Option<String>,
- sha1: Option<String>,
- sha256: Option<String>,
+ rev_id: String,
expand: Option<String>,
hide: Option<String>,
- ) -> Box<dyn Future<Item = LookupFileResponse, Error = ApiError> + 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<dyn Future<Item = UpdateFileResponse, Error = ApiError> + Send> {
- self.api().update_file(editgroup_id, ident, entity, &self.context())
+ ) -> Box<dyn Future<Item = GetFilesetRevisionResponse, Error = ApiError> + Send> {
+ self.api()
+ .get_fileset_revision(rev_id, expand, hide, &self.context())
}
- fn create_fileset(&self, editgroup_id: String, entity: models::FilesetEntity) -> Box<dyn Future<Item = CreateFilesetResponse, Error = ApiError> + Send> {
- self.api().create_fileset(editgroup_id, entity, &self.context())
+ fn get_release(
+ &self,
+ ident: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ ) -> Box<dyn Future<Item = GetReleaseResponse, Error = ApiError> + Send> {
+ self.api().get_release(ident, expand, hide, &self.context())
}
- fn create_fileset_auto_batch(&self, auto_batch: models::FilesetAutoBatch) -> Box<dyn Future<Item = CreateFilesetAutoBatchResponse, Error = ApiError> + Send> {
- self.api().create_fileset_auto_batch(auto_batch, &self.context())
+ fn get_release_edit(
+ &self,
+ edit_id: String,
+ ) -> Box<dyn Future<Item = GetReleaseEditResponse, Error = ApiError> + Send> {
+ self.api().get_release_edit(edit_id, &self.context())
}
- fn delete_fileset(&self, editgroup_id: String, ident: String) -> Box<dyn Future<Item = DeleteFilesetResponse, Error = ApiError> + Send> {
- self.api().delete_fileset(editgroup_id, ident, &self.context())
+ fn get_release_files(
+ &self,
+ ident: String,
+ hide: Option<String>,
+ ) -> Box<dyn Future<Item = GetReleaseFilesResponse, Error = ApiError> + Send> {
+ self.api().get_release_files(ident, hide, &self.context())
}
- fn delete_fileset_edit(&self, editgroup_id: String, edit_id: String) -> Box<dyn Future<Item = DeleteFilesetEditResponse, Error = ApiError> + Send> {
- self.api().delete_fileset_edit(editgroup_id, edit_id, &self.context())
+ fn get_release_filesets(
+ &self,
+ ident: String,
+ hide: Option<String>,
+ ) -> Box<dyn Future<Item = GetReleaseFilesetsResponse, Error = ApiError> + Send> {
+ self.api()
+ .get_release_filesets(ident, hide, &self.context())
}
- fn get_fileset(&self, ident: String, expand: Option<String>, hide: Option<String>) -> Box<dyn Future<Item = GetFilesetResponse, Error = ApiError> + Send> {
- self.api().get_fileset(ident, expand, hide, &self.context())
+ fn get_release_history(
+ &self,
+ ident: String,
+ limit: Option<i64>,
+ ) -> Box<dyn Future<Item = GetReleaseHistoryResponse, Error = ApiError> + Send> {
+ self.api()
+ .get_release_history(ident, limit, &self.context())
}
- fn get_fileset_edit(&self, edit_id: String) -> Box<dyn Future<Item = GetFilesetEditResponse, Error = ApiError> + Send> {
- self.api().get_fileset_edit(edit_id, &self.context())
+ fn get_release_redirects(
+ &self,
+ ident: String,
+ ) -> Box<dyn Future<Item = GetReleaseRedirectsResponse, Error = ApiError> + Send> {
+ self.api().get_release_redirects(ident, &self.context())
}
- fn get_fileset_history(&self, ident: String, limit: Option<i64>) -> Box<dyn Future<Item = GetFilesetHistoryResponse, Error = ApiError> + Send> {
- self.api().get_fileset_history(ident, limit, &self.context())
+ fn get_release_revision(
+ &self,
+ rev_id: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ ) -> Box<dyn Future<Item = GetReleaseRevisionResponse, Error = ApiError> + Send> {
+ self.api()
+ .get_release_revision(rev_id, expand, hide, &self.context())
}
- fn get_fileset_redirects(&self, ident: String) -> Box<dyn Future<Item = GetFilesetRedirectsResponse, Error = ApiError> + Send> {
- self.api().get_fileset_redirects(ident, &self.context())
+ fn get_release_webcaptures(
+ &self,
+ ident: String,
+ hide: Option<String>,
+ ) -> Box<dyn Future<Item = GetReleaseWebcapturesResponse, Error = ApiError> + Send> {
+ self.api()
+ .get_release_webcaptures(ident, hide, &self.context())
}
- fn get_fileset_revision(&self, rev_id: String, expand: Option<String>, hide: Option<String>) -> Box<dyn Future<Item = GetFilesetRevisionResponse, Error = ApiError> + Send> {
- self.api().get_fileset_revision(rev_id, expand, hide, &self.context())
+ fn get_webcapture(
+ &self,
+ ident: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ ) -> Box<dyn Future<Item = GetWebcaptureResponse, Error = ApiError> + Send> {
+ self.api()
+ .get_webcapture(ident, expand, hide, &self.context())
}
- fn update_fileset(&self, editgroup_id: String, ident: String, entity: models::FilesetEntity) -> Box<dyn Future<Item = UpdateFilesetResponse, Error = ApiError> + Send> {
- self.api().update_fileset(editgroup_id, ident, entity, &self.context())
+ fn get_webcapture_edit(
+ &self,
+ edit_id: String,
+ ) -> Box<dyn Future<Item = GetWebcaptureEditResponse, Error = ApiError> + Send> {
+ self.api().get_webcapture_edit(edit_id, &self.context())
}
- fn create_release(&self, editgroup_id: String, entity: models::ReleaseEntity) -> Box<dyn Future<Item = CreateReleaseResponse, Error = ApiError> + Send> {
- self.api().create_release(editgroup_id, entity, &self.context())
+ fn get_webcapture_history(
+ &self,
+ ident: String,
+ limit: Option<i64>,
+ ) -> Box<dyn Future<Item = GetWebcaptureHistoryResponse, Error = ApiError> + Send> {
+ self.api()
+ .get_webcapture_history(ident, limit, &self.context())
}
- fn create_release_auto_batch(&self, auto_batch: models::ReleaseAutoBatch) -> Box<dyn Future<Item = CreateReleaseAutoBatchResponse, Error = ApiError> + Send> {
- self.api().create_release_auto_batch(auto_batch, &self.context())
+ fn get_webcapture_redirects(
+ &self,
+ ident: String,
+ ) -> Box<dyn Future<Item = GetWebcaptureRedirectsResponse, Error = ApiError> + Send> {
+ self.api().get_webcapture_redirects(ident, &self.context())
}
- fn delete_release(&self, editgroup_id: String, ident: String) -> Box<dyn Future<Item = DeleteReleaseResponse, Error = ApiError> + Send> {
- self.api().delete_release(editgroup_id, ident, &self.context())
+ fn get_webcapture_revision(
+ &self,
+ rev_id: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ ) -> Box<dyn Future<Item = GetWebcaptureRevisionResponse, Error = ApiError> + Send> {
+ self.api()
+ .get_webcapture_revision(rev_id, expand, hide, &self.context())
}
- fn delete_release_edit(&self, editgroup_id: String, edit_id: String) -> Box<dyn Future<Item = DeleteReleaseEditResponse, Error = ApiError> + Send> {
- self.api().delete_release_edit(editgroup_id, edit_id, &self.context())
+ fn get_work(
+ &self,
+ ident: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ ) -> Box<dyn Future<Item = GetWorkResponse, Error = ApiError> + Send> {
+ self.api().get_work(ident, expand, hide, &self.context())
}
- fn get_release(&self, ident: String, expand: Option<String>, hide: Option<String>) -> Box<dyn Future<Item = GetReleaseResponse, Error = ApiError> + Send> {
- self.api().get_release(ident, expand, hide, &self.context())
+ fn get_work_edit(
+ &self,
+ edit_id: String,
+ ) -> Box<dyn Future<Item = GetWorkEditResponse, Error = ApiError> + Send> {
+ self.api().get_work_edit(edit_id, &self.context())
}
- fn get_release_edit(&self, edit_id: String) -> Box<dyn Future<Item = GetReleaseEditResponse, Error = ApiError> + Send> {
- self.api().get_release_edit(edit_id, &self.context())
+ fn get_work_history(
+ &self,
+ ident: String,
+ limit: Option<i64>,
+ ) -> Box<dyn Future<Item = GetWorkHistoryResponse, Error = ApiError> + Send> {
+ self.api().get_work_history(ident, limit, &self.context())
}
- fn get_release_files(&self, ident: String, hide: Option<String>) -> Box<dyn Future<Item = GetReleaseFilesResponse, Error = ApiError> + Send> {
- self.api().get_release_files(ident, hide, &self.context())
+ fn get_work_redirects(
+ &self,
+ ident: String,
+ ) -> Box<dyn Future<Item = GetWorkRedirectsResponse, Error = ApiError> + Send> {
+ self.api().get_work_redirects(ident, &self.context())
}
- fn get_release_filesets(&self, ident: String, hide: Option<String>) -> Box<dyn Future<Item = GetReleaseFilesetsResponse, Error = ApiError> + Send> {
- self.api().get_release_filesets(ident, hide, &self.context())
+ fn get_work_releases(
+ &self,
+ ident: String,
+ hide: Option<String>,
+ ) -> Box<dyn Future<Item = GetWorkReleasesResponse, Error = ApiError> + Send> {
+ self.api().get_work_releases(ident, hide, &self.context())
}
- fn get_release_history(&self, ident: String, limit: Option<i64>) -> Box<dyn Future<Item = GetReleaseHistoryResponse, Error = ApiError> + Send> {
- self.api().get_release_history(ident, limit, &self.context())
+ fn get_work_revision(
+ &self,
+ rev_id: String,
+ expand: Option<String>,
+ hide: Option<String>,
+ ) -> Box<dyn Future<Item = GetWorkRevisionResponse, Error = ApiError> + Send> {
+ self.api()
+ .get_work_revision(rev_id, expand, hide, &self.context())
}
- fn get_release_redirects(&self, ident: String) -> Box<dyn Future<Item = GetReleaseRedirectsResponse, Error = ApiError> + Send> {
- self.api().get_release_redirects(ident, &self.context())
+ fn lookup_container(
+ &self,
+ issnl: Option<String>,
+ wikidata_qid: Option<String>,
+ expand: Option<String>,
+ hide: Option<String>,
+ ) -> Box<dyn Future<Item = LookupContainerResponse, Error = ApiError> + Send> {
+ self.api()
+ .lookup_container(issnl, wikidata_qid, expand, hide, &self.context())
}
- fn get_release_revision(&self, rev_id: String, expand: Option<String>, hide: Option<String>) -> Box<dyn Future<Item = GetReleaseRevisionResponse, Error = ApiError> + Send> {
- self.api().get_release_revision(rev_id, expand, hide, &self.context())
+ fn lookup_creator(
+ &self,
+ orcid: Option<String>,
+ wikidata_qid: Option<String>,
+ expand: Option<String>,
+ hide: Option<String>,
+ ) -> Box<dyn Future<Item = LookupCreatorResponse, Error = ApiError> + Send> {
+ self.api()
+ .lookup_creator(orcid, wikidata_qid, expand, hide, &self.context())
}
- fn get_release_webcaptures(&self, ident: String, hide: Option<String>) -> Box<dyn Future<Item = GetReleaseWebcapturesResponse, Error = ApiError> + Send> {
- self.api().get_release_webcaptures(ident, hide, &self.context())
+ fn lookup_file(
+ &self,
+ md5: Option<String>,
+ sha1: Option<String>,
+ sha256: Option<String>,
+ expand: Option<String>,
+ hide: Option<String>,
+ ) -> Box<dyn Future<Item = LookupFileResponse, Error = ApiError> + Send> {
+ self.api()
+ .lookup_file(md5, sha1, sha256, expand, hide, &self.context())
}
fn lookup_release(
@@ -2213,96 +3601,109 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> {
expand: Option<String>,
hide: Option<String>,
) -> Box<dyn Future<Item = LookupReleaseResponse, Error = ApiError> + Send> {
+ self.api().lookup_release(
+ doi,
+ wikidata_qid,
+ isbn13,
+ pmid,
+ pmcid,
+ core,
+ arxiv,
+ jstor,
+ ark,
+ mag,
+ expand,
+ hide,
+ &self.context(),
+ )
+ }
+
+ fn update_container(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ entity: models::ContainerEntity,
+ ) -> Box<dyn Future<Item = UpdateContainerResponse, Error = ApiError> + 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<dyn Future<Item = UpdateReleaseResponse, Error = ApiError> + Send> {
- self.api().update_release(editgroup_id, ident, entity, &self.context())
- }
-
- fn create_webcapture(&self, editgroup_id: String, entity: models::WebcaptureEntity) -> Box<dyn Future<Item = CreateWebcaptureResponse, Error = ApiError> + Send> {
- self.api().create_webcapture(editgroup_id, entity, &self.context())
+ .update_container(editgroup_id, ident, entity, &self.context())
}
- fn create_webcapture_auto_batch(&self, auto_batch: models::WebcaptureAutoBatch) -> Box<dyn Future<Item = CreateWebcaptureAutoBatchResponse, Error = ApiError> + Send> {
- self.api().create_webcapture_auto_batch(auto_batch, &self.context())
- }
-
- fn delete_webcapture(&self, editgroup_id: String, ident: String) -> Box<dyn Future<Item = DeleteWebcaptureResponse, Error = ApiError> + Send> {
- self.api().delete_webcapture(editgroup_id, ident, &self.context())
- }
-
- fn delete_webcapture_edit(&self, editgroup_id: String, edit_id: String) -> Box<dyn Future<Item = DeleteWebcaptureEditResponse, Error = ApiError> + Send> {
- self.api().delete_webcapture_edit(editgroup_id, edit_id, &self.context())
- }
-
- fn get_webcapture(&self, ident: String, expand: Option<String>, hide: Option<String>) -> Box<dyn Future<Item = GetWebcaptureResponse, Error = ApiError> + Send> {
- self.api().get_webcapture(ident, expand, hide, &self.context())
- }
-
- fn get_webcapture_edit(&self, edit_id: String) -> Box<dyn Future<Item = GetWebcaptureEditResponse, Error = ApiError> + Send> {
- self.api().get_webcapture_edit(edit_id, &self.context())
- }
-
- fn get_webcapture_history(&self, ident: String, limit: Option<i64>) -> Box<dyn Future<Item = GetWebcaptureHistoryResponse, Error = ApiError> + Send> {
- self.api().get_webcapture_history(ident, limit, &self.context())
- }
-
- fn get_webcapture_redirects(&self, ident: String) -> Box<dyn Future<Item = GetWebcaptureRedirectsResponse, Error = ApiError> + Send> {
- self.api().get_webcapture_redirects(ident, &self.context())
- }
-
- fn get_webcapture_revision(&self, rev_id: String, expand: Option<String>, hide: Option<String>) -> Box<dyn Future<Item = GetWebcaptureRevisionResponse, Error = ApiError> + 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<dyn Future<Item = UpdateWebcaptureResponse, Error = ApiError> + Send> {
- self.api().update_webcapture(editgroup_id, ident, entity, &self.context())
- }
-
- fn create_work(&self, editgroup_id: String, entity: models::WorkEntity) -> Box<dyn Future<Item = CreateWorkResponse, Error = ApiError> + Send> {
- self.api().create_work(editgroup_id, entity, &self.context())
- }
-
- fn create_work_auto_batch(&self, auto_batch: models::WorkAutoBatch) -> Box<dyn Future<Item = CreateWorkAutoBatchResponse, Error = ApiError> + Send> {
- self.api().create_work_auto_batch(auto_batch, &self.context())
- }
-
- fn delete_work(&self, editgroup_id: String, ident: String) -> Box<dyn Future<Item = DeleteWorkResponse, Error = ApiError> + Send> {
- self.api().delete_work(editgroup_id, ident, &self.context())
- }
-
- fn delete_work_edit(&self, editgroup_id: String, edit_id: String) -> Box<dyn Future<Item = DeleteWorkEditResponse, Error = ApiError> + Send> {
- self.api().delete_work_edit(editgroup_id, edit_id, &self.context())
+ fn update_creator(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ entity: models::CreatorEntity,
+ ) -> Box<dyn Future<Item = UpdateCreatorResponse, Error = ApiError> + Send> {
+ self.api()
+ .update_creator(editgroup_id, ident, entity, &self.context())
}
- fn get_work(&self, ident: String, expand: Option<String>, hide: Option<String>) -> Box<dyn Future<Item = GetWorkResponse, Error = ApiError> + Send> {
- self.api().get_work(ident, expand, hide, &self.context())
+ fn update_editgroup(
+ &self,
+ editgroup_id: String,
+ editgroup: models::Editgroup,
+ submit: Option<bool>,
+ ) -> Box<dyn Future<Item = UpdateEditgroupResponse, Error = ApiError> + Send> {
+ self.api()
+ .update_editgroup(editgroup_id, editgroup, submit, &self.context())
}
- fn get_work_edit(&self, edit_id: String) -> Box<dyn Future<Item = GetWorkEditResponse, Error = ApiError> + Send> {
- self.api().get_work_edit(edit_id, &self.context())
+ fn update_editor(
+ &self,
+ editor_id: String,
+ editor: models::Editor,
+ ) -> Box<dyn Future<Item = UpdateEditorResponse, Error = ApiError> + Send> {
+ self.api().update_editor(editor_id, editor, &self.context())
}
- fn get_work_history(&self, ident: String, limit: Option<i64>) -> Box<dyn Future<Item = GetWorkHistoryResponse, Error = ApiError> + Send> {
- self.api().get_work_history(ident, limit, &self.context())
+ fn update_file(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ entity: models::FileEntity,
+ ) -> Box<dyn Future<Item = UpdateFileResponse, Error = ApiError> + Send> {
+ self.api()
+ .update_file(editgroup_id, ident, entity, &self.context())
}
- fn get_work_redirects(&self, ident: String) -> Box<dyn Future<Item = GetWorkRedirectsResponse, Error = ApiError> + Send> {
- self.api().get_work_redirects(ident, &self.context())
+ fn update_fileset(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ entity: models::FilesetEntity,
+ ) -> Box<dyn Future<Item = UpdateFilesetResponse, Error = ApiError> + Send> {
+ self.api()
+ .update_fileset(editgroup_id, ident, entity, &self.context())
}
- fn get_work_releases(&self, ident: String, hide: Option<String>) -> Box<dyn Future<Item = GetWorkReleasesResponse, Error = ApiError> + Send> {
- self.api().get_work_releases(ident, hide, &self.context())
+ fn update_release(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ entity: models::ReleaseEntity,
+ ) -> Box<dyn Future<Item = UpdateReleaseResponse, Error = ApiError> + Send> {
+ self.api()
+ .update_release(editgroup_id, ident, entity, &self.context())
}
- fn get_work_revision(&self, rev_id: String, expand: Option<String>, hide: Option<String>) -> Box<dyn Future<Item = GetWorkRevisionResponse, Error = ApiError> + Send> {
- self.api().get_work_revision(rev_id, expand, hide, &self.context())
+ fn update_webcapture(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ entity: models::WebcaptureEntity,
+ ) -> Box<dyn Future<Item = UpdateWebcaptureResponse, Error = ApiError> + Send> {
+ self.api()
+ .update_webcapture(editgroup_id, ident, entity, &self.context())
}
- fn update_work(&self, editgroup_id: String, ident: String, entity: models::WorkEntity) -> Box<dyn Future<Item = UpdateWorkResponse, Error = ApiError> + Send> {
- self.api().update_work(editgroup_id, ident, entity, &self.context())
+ fn update_work(
+ &self,
+ editgroup_id: String,
+ ident: String,
+ entity: models::WorkEntity,
+ ) -> Box<dyn Future<Item = UpdateWorkResponse, Error = ApiError> + Send> {
+ self.api()
+ .update_work(editgroup_id, ident, entity, &self.context())
}
}
@@ -2311,13 +3712,19 @@ pub mod client;
// Re-export Client as a top-level name
#[cfg(feature = "client")]
-pub use self::client::Client;
+pub use 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 use self::server::Service;
+
+#[cfg(feature = "server")]
+pub mod context;
pub mod models;
+
+#[cfg(any(feature = "client", feature = "server"))]
+pub(crate) mod header;
diff --git a/rust/fatcat-openapi/src/mimetypes.rs b/rust/fatcat-openapi/src/mimetypes.rs
deleted file mode 100644
index 13c4ccbe..00000000
--- a/rust/fatcat-openapi/src/mimetypes.rs
+++ /dev/null
@@ -1,1993 +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 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 CreateAuthToken
- lazy_static! {
- pub static ref CREATE_AUTH_TOKEN_SUCCESS: Mime = mime!(Application / Json);
- }
- // Create Mime objects for the response content types for CreateAuthToken
- lazy_static! {
- pub static ref CREATE_AUTH_TOKEN_BAD_REQUEST: Mime = mime!(Application / Json);
- }
- // Create Mime objects for the response content types for CreateAuthToken
- lazy_static! {
- pub static ref CREATE_AUTH_TOKEN_NOT_AUTHORIZED: Mime = mime!(Application / Json);
- }
- // Create Mime objects for the response content types for CreateAuthToken
- lazy_static! {
- pub static ref CREATE_AUTH_TOKEN_FORBIDDEN: Mime = mime!(Application / Json);
- }
- // Create Mime objects for the response content types for CreateAuthToken
- lazy_static! {
- pub static ref CREATE_AUTH_TOKEN_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 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 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 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 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 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 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 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 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 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 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 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 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 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 AuthOidc
- lazy_static! {
- pub static ref AUTH_OIDC: Mime = mime!(Application / Json);
- }
- // 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 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 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 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 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 CreateWork
- lazy_static! {
- pub static ref CREATE_WORK: 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-openapi/src/models.rs b/rust/fatcat-openapi/src/models.rs
index adad2958..3de56ed8 100644
--- a/rust/fatcat-openapi/src/models.rs
+++ b/rust/fatcat-openapi/src/models.rs
@@ -1,15 +1,56 @@
-#![allow(unused_imports, unused_qualifications, unused_extern_crates)]
-extern crate chrono;
-extern crate serde_json;
-extern crate uuid;
-
-use serde::ser::Serializer;
+#![allow(unused_qualifications)]
+#[cfg(any(feature = "client", feature = "server"))]
+use crate::header;
use crate::models;
-use std::collections::HashMap;
-use swagger;
-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+// Methods for converting between header::IntoHeaderValue<AuthOidc> and hyper::header::HeaderValue
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<header::IntoHeaderValue<AuthOidc>> for hyper::header::HeaderValue {
+ type Error = String;
+
+ fn try_from(
+ hdr_value: header::IntoHeaderValue<AuthOidc>,
+ ) -> std::result::Result<Self, Self::Error> {
+ let hdr_value = hdr_value.to_string();
+ match hyper::header::HeaderValue::from_str(&hdr_value) {
+ std::result::Result::Ok(value) => std::result::Result::Ok(value),
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Invalid header value for AuthOidc - value: {} is invalid {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<AuthOidc> {
+ type Error = String;
+
+ fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
+ match hdr_value.to_str() {
+ std::result::Result::Ok(value) => {
+ match <AuthOidc as std::str::FromStr>::from_str(value) {
+ std::result::Result::Ok(value) => {
+ std::result::Result::Ok(header::IntoHeaderValue(value))
+ }
+ std::result::Result::Err(err) => std::result::Result::Err(format!(
+ "Unable to convert header value '{}' into AuthOidc - {}",
+ value, err
+ )),
+ }
+ }
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Unable to convert header: {:?} to string: {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
+#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct AuthOidc {
/// Fatcat-specific short name (slug) for remote service being used for authentication.
#[serde(rename = "provider")]
@@ -39,7 +80,160 @@ impl AuthOidc {
}
}
-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+/// Converts the AuthOidc value to the Query Parameters representation (style=form, explode=false)
+/// specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde serializer
+impl std::string::ToString for AuthOidc {
+ fn to_string(&self) -> String {
+ let mut params: Vec<String> = vec![];
+
+ params.push("provider".to_string());
+ params.push(self.provider.to_string());
+
+ params.push("sub".to_string());
+ params.push(self.sub.to_string());
+
+ params.push("iss".to_string());
+ params.push(self.iss.to_string());
+
+ params.push("preferred_username".to_string());
+ params.push(self.preferred_username.to_string());
+
+ params.join(",").to_string()
+ }
+}
+
+/// Converts Query Parameters representation (style=form, explode=false) to a AuthOidc value
+/// as specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde deserializer
+impl std::str::FromStr for AuthOidc {
+ type Err = String;
+
+ fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
+ #[derive(Default)]
+ // An intermediate representation of the struct to use for parsing.
+ struct IntermediateRep {
+ pub provider: Vec<String>,
+ pub sub: Vec<String>,
+ pub iss: Vec<String>,
+ pub preferred_username: Vec<String>,
+ }
+
+ let mut intermediate_rep = IntermediateRep::default();
+
+ // Parse into intermediate representation
+ let mut string_iter = s.split(',').into_iter();
+ let mut key_result = string_iter.next();
+
+ while key_result.is_some() {
+ let val = match string_iter.next() {
+ Some(x) => x,
+ None => {
+ return std::result::Result::Err(
+ "Missing value while parsing AuthOidc".to_string(),
+ )
+ }
+ };
+
+ if let Some(key) = key_result {
+ match key {
+ "provider" => intermediate_rep
+ .provider
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "sub" => intermediate_rep
+ .sub
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "iss" => intermediate_rep
+ .iss
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "preferred_username" => intermediate_rep
+ .preferred_username
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ _ => {
+ return std::result::Result::Err(
+ "Unexpected key while parsing AuthOidc".to_string(),
+ )
+ }
+ }
+ }
+
+ // Get the next key
+ key_result = string_iter.next();
+ }
+
+ // Use the intermediate representation to return the struct
+ std::result::Result::Ok(AuthOidc {
+ provider: intermediate_rep
+ .provider
+ .into_iter()
+ .next()
+ .ok_or("provider missing in AuthOidc".to_string())?,
+ sub: intermediate_rep
+ .sub
+ .into_iter()
+ .next()
+ .ok_or("sub missing in AuthOidc".to_string())?,
+ iss: intermediate_rep
+ .iss
+ .into_iter()
+ .next()
+ .ok_or("iss missing in AuthOidc".to_string())?,
+ preferred_username: intermediate_rep
+ .preferred_username
+ .into_iter()
+ .next()
+ .ok_or("preferred_username missing in AuthOidc".to_string())?,
+ })
+ }
+}
+
+// Methods for converting between header::IntoHeaderValue<AuthOidcResult> and hyper::header::HeaderValue
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<header::IntoHeaderValue<AuthOidcResult>> for hyper::header::HeaderValue {
+ type Error = String;
+
+ fn try_from(
+ hdr_value: header::IntoHeaderValue<AuthOidcResult>,
+ ) -> std::result::Result<Self, Self::Error> {
+ let hdr_value = hdr_value.to_string();
+ match hyper::header::HeaderValue::from_str(&hdr_value) {
+ std::result::Result::Ok(value) => std::result::Result::Ok(value),
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Invalid header value for AuthOidcResult - value: {} is invalid {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<AuthOidcResult> {
+ type Error = String;
+
+ fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
+ match hdr_value.to_str() {
+ std::result::Result::Ok(value) => {
+ match <AuthOidcResult as std::str::FromStr>::from_str(value) {
+ std::result::Result::Ok(value) => {
+ std::result::Result::Ok(header::IntoHeaderValue(value))
+ }
+ std::result::Result::Err(err) => std::result::Result::Err(format!(
+ "Unable to convert header value '{}' into AuthOidcResult - {}",
+ value, err
+ )),
+ }
+ }
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Unable to convert header: {:?} to string: {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
+#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct AuthOidcResult {
#[serde(rename = "editor")]
pub editor: models::Editor,
@@ -50,11 +244,145 @@ pub struct AuthOidcResult {
impl AuthOidcResult {
pub fn new(editor: models::Editor, token: String) -> AuthOidcResult {
- AuthOidcResult { editor: editor, token: token }
+ AuthOidcResult {
+ editor: editor,
+ token: token,
+ }
}
}
-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+/// Converts the AuthOidcResult value to the Query Parameters representation (style=form, explode=false)
+/// specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde serializer
+impl std::string::ToString for AuthOidcResult {
+ fn to_string(&self) -> String {
+ let mut params: Vec<String> = vec![];
+ // Skipping editor in query parameter serialization
+
+ params.push("token".to_string());
+ params.push(self.token.to_string());
+
+ params.join(",").to_string()
+ }
+}
+
+/// Converts Query Parameters representation (style=form, explode=false) to a AuthOidcResult value
+/// as specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde deserializer
+impl std::str::FromStr for AuthOidcResult {
+ type Err = String;
+
+ fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
+ #[derive(Default)]
+ // An intermediate representation of the struct to use for parsing.
+ struct IntermediateRep {
+ pub editor: Vec<models::Editor>,
+ pub token: Vec<String>,
+ }
+
+ let mut intermediate_rep = IntermediateRep::default();
+
+ // Parse into intermediate representation
+ let mut string_iter = s.split(',').into_iter();
+ let mut key_result = string_iter.next();
+
+ while key_result.is_some() {
+ let val = match string_iter.next() {
+ Some(x) => x,
+ None => {
+ return std::result::Result::Err(
+ "Missing value while parsing AuthOidcResult".to_string(),
+ )
+ }
+ };
+
+ if let Some(key) = key_result {
+ match key {
+ "editor" => intermediate_rep
+ .editor
+ .push(models::Editor::from_str(val).map_err(|x| format!("{}", x))?),
+ "token" => intermediate_rep
+ .token
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ _ => {
+ return std::result::Result::Err(
+ "Unexpected key while parsing AuthOidcResult".to_string(),
+ )
+ }
+ }
+ }
+
+ // Get the next key
+ key_result = string_iter.next();
+ }
+
+ // Use the intermediate representation to return the struct
+ std::result::Result::Ok(AuthOidcResult {
+ editor: intermediate_rep
+ .editor
+ .into_iter()
+ .next()
+ .ok_or("editor missing in AuthOidcResult".to_string())?,
+ token: intermediate_rep
+ .token
+ .into_iter()
+ .next()
+ .ok_or("token missing in AuthOidcResult".to_string())?,
+ })
+ }
+}
+
+// Methods for converting between header::IntoHeaderValue<AuthTokenResult> and hyper::header::HeaderValue
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<header::IntoHeaderValue<AuthTokenResult>>
+ for hyper::header::HeaderValue
+{
+ type Error = String;
+
+ fn try_from(
+ hdr_value: header::IntoHeaderValue<AuthTokenResult>,
+ ) -> std::result::Result<Self, Self::Error> {
+ let hdr_value = hdr_value.to_string();
+ match hyper::header::HeaderValue::from_str(&hdr_value) {
+ std::result::Result::Ok(value) => std::result::Result::Ok(value),
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Invalid header value for AuthTokenResult - value: {} is invalid {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<hyper::header::HeaderValue>
+ for header::IntoHeaderValue<AuthTokenResult>
+{
+ type Error = String;
+
+ fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
+ match hdr_value.to_str() {
+ std::result::Result::Ok(value) => {
+ match <AuthTokenResult as std::str::FromStr>::from_str(value) {
+ std::result::Result::Ok(value) => {
+ std::result::Result::Ok(header::IntoHeaderValue(value))
+ }
+ std::result::Result::Err(err) => std::result::Result::Err(format!(
+ "Unable to convert header value '{}' into AuthTokenResult - {}",
+ value, err
+ )),
+ }
+ }
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Unable to convert header: {:?} to string: {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
+#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct AuthTokenResult {
#[serde(rename = "token")]
pub token: String,
@@ -66,7 +394,124 @@ impl AuthTokenResult {
}
}
-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+/// Converts the AuthTokenResult value to the Query Parameters representation (style=form, explode=false)
+/// specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde serializer
+impl std::string::ToString for AuthTokenResult {
+ fn to_string(&self) -> String {
+ let mut params: Vec<String> = vec![];
+
+ params.push("token".to_string());
+ params.push(self.token.to_string());
+
+ params.join(",").to_string()
+ }
+}
+
+/// Converts Query Parameters representation (style=form, explode=false) to a AuthTokenResult value
+/// as specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde deserializer
+impl std::str::FromStr for AuthTokenResult {
+ type Err = String;
+
+ fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
+ #[derive(Default)]
+ // An intermediate representation of the struct to use for parsing.
+ struct IntermediateRep {
+ pub token: Vec<String>,
+ }
+
+ let mut intermediate_rep = IntermediateRep::default();
+
+ // Parse into intermediate representation
+ let mut string_iter = s.split(',').into_iter();
+ let mut key_result = string_iter.next();
+
+ while key_result.is_some() {
+ let val = match string_iter.next() {
+ Some(x) => x,
+ None => {
+ return std::result::Result::Err(
+ "Missing value while parsing AuthTokenResult".to_string(),
+ )
+ }
+ };
+
+ if let Some(key) = key_result {
+ match key {
+ "token" => intermediate_rep
+ .token
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ _ => {
+ return std::result::Result::Err(
+ "Unexpected key while parsing AuthTokenResult".to_string(),
+ )
+ }
+ }
+ }
+
+ // Get the next key
+ key_result = string_iter.next();
+ }
+
+ // Use the intermediate representation to return the struct
+ std::result::Result::Ok(AuthTokenResult {
+ token: intermediate_rep
+ .token
+ .into_iter()
+ .next()
+ .ok_or("token missing in AuthTokenResult".to_string())?,
+ })
+ }
+}
+
+// Methods for converting between header::IntoHeaderValue<ChangelogEntry> and hyper::header::HeaderValue
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<header::IntoHeaderValue<ChangelogEntry>> for hyper::header::HeaderValue {
+ type Error = String;
+
+ fn try_from(
+ hdr_value: header::IntoHeaderValue<ChangelogEntry>,
+ ) -> std::result::Result<Self, Self::Error> {
+ let hdr_value = hdr_value.to_string();
+ match hyper::header::HeaderValue::from_str(&hdr_value) {
+ std::result::Result::Ok(value) => std::result::Result::Ok(value),
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Invalid header value for ChangelogEntry - value: {} is invalid {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<ChangelogEntry> {
+ type Error = String;
+
+ fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
+ match hdr_value.to_str() {
+ std::result::Result::Ok(value) => {
+ match <ChangelogEntry as std::str::FromStr>::from_str(value) {
+ std::result::Result::Ok(value) => {
+ std::result::Result::Ok(header::IntoHeaderValue(value))
+ }
+ std::result::Result::Err(err) => std::result::Result::Err(format!(
+ "Unable to convert header value '{}' into ChangelogEntry - {}",
+ value, err
+ )),
+ }
+ }
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Unable to convert header: {:?} to string: {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
+#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ChangelogEntry {
/// Monotonically increasing sequence number of this changelog entry.
#[serde(rename = "index")]
@@ -86,7 +531,11 @@ pub struct ChangelogEntry {
}
impl ChangelogEntry {
- pub fn new(index: i64, editgroup_id: String, timestamp: chrono::DateTime<chrono::Utc>) -> ChangelogEntry {
+ pub fn new(
+ index: i64,
+ editgroup_id: String,
+ timestamp: chrono::DateTime<chrono::Utc>,
+ ) -> ChangelogEntry {
ChangelogEntry {
index: index,
editgroup_id: editgroup_id,
@@ -96,7 +545,159 @@ impl ChangelogEntry {
}
}
-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+/// Converts the ChangelogEntry value to the Query Parameters representation (style=form, explode=false)
+/// specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde serializer
+impl std::string::ToString for ChangelogEntry {
+ fn to_string(&self) -> String {
+ let mut params: Vec<String> = vec![];
+
+ params.push("index".to_string());
+ params.push(self.index.to_string());
+
+ params.push("editgroup_id".to_string());
+ params.push(self.editgroup_id.to_string());
+
+ // Skipping timestamp in query parameter serialization
+
+ // Skipping editgroup in query parameter serialization
+
+ params.join(",").to_string()
+ }
+}
+
+/// Converts Query Parameters representation (style=form, explode=false) to a ChangelogEntry value
+/// as specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde deserializer
+impl std::str::FromStr for ChangelogEntry {
+ type Err = String;
+
+ fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
+ #[derive(Default)]
+ // An intermediate representation of the struct to use for parsing.
+ struct IntermediateRep {
+ pub index: Vec<i64>,
+ pub editgroup_id: Vec<String>,
+ pub timestamp: Vec<chrono::DateTime<chrono::Utc>>,
+ pub editgroup: Vec<models::Editgroup>,
+ }
+
+ let mut intermediate_rep = IntermediateRep::default();
+
+ // Parse into intermediate representation
+ let mut string_iter = s.split(',').into_iter();
+ let mut key_result = string_iter.next();
+
+ while key_result.is_some() {
+ let val = match string_iter.next() {
+ Some(x) => x,
+ None => {
+ return std::result::Result::Err(
+ "Missing value while parsing ChangelogEntry".to_string(),
+ )
+ }
+ };
+
+ if let Some(key) = key_result {
+ match key {
+ "index" => intermediate_rep
+ .index
+ .push(i64::from_str(val).map_err(|x| format!("{}", x))?),
+ "editgroup_id" => intermediate_rep
+ .editgroup_id
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "timestamp" => intermediate_rep.timestamp.push(
+ chrono::DateTime::<chrono::Utc>::from_str(val)
+ .map_err(|x| format!("{}", x))?,
+ ),
+ "editgroup" => intermediate_rep
+ .editgroup
+ .push(models::Editgroup::from_str(val).map_err(|x| format!("{}", x))?),
+ _ => {
+ return std::result::Result::Err(
+ "Unexpected key while parsing ChangelogEntry".to_string(),
+ )
+ }
+ }
+ }
+
+ // Get the next key
+ key_result = string_iter.next();
+ }
+
+ // Use the intermediate representation to return the struct
+ std::result::Result::Ok(ChangelogEntry {
+ index: intermediate_rep
+ .index
+ .into_iter()
+ .next()
+ .ok_or("index missing in ChangelogEntry".to_string())?,
+ editgroup_id: intermediate_rep
+ .editgroup_id
+ .into_iter()
+ .next()
+ .ok_or("editgroup_id missing in ChangelogEntry".to_string())?,
+ timestamp: intermediate_rep
+ .timestamp
+ .into_iter()
+ .next()
+ .ok_or("timestamp missing in ChangelogEntry".to_string())?,
+ editgroup: intermediate_rep.editgroup.into_iter().next(),
+ })
+ }
+}
+
+// Methods for converting between header::IntoHeaderValue<ContainerAutoBatch> and hyper::header::HeaderValue
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<header::IntoHeaderValue<ContainerAutoBatch>>
+ for hyper::header::HeaderValue
+{
+ type Error = String;
+
+ fn try_from(
+ hdr_value: header::IntoHeaderValue<ContainerAutoBatch>,
+ ) -> std::result::Result<Self, Self::Error> {
+ let hdr_value = hdr_value.to_string();
+ match hyper::header::HeaderValue::from_str(&hdr_value) {
+ std::result::Result::Ok(value) => std::result::Result::Ok(value),
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Invalid header value for ContainerAutoBatch - value: {} is invalid {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<hyper::header::HeaderValue>
+ for header::IntoHeaderValue<ContainerAutoBatch>
+{
+ type Error = String;
+
+ fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
+ match hdr_value.to_str() {
+ std::result::Result::Ok(value) => {
+ match <ContainerAutoBatch as std::str::FromStr>::from_str(value) {
+ std::result::Result::Ok(value) => {
+ std::result::Result::Ok(header::IntoHeaderValue(value))
+ }
+ std::result::Result::Err(err) => std::result::Result::Err(format!(
+ "Unable to convert header value '{}' into ContainerAutoBatch - {}",
+ value, err
+ )),
+ }
+ }
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Unable to convert header: {:?} to string: {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
+#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ContainerAutoBatch {
#[serde(rename = "editgroup")]
pub editgroup: models::Editgroup,
@@ -106,7 +707,10 @@ pub struct ContainerAutoBatch {
}
impl ContainerAutoBatch {
- pub fn new(editgroup: models::Editgroup, entity_list: Vec<models::ContainerEntity>) -> ContainerAutoBatch {
+ pub fn new(
+ editgroup: models::Editgroup,
+ entity_list: Vec<models::ContainerEntity>,
+ ) -> ContainerAutoBatch {
ContainerAutoBatch {
editgroup: editgroup,
entity_list: entity_list,
@@ -114,82 +718,434 @@ impl ContainerAutoBatch {
}
}
-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+/// Converts the ContainerAutoBatch value to the Query Parameters representation (style=form, explode=false)
+/// specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde serializer
+impl std::string::ToString for ContainerAutoBatch {
+ fn to_string(&self) -> String {
+ let mut params: Vec<String> = vec![];
+ // Skipping editgroup in query parameter serialization
+
+ // Skipping entity_list in query parameter serialization
+
+ params.join(",").to_string()
+ }
+}
+
+/// Converts Query Parameters representation (style=form, explode=false) to a ContainerAutoBatch value
+/// as specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde deserializer
+impl std::str::FromStr for ContainerAutoBatch {
+ type Err = String;
+
+ fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
+ #[derive(Default)]
+ // An intermediate representation of the struct to use for parsing.
+ struct IntermediateRep {
+ pub editgroup: Vec<models::Editgroup>,
+ pub entity_list: Vec<Vec<models::ContainerEntity>>,
+ }
+
+ let mut intermediate_rep = IntermediateRep::default();
+
+ // Parse into intermediate representation
+ let mut string_iter = s.split(',').into_iter();
+ let mut key_result = string_iter.next();
+
+ while key_result.is_some() {
+ let val = match string_iter.next() {
+ Some(x) => x,
+ None => {
+ return std::result::Result::Err(
+ "Missing value while parsing ContainerAutoBatch".to_string(),
+ )
+ }
+ };
+
+ if let Some(key) = key_result {
+ match key {
+ "editgroup" => intermediate_rep
+ .editgroup
+ .push(models::Editgroup::from_str(val).map_err(|x| format!("{}", x))?),
+ "entity_list" => return std::result::Result::Err(
+ "Parsing a container in this style is not supported in ContainerAutoBatch"
+ .to_string(),
+ ),
+ _ => {
+ return std::result::Result::Err(
+ "Unexpected key while parsing ContainerAutoBatch".to_string(),
+ )
+ }
+ }
+ }
+
+ // Get the next key
+ key_result = string_iter.next();
+ }
+
+ // Use the intermediate representation to return the struct
+ std::result::Result::Ok(ContainerAutoBatch {
+ editgroup: intermediate_rep
+ .editgroup
+ .into_iter()
+ .next()
+ .ok_or("editgroup missing in ContainerAutoBatch".to_string())?,
+ entity_list: intermediate_rep
+ .entity_list
+ .into_iter()
+ .next()
+ .ok_or("entity_list missing in ContainerAutoBatch".to_string())?,
+ })
+ }
+}
+
+// Methods for converting between header::IntoHeaderValue<ContainerEntity> and hyper::header::HeaderValue
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<header::IntoHeaderValue<ContainerEntity>>
+ for hyper::header::HeaderValue
+{
+ type Error = String;
+
+ fn try_from(
+ hdr_value: header::IntoHeaderValue<ContainerEntity>,
+ ) -> std::result::Result<Self, Self::Error> {
+ let hdr_value = hdr_value.to_string();
+ match hyper::header::HeaderValue::from_str(&hdr_value) {
+ std::result::Result::Ok(value) => std::result::Result::Ok(value),
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Invalid header value for ContainerEntity - value: {} is invalid {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<hyper::header::HeaderValue>
+ for header::IntoHeaderValue<ContainerEntity>
+{
+ type Error = String;
+
+ fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
+ match hdr_value.to_str() {
+ std::result::Result::Ok(value) => {
+ match <ContainerEntity as std::str::FromStr>::from_str(value) {
+ std::result::Result::Ok(value) => {
+ std::result::Result::Ok(header::IntoHeaderValue(value))
+ }
+ std::result::Result::Err(err) => std::result::Result::Err(format!(
+ "Unable to convert header value '{}' into ContainerEntity - {}",
+ value, err
+ )),
+ }
+ }
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Unable to convert header: {:?} to string: {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
+#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ContainerEntity {
- #[serde(rename = "wikidata_qid")]
+ // Note: inline enums are not fully supported by openapi-generator
+ #[serde(rename = "state")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub wikidata_qid: Option<String>,
+ pub state: Option<String>,
- /// Linking ISSN number (ISSN-L). Should be valid and registered with issn.org
- #[serde(rename = "issnl")]
+ /// base32-encoded unique identifier
+ #[serde(rename = "ident")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub issnl: Option<String>,
+ pub ident: Option<String>,
- /// Name of the organization or entity responsible for publication. Not the complete imprint/brand.
- #[serde(rename = "publisher")]
+ /// UUID (lower-case, dash-separated, hex-encoded 128-bit)
+ #[serde(rename = "revision")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub publisher: Option<String>,
+ pub revision: Option<String>,
- /// Type of container, eg 'journal' or 'proceedings'. See Guide for list of valid types.
- #[serde(rename = "container_type")]
+ /// base32-encoded unique identifier
+ #[serde(rename = "redirect")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub container_type: Option<String>,
+ pub redirect: Option<String>,
- /// Name of the container (eg, Journal title). Required for entity creation.
- #[serde(rename = "name")]
+ /// Free-form JSON metadata that will be stored with the other entity metadata. See guide for (unenforced) schema conventions.
+ #[serde(rename = "extra")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub name: Option<String>,
+ pub extra: Option<std::collections::HashMap<String, serde_json::Value>>,
/// Free-form JSON metadata that will be stored with specific entity edits (eg, creation/update/delete).
#[serde(rename = "edit_extra")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub edit_extra: Option<serde_json::Value>,
+ pub edit_extra: Option<std::collections::HashMap<String, serde_json::Value>>,
- /// Free-form JSON metadata that will be stored with the other entity metadata. See guide for (unenforced) schema conventions.
- #[serde(rename = "extra")]
+ /// Name of the container (eg, Journal title). Required for entity creation.
+ #[serde(rename = "name")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub extra: Option<serde_json::Value>,
+ pub name: Option<String>,
- /// base32-encoded unique identifier
- #[serde(rename = "redirect")]
+ /// Type of container, eg 'journal' or 'proceedings'. See Guide for list of valid types.
+ #[serde(rename = "container_type")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub redirect: Option<String>,
+ pub container_type: Option<String>,
- /// UUID (lower-case, dash-separated, hex-encoded 128-bit)
- #[serde(rename = "revision")]
+ /// Name of the organization or entity responsible for publication. Not the complete imprint/brand.
+ #[serde(rename = "publisher")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub revision: Option<String>,
+ pub publisher: Option<String>,
- /// base32-encoded unique identifier
- #[serde(rename = "ident")]
+ /// Linking ISSN number (ISSN-L). Should be valid and registered with issn.org
+ #[serde(rename = "issnl")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub ident: Option<String>,
+ pub issnl: Option<String>,
- // Note: inline enums are not fully supported by swagger-codegen
- #[serde(rename = "state")]
+ #[serde(rename = "wikidata_qid")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub state: Option<String>,
+ pub wikidata_qid: Option<String>,
}
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,
+ ident: None,
+ revision: None,
+ redirect: None,
+ extra: None,
+ edit_extra: None,
+ name: None,
+ container_type: None,
+ publisher: None,
+ issnl: None,
+ wikidata_qid: None,
+ }
+ }
+}
+
+/// Converts the ContainerEntity value to the Query Parameters representation (style=form, explode=false)
+/// specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde serializer
+impl std::string::ToString for ContainerEntity {
+ fn to_string(&self) -> String {
+ let mut params: Vec<String> = vec![];
+
+ if let Some(ref state) = self.state {
+ params.push("state".to_string());
+ params.push(state.to_string());
+ }
+
+ if let Some(ref ident) = self.ident {
+ params.push("ident".to_string());
+ params.push(ident.to_string());
+ }
+
+ if let Some(ref revision) = self.revision {
+ params.push("revision".to_string());
+ params.push(revision.to_string());
+ }
+
+ if let Some(ref redirect) = self.redirect {
+ params.push("redirect".to_string());
+ params.push(redirect.to_string());
}
+
+ // Skipping extra in query parameter serialization
+ // Skipping extra in query parameter serialization
+
+ // Skipping edit_extra in query parameter serialization
+ // Skipping edit_extra in query parameter serialization
+
+ if let Some(ref name) = self.name {
+ params.push("name".to_string());
+ params.push(name.to_string());
+ }
+
+ if let Some(ref container_type) = self.container_type {
+ params.push("container_type".to_string());
+ params.push(container_type.to_string());
+ }
+
+ if let Some(ref publisher) = self.publisher {
+ params.push("publisher".to_string());
+ params.push(publisher.to_string());
+ }
+
+ if let Some(ref issnl) = self.issnl {
+ params.push("issnl".to_string());
+ params.push(issnl.to_string());
+ }
+
+ if let Some(ref wikidata_qid) = self.wikidata_qid {
+ params.push("wikidata_qid".to_string());
+ params.push(wikidata_qid.to_string());
+ }
+
+ params.join(",").to_string()
}
}
-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+/// Converts Query Parameters representation (style=form, explode=false) to a ContainerEntity value
+/// as specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde deserializer
+impl std::str::FromStr for ContainerEntity {
+ type Err = String;
+
+ fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
+ #[derive(Default)]
+ // An intermediate representation of the struct to use for parsing.
+ struct IntermediateRep {
+ pub state: Vec<String>,
+ pub ident: Vec<String>,
+ pub revision: Vec<String>,
+ pub redirect: Vec<String>,
+ pub extra: Vec<std::collections::HashMap<String, serde_json::Value>>,
+ pub edit_extra: Vec<std::collections::HashMap<String, serde_json::Value>>,
+ pub name: Vec<String>,
+ pub container_type: Vec<String>,
+ pub publisher: Vec<String>,
+ pub issnl: Vec<String>,
+ pub wikidata_qid: Vec<String>,
+ }
+
+ let mut intermediate_rep = IntermediateRep::default();
+
+ // Parse into intermediate representation
+ let mut string_iter = s.split(',').into_iter();
+ let mut key_result = string_iter.next();
+
+ while key_result.is_some() {
+ let val = match string_iter.next() {
+ Some(x) => x,
+ None => {
+ return std::result::Result::Err(
+ "Missing value while parsing ContainerEntity".to_string(),
+ )
+ }
+ };
+
+ if let Some(key) = key_result {
+ match key {
+ "state" => intermediate_rep
+ .state
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "ident" => intermediate_rep
+ .ident
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "revision" => intermediate_rep
+ .revision
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "redirect" => intermediate_rep
+ .redirect
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "extra" => {
+ return std::result::Result::Err(
+ "Parsing a container in this style is not supported in ContainerEntity"
+ .to_string(),
+ )
+ }
+ "edit_extra" => {
+ return std::result::Result::Err(
+ "Parsing a container in this style is not supported in ContainerEntity"
+ .to_string(),
+ )
+ }
+ "name" => intermediate_rep
+ .name
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "container_type" => intermediate_rep
+ .container_type
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "publisher" => intermediate_rep
+ .publisher
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "issnl" => intermediate_rep
+ .issnl
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "wikidata_qid" => intermediate_rep
+ .wikidata_qid
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ _ => {
+ return std::result::Result::Err(
+ "Unexpected key while parsing ContainerEntity".to_string(),
+ )
+ }
+ }
+ }
+
+ // Get the next key
+ key_result = string_iter.next();
+ }
+
+ // Use the intermediate representation to return the struct
+ std::result::Result::Ok(ContainerEntity {
+ state: intermediate_rep.state.into_iter().next(),
+ ident: intermediate_rep.ident.into_iter().next(),
+ revision: intermediate_rep.revision.into_iter().next(),
+ redirect: intermediate_rep.redirect.into_iter().next(),
+ extra: intermediate_rep.extra.into_iter().next(),
+ edit_extra: intermediate_rep.edit_extra.into_iter().next(),
+ name: intermediate_rep.name.into_iter().next(),
+ container_type: intermediate_rep.container_type.into_iter().next(),
+ publisher: intermediate_rep.publisher.into_iter().next(),
+ issnl: intermediate_rep.issnl.into_iter().next(),
+ wikidata_qid: intermediate_rep.wikidata_qid.into_iter().next(),
+ })
+ }
+}
+
+// Methods for converting between header::IntoHeaderValue<CreatorAutoBatch> and hyper::header::HeaderValue
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<header::IntoHeaderValue<CreatorAutoBatch>>
+ for hyper::header::HeaderValue
+{
+ type Error = String;
+
+ fn try_from(
+ hdr_value: header::IntoHeaderValue<CreatorAutoBatch>,
+ ) -> std::result::Result<Self, Self::Error> {
+ let hdr_value = hdr_value.to_string();
+ match hyper::header::HeaderValue::from_str(&hdr_value) {
+ std::result::Result::Ok(value) => std::result::Result::Ok(value),
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Invalid header value for CreatorAutoBatch - value: {} is invalid {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<hyper::header::HeaderValue>
+ for header::IntoHeaderValue<CreatorAutoBatch>
+{
+ type Error = String;
+
+ fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
+ match hdr_value.to_str() {
+ std::result::Result::Ok(value) => {
+ match <CreatorAutoBatch as std::str::FromStr>::from_str(value) {
+ std::result::Result::Ok(value) => {
+ std::result::Result::Ok(header::IntoHeaderValue(value))
+ }
+ std::result::Result::Err(err) => std::result::Result::Err(format!(
+ "Unable to convert header value '{}' into CreatorAutoBatch - {}",
+ value, err
+ )),
+ }
+ }
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Unable to convert header: {:?} to string: {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
+#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct CreatorAutoBatch {
#[serde(rename = "editgroup")]
pub editgroup: models::Editgroup,
@@ -199,7 +1155,10 @@ pub struct CreatorAutoBatch {
}
impl CreatorAutoBatch {
- pub fn new(editgroup: models::Editgroup, entity_list: Vec<models::CreatorEntity>) -> CreatorAutoBatch {
+ pub fn new(
+ editgroup: models::Editgroup,
+ entity_list: Vec<models::CreatorEntity>,
+ ) -> CreatorAutoBatch {
CreatorAutoBatch {
editgroup: editgroup,
entity_list: entity_list,
@@ -207,34 +1166,136 @@ impl CreatorAutoBatch {
}
}
-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
-pub struct CreatorEntity {
- /// Wikidata entity QID
- #[serde(rename = "wikidata_qid")]
- #[serde(skip_serializing_if = "Option::is_none")]
- pub wikidata_qid: Option<String>,
+/// Converts the CreatorAutoBatch value to the Query Parameters representation (style=form, explode=false)
+/// specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde serializer
+impl std::string::ToString for CreatorAutoBatch {
+ fn to_string(&self) -> String {
+ let mut params: Vec<String> = vec![];
+ // Skipping editgroup in query parameter serialization
- /// ORCiD (https://orcid.org) identifier
- #[serde(rename = "orcid")]
- #[serde(skip_serializing_if = "Option::is_none")]
- pub orcid: Option<String>,
+ // Skipping entity_list in query parameter serialization
- /// In English commonly the last, or family name, but ordering is context and culture specific.
- #[serde(rename = "surname")]
- #[serde(skip_serializing_if = "Option::is_none")]
- pub surname: Option<String>,
+ params.join(",").to_string()
+ }
+}
- /// In English commonly the first name, but ordering is context and culture specific.
- #[serde(rename = "given_name")]
- #[serde(skip_serializing_if = "Option::is_none")]
- pub given_name: Option<String>,
+/// Converts Query Parameters representation (style=form, explode=false) to a CreatorAutoBatch value
+/// as specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde deserializer
+impl std::str::FromStr for CreatorAutoBatch {
+ type Err = String;
+
+ fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
+ #[derive(Default)]
+ // An intermediate representation of the struct to use for parsing.
+ struct IntermediateRep {
+ pub editgroup: Vec<models::Editgroup>,
+ pub entity_list: Vec<Vec<models::CreatorEntity>>,
+ }
- /// Name as should be displayed in web interface or in author lists (not index/sorted). Required for valid entities.
- #[serde(rename = "display_name")]
- #[serde(skip_serializing_if = "Option::is_none")]
- pub display_name: Option<String>,
+ let mut intermediate_rep = IntermediateRep::default();
+
+ // Parse into intermediate representation
+ let mut string_iter = s.split(',').into_iter();
+ let mut key_result = string_iter.next();
+
+ while key_result.is_some() {
+ let val = match string_iter.next() {
+ Some(x) => x,
+ None => {
+ return std::result::Result::Err(
+ "Missing value while parsing CreatorAutoBatch".to_string(),
+ )
+ }
+ };
+
+ if let Some(key) = key_result {
+ match key {
+ "editgroup" => intermediate_rep
+ .editgroup
+ .push(models::Editgroup::from_str(val).map_err(|x| format!("{}", x))?),
+ "entity_list" => return std::result::Result::Err(
+ "Parsing a container in this style is not supported in CreatorAutoBatch"
+ .to_string(),
+ ),
+ _ => {
+ return std::result::Result::Err(
+ "Unexpected key while parsing CreatorAutoBatch".to_string(),
+ )
+ }
+ }
+ }
+
+ // Get the next key
+ key_result = string_iter.next();
+ }
+
+ // Use the intermediate representation to return the struct
+ std::result::Result::Ok(CreatorAutoBatch {
+ editgroup: intermediate_rep
+ .editgroup
+ .into_iter()
+ .next()
+ .ok_or("editgroup missing in CreatorAutoBatch".to_string())?,
+ entity_list: intermediate_rep
+ .entity_list
+ .into_iter()
+ .next()
+ .ok_or("entity_list missing in CreatorAutoBatch".to_string())?,
+ })
+ }
+}
+
+// Methods for converting between header::IntoHeaderValue<CreatorEntity> and hyper::header::HeaderValue
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<header::IntoHeaderValue<CreatorEntity>> for hyper::header::HeaderValue {
+ type Error = String;
+
+ fn try_from(
+ hdr_value: header::IntoHeaderValue<CreatorEntity>,
+ ) -> std::result::Result<Self, Self::Error> {
+ let hdr_value = hdr_value.to_string();
+ match hyper::header::HeaderValue::from_str(&hdr_value) {
+ std::result::Result::Ok(value) => std::result::Result::Ok(value),
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Invalid header value for CreatorEntity - value: {} is invalid {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<CreatorEntity> {
+ type Error = String;
+
+ fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
+ match hdr_value.to_str() {
+ std::result::Result::Ok(value) => {
+ match <CreatorEntity as std::str::FromStr>::from_str(value) {
+ std::result::Result::Ok(value) => {
+ std::result::Result::Ok(header::IntoHeaderValue(value))
+ }
+ std::result::Result::Err(err) => std::result::Result::Err(format!(
+ "Unable to convert header value '{}' into CreatorEntity - {}",
+ value, err
+ )),
+ }
+ }
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Unable to convert header: {:?} to string: {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
- // Note: inline enums are not fully supported by swagger-codegen
+#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
+#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
+pub struct CreatorEntity {
+ // Note: inline enums are not fully supported by openapi-generator
#[serde(rename = "state")]
#[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<String>,
@@ -257,33 +1318,275 @@ pub struct CreatorEntity {
/// Free-form JSON metadata that will be stored with the other entity metadata. See guide for (unenforced) schema conventions.
#[serde(rename = "extra")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub extra: Option<serde_json::Value>,
+ pub extra: Option<std::collections::HashMap<String, serde_json::Value>>,
/// Free-form JSON metadata that will be stored with specific entity edits (eg, creation/update/delete).
#[serde(rename = "edit_extra")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub edit_extra: Option<serde_json::Value>,
+ pub edit_extra: Option<std::collections::HashMap<String, serde_json::Value>>,
+
+ /// Name as should be displayed in web interface or in author lists (not index/sorted). Required for valid entities.
+ #[serde(rename = "display_name")]
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub display_name: Option<String>,
+
+ /// In English commonly the first name, but ordering is context and culture specific.
+ #[serde(rename = "given_name")]
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub given_name: Option<String>,
+
+ /// In English commonly the last, or family name, but ordering is context and culture specific.
+ #[serde(rename = "surname")]
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub surname: Option<String>,
+
+ /// ORCiD (https://orcid.org) identifier
+ #[serde(rename = "orcid")]
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub orcid: Option<String>,
+
+ /// Wikidata entity QID
+ #[serde(rename = "wikidata_qid")]
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub wikidata_qid: Option<String>,
}
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,
+ display_name: None,
+ given_name: None,
+ surname: None,
+ orcid: None,
+ wikidata_qid: None,
}
}
}
-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+/// Converts the CreatorEntity value to the Query Parameters representation (style=form, explode=false)
+/// specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde serializer
+impl std::string::ToString for CreatorEntity {
+ fn to_string(&self) -> String {
+ let mut params: Vec<String> = vec![];
+
+ if let Some(ref state) = self.state {
+ params.push("state".to_string());
+ params.push(state.to_string());
+ }
+
+ if let Some(ref ident) = self.ident {
+ params.push("ident".to_string());
+ params.push(ident.to_string());
+ }
+
+ if let Some(ref revision) = self.revision {
+ params.push("revision".to_string());
+ params.push(revision.to_string());
+ }
+
+ if let Some(ref redirect) = self.redirect {
+ params.push("redirect".to_string());
+ params.push(redirect.to_string());
+ }
+
+ // Skipping extra in query parameter serialization
+ // Skipping extra in query parameter serialization
+
+ // Skipping edit_extra in query parameter serialization
+ // Skipping edit_extra in query parameter serialization
+
+ if let Some(ref display_name) = self.display_name {
+ params.push("display_name".to_string());
+ params.push(display_name.to_string());
+ }
+
+ if let Some(ref given_name) = self.given_name {
+ params.push("given_name".to_string());
+ params.push(given_name.to_string());
+ }
+
+ if let Some(ref surname) = self.surname {
+ params.push("surname".to_string());
+ params.push(surname.to_string());
+ }
+
+ if let Some(ref orcid) = self.orcid {
+ params.push("orcid".to_string());
+ params.push(orcid.to_string());
+ }
+
+ if let Some(ref wikidata_qid) = self.wikidata_qid {
+ params.push("wikidata_qid".to_string());
+ params.push(wikidata_qid.to_string());
+ }
+
+ params.join(",").to_string()
+ }
+}
+
+/// Converts Query Parameters representation (style=form, explode=false) to a CreatorEntity value
+/// as specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde deserializer
+impl std::str::FromStr for CreatorEntity {
+ type Err = String;
+
+ fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
+ #[derive(Default)]
+ // An intermediate representation of the struct to use for parsing.
+ struct IntermediateRep {
+ pub state: Vec<String>,
+ pub ident: Vec<String>,
+ pub revision: Vec<String>,
+ pub redirect: Vec<String>,
+ pub extra: Vec<std::collections::HashMap<String, serde_json::Value>>,
+ pub edit_extra: Vec<std::collections::HashMap<String, serde_json::Value>>,
+ pub display_name: Vec<String>,
+ pub given_name: Vec<String>,
+ pub surname: Vec<String>,
+ pub orcid: Vec<String>,
+ pub wikidata_qid: Vec<String>,
+ }
+
+ let mut intermediate_rep = IntermediateRep::default();
+
+ // Parse into intermediate representation
+ let mut string_iter = s.split(',').into_iter();
+ let mut key_result = string_iter.next();
+
+ while key_result.is_some() {
+ let val = match string_iter.next() {
+ Some(x) => x,
+ None => {
+ return std::result::Result::Err(
+ "Missing value while parsing CreatorEntity".to_string(),
+ )
+ }
+ };
+
+ if let Some(key) = key_result {
+ match key {
+ "state" => intermediate_rep
+ .state
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "ident" => intermediate_rep
+ .ident
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "revision" => intermediate_rep
+ .revision
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "redirect" => intermediate_rep
+ .redirect
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "extra" => {
+ return std::result::Result::Err(
+ "Parsing a container in this style is not supported in CreatorEntity"
+ .to_string(),
+ )
+ }
+ "edit_extra" => {
+ return std::result::Result::Err(
+ "Parsing a container in this style is not supported in CreatorEntity"
+ .to_string(),
+ )
+ }
+ "display_name" => intermediate_rep
+ .display_name
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "given_name" => intermediate_rep
+ .given_name
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "surname" => intermediate_rep
+ .surname
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "orcid" => intermediate_rep
+ .orcid
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "wikidata_qid" => intermediate_rep
+ .wikidata_qid
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ _ => {
+ return std::result::Result::Err(
+ "Unexpected key while parsing CreatorEntity".to_string(),
+ )
+ }
+ }
+ }
+
+ // Get the next key
+ key_result = string_iter.next();
+ }
+
+ // Use the intermediate representation to return the struct
+ std::result::Result::Ok(CreatorEntity {
+ state: intermediate_rep.state.into_iter().next(),
+ ident: intermediate_rep.ident.into_iter().next(),
+ revision: intermediate_rep.revision.into_iter().next(),
+ redirect: intermediate_rep.redirect.into_iter().next(),
+ extra: intermediate_rep.extra.into_iter().next(),
+ edit_extra: intermediate_rep.edit_extra.into_iter().next(),
+ display_name: intermediate_rep.display_name.into_iter().next(),
+ given_name: intermediate_rep.given_name.into_iter().next(),
+ surname: intermediate_rep.surname.into_iter().next(),
+ orcid: intermediate_rep.orcid.into_iter().next(),
+ wikidata_qid: intermediate_rep.wikidata_qid.into_iter().next(),
+ })
+ }
+}
+
+// Methods for converting between header::IntoHeaderValue<Editgroup> and hyper::header::HeaderValue
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<header::IntoHeaderValue<Editgroup>> for hyper::header::HeaderValue {
+ type Error = String;
+
+ fn try_from(
+ hdr_value: header::IntoHeaderValue<Editgroup>,
+ ) -> std::result::Result<Self, Self::Error> {
+ let hdr_value = hdr_value.to_string();
+ match hyper::header::HeaderValue::from_str(&hdr_value) {
+ std::result::Result::Ok(value) => std::result::Result::Ok(value),
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Invalid header value for Editgroup - value: {} is invalid {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<Editgroup> {
+ type Error = String;
+
+ fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
+ match hdr_value.to_str() {
+ std::result::Result::Ok(value) => {
+ match <Editgroup as std::str::FromStr>::from_str(value) {
+ std::result::Result::Ok(value) => {
+ std::result::Result::Ok(header::IntoHeaderValue(value))
+ }
+ std::result::Result::Err(err) => std::result::Result::Err(format!(
+ "Unable to convert header value '{}' into Editgroup - {}",
+ value, err
+ )),
+ }
+ }
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Unable to convert header: {:?} to string: {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
+#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct Editgroup {
/// Fatcat identifier for this editgroup. Assigned on creation.
#[serde(rename = "editgroup_id")]
@@ -295,7 +1598,6 @@ pub struct Editgroup {
#[serde(skip_serializing_if = "Option::is_none")]
pub editor_id: Option<String>,
- /// Complete editor object identified by `container_id` field. Only included in GET responses.
#[serde(rename = "editor")]
#[serde(skip_serializing_if = "Option::is_none")]
pub editor: Option<models::Editor>,
@@ -323,7 +1625,7 @@ pub struct Editgroup {
/// Free-form JSON metadata attached to this editgroup. Eg, metadata provenance, or script user-agent details. See guide for (unenforced) schema norms.
#[serde(rename = "extra")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub extra: Option<serde_json::Value>,
+ pub extra: Option<std::collections::HashMap<String, serde_json::Value>>,
/// Only included in GET responses, and not in all contexts. Do not include this field in PUT or POST requests.
#[serde(rename = "annotations")]
@@ -352,7 +1654,207 @@ impl Editgroup {
}
}
-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+/// Converts the Editgroup value to the Query Parameters representation (style=form, explode=false)
+/// specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde serializer
+impl std::string::ToString for Editgroup {
+ fn to_string(&self) -> String {
+ let mut params: Vec<String> = vec![];
+
+ if let Some(ref editgroup_id) = self.editgroup_id {
+ params.push("editgroup_id".to_string());
+ params.push(editgroup_id.to_string());
+ }
+
+ if let Some(ref editor_id) = self.editor_id {
+ params.push("editor_id".to_string());
+ params.push(editor_id.to_string());
+ }
+
+ // Skipping editor in query parameter serialization
+
+ if let Some(ref changelog_index) = self.changelog_index {
+ params.push("changelog_index".to_string());
+ params.push(changelog_index.to_string());
+ }
+
+ // Skipping created in query parameter serialization
+
+ // Skipping submitted in query parameter serialization
+
+ if let Some(ref description) = self.description {
+ params.push("description".to_string());
+ params.push(description.to_string());
+ }
+
+ // Skipping extra in query parameter serialization
+ // Skipping extra in query parameter serialization
+
+ // Skipping annotations in query parameter serialization
+
+ // Skipping edits in query parameter serialization
+
+ params.join(",").to_string()
+ }
+}
+
+/// Converts Query Parameters representation (style=form, explode=false) to a Editgroup value
+/// as specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde deserializer
+impl std::str::FromStr for Editgroup {
+ type Err = String;
+
+ fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
+ #[derive(Default)]
+ // An intermediate representation of the struct to use for parsing.
+ struct IntermediateRep {
+ pub editgroup_id: Vec<String>,
+ pub editor_id: Vec<String>,
+ pub editor: Vec<models::Editor>,
+ pub changelog_index: Vec<i64>,
+ pub created: Vec<chrono::DateTime<chrono::Utc>>,
+ pub submitted: Vec<chrono::DateTime<chrono::Utc>>,
+ pub description: Vec<String>,
+ pub extra: Vec<std::collections::HashMap<String, serde_json::Value>>,
+ pub annotations: Vec<Vec<models::EditgroupAnnotation>>,
+ pub edits: Vec<models::EditgroupEdits>,
+ }
+
+ let mut intermediate_rep = IntermediateRep::default();
+
+ // Parse into intermediate representation
+ let mut string_iter = s.split(',').into_iter();
+ let mut key_result = string_iter.next();
+
+ while key_result.is_some() {
+ let val = match string_iter.next() {
+ Some(x) => x,
+ None => {
+ return std::result::Result::Err(
+ "Missing value while parsing Editgroup".to_string(),
+ )
+ }
+ };
+
+ if let Some(key) = key_result {
+ match key {
+ "editgroup_id" => intermediate_rep
+ .editgroup_id
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "editor_id" => intermediate_rep
+ .editor_id
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "editor" => intermediate_rep
+ .editor
+ .push(models::Editor::from_str(val).map_err(|x| format!("{}", x))?),
+ "changelog_index" => intermediate_rep
+ .changelog_index
+ .push(i64::from_str(val).map_err(|x| format!("{}", x))?),
+ "created" => intermediate_rep.created.push(
+ chrono::DateTime::<chrono::Utc>::from_str(val)
+ .map_err(|x| format!("{}", x))?,
+ ),
+ "submitted" => intermediate_rep.submitted.push(
+ chrono::DateTime::<chrono::Utc>::from_str(val)
+ .map_err(|x| format!("{}", x))?,
+ ),
+ "description" => intermediate_rep
+ .description
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "extra" => {
+ return std::result::Result::Err(
+ "Parsing a container in this style is not supported in Editgroup"
+ .to_string(),
+ )
+ }
+ "annotations" => {
+ return std::result::Result::Err(
+ "Parsing a container in this style is not supported in Editgroup"
+ .to_string(),
+ )
+ }
+ "edits" => intermediate_rep
+ .edits
+ .push(models::EditgroupEdits::from_str(val).map_err(|x| format!("{}", x))?),
+ _ => {
+ return std::result::Result::Err(
+ "Unexpected key while parsing Editgroup".to_string(),
+ )
+ }
+ }
+ }
+
+ // Get the next key
+ key_result = string_iter.next();
+ }
+
+ // Use the intermediate representation to return the struct
+ std::result::Result::Ok(Editgroup {
+ editgroup_id: intermediate_rep.editgroup_id.into_iter().next(),
+ editor_id: intermediate_rep.editor_id.into_iter().next(),
+ editor: intermediate_rep.editor.into_iter().next(),
+ changelog_index: intermediate_rep.changelog_index.into_iter().next(),
+ created: intermediate_rep.created.into_iter().next(),
+ submitted: intermediate_rep.submitted.into_iter().next(),
+ description: intermediate_rep.description.into_iter().next(),
+ extra: intermediate_rep.extra.into_iter().next(),
+ annotations: intermediate_rep.annotations.into_iter().next(),
+ edits: intermediate_rep.edits.into_iter().next(),
+ })
+ }
+}
+
+// Methods for converting between header::IntoHeaderValue<EditgroupAnnotation> and hyper::header::HeaderValue
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<header::IntoHeaderValue<EditgroupAnnotation>>
+ for hyper::header::HeaderValue
+{
+ type Error = String;
+
+ fn try_from(
+ hdr_value: header::IntoHeaderValue<EditgroupAnnotation>,
+ ) -> std::result::Result<Self, Self::Error> {
+ let hdr_value = hdr_value.to_string();
+ match hyper::header::HeaderValue::from_str(&hdr_value) {
+ std::result::Result::Ok(value) => std::result::Result::Ok(value),
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Invalid header value for EditgroupAnnotation - value: {} is invalid {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<hyper::header::HeaderValue>
+ for header::IntoHeaderValue<EditgroupAnnotation>
+{
+ type Error = String;
+
+ fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
+ match hdr_value.to_str() {
+ std::result::Result::Ok(value) => {
+ match <EditgroupAnnotation as std::str::FromStr>::from_str(value) {
+ std::result::Result::Ok(value) => {
+ std::result::Result::Ok(header::IntoHeaderValue(value))
+ }
+ std::result::Result::Err(err) => std::result::Result::Err(format!(
+ "Unable to convert header value '{}' into EditgroupAnnotation - {}",
+ value, err
+ )),
+ }
+ }
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Unable to convert header: {:?} to string: {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
+#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct EditgroupAnnotation {
/// UUID (lower-case, dash-separated, hex-encoded 128-bit)
#[serde(rename = "annotation_id")]
@@ -369,7 +1871,6 @@ pub struct EditgroupAnnotation {
#[serde(skip_serializing_if = "Option::is_none")]
pub editor_id: Option<String>,
- /// Only included in GET responses; ignored in PUT or POST requests.
#[serde(rename = "editor")]
#[serde(skip_serializing_if = "Option::is_none")]
pub editor: Option<models::Editor>,
@@ -386,7 +1887,7 @@ pub struct EditgroupAnnotation {
/// Additional free-form JSON metadata that can be included as part of the annotation (or even as the primary annotation itself). See guide for details.
#[serde(rename = "extra")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub extra: Option<serde_json::Value>,
+ pub extra: Option<std::collections::HashMap<String, serde_json::Value>>,
}
impl EditgroupAnnotation {
@@ -403,8 +1904,177 @@ impl EditgroupAnnotation {
}
}
+/// Converts the EditgroupAnnotation value to the Query Parameters representation (style=form, explode=false)
+/// specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde serializer
+impl std::string::ToString for EditgroupAnnotation {
+ fn to_string(&self) -> String {
+ let mut params: Vec<String> = vec![];
+
+ if let Some(ref annotation_id) = self.annotation_id {
+ params.push("annotation_id".to_string());
+ params.push(annotation_id.to_string());
+ }
+
+ if let Some(ref editgroup_id) = self.editgroup_id {
+ params.push("editgroup_id".to_string());
+ params.push(editgroup_id.to_string());
+ }
+
+ if let Some(ref editor_id) = self.editor_id {
+ params.push("editor_id".to_string());
+ params.push(editor_id.to_string());
+ }
+
+ // Skipping editor in query parameter serialization
+
+ // Skipping created in query parameter serialization
+
+ if let Some(ref comment_markdown) = self.comment_markdown {
+ params.push("comment_markdown".to_string());
+ params.push(comment_markdown.to_string());
+ }
+
+ // Skipping extra in query parameter serialization
+ // Skipping extra in query parameter serialization
+
+ params.join(",").to_string()
+ }
+}
+
+/// Converts Query Parameters representation (style=form, explode=false) to a EditgroupAnnotation value
+/// as specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde deserializer
+impl std::str::FromStr for EditgroupAnnotation {
+ type Err = String;
+
+ fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
+ #[derive(Default)]
+ // An intermediate representation of the struct to use for parsing.
+ struct IntermediateRep {
+ pub annotation_id: Vec<String>,
+ pub editgroup_id: Vec<String>,
+ pub editor_id: Vec<String>,
+ pub editor: Vec<models::Editor>,
+ pub created: Vec<chrono::DateTime<chrono::Utc>>,
+ pub comment_markdown: Vec<String>,
+ pub extra: Vec<std::collections::HashMap<String, serde_json::Value>>,
+ }
+
+ let mut intermediate_rep = IntermediateRep::default();
+
+ // Parse into intermediate representation
+ let mut string_iter = s.split(',').into_iter();
+ let mut key_result = string_iter.next();
+
+ while key_result.is_some() {
+ let val = match string_iter.next() {
+ Some(x) => x,
+ None => {
+ return std::result::Result::Err(
+ "Missing value while parsing EditgroupAnnotation".to_string(),
+ )
+ }
+ };
+
+ if let Some(key) = key_result {
+ match key {
+ "annotation_id" => intermediate_rep
+ .annotation_id
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "editgroup_id" => intermediate_rep
+ .editgroup_id
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "editor_id" => intermediate_rep
+ .editor_id
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "editor" => intermediate_rep
+ .editor
+ .push(models::Editor::from_str(val).map_err(|x| format!("{}", x))?),
+ "created" => intermediate_rep.created.push(
+ chrono::DateTime::<chrono::Utc>::from_str(val)
+ .map_err(|x| format!("{}", x))?,
+ ),
+ "comment_markdown" => intermediate_rep
+ .comment_markdown
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "extra" => return std::result::Result::Err(
+ "Parsing a container in this style is not supported in EditgroupAnnotation"
+ .to_string(),
+ ),
+ _ => {
+ return std::result::Result::Err(
+ "Unexpected key while parsing EditgroupAnnotation".to_string(),
+ )
+ }
+ }
+ }
+
+ // Get the next key
+ key_result = string_iter.next();
+ }
+
+ // Use the intermediate representation to return the struct
+ std::result::Result::Ok(EditgroupAnnotation {
+ annotation_id: intermediate_rep.annotation_id.into_iter().next(),
+ editgroup_id: intermediate_rep.editgroup_id.into_iter().next(),
+ editor_id: intermediate_rep.editor_id.into_iter().next(),
+ editor: intermediate_rep.editor.into_iter().next(),
+ created: intermediate_rep.created.into_iter().next(),
+ comment_markdown: intermediate_rep.comment_markdown.into_iter().next(),
+ extra: intermediate_rep.extra.into_iter().next(),
+ })
+ }
+}
+
/// Only included in GET responses, and not in all contexts. Do not include this field in PUT or POST requests.
-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+// Methods for converting between header::IntoHeaderValue<EditgroupEdits> and hyper::header::HeaderValue
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<header::IntoHeaderValue<EditgroupEdits>> for hyper::header::HeaderValue {
+ type Error = String;
+
+ fn try_from(
+ hdr_value: header::IntoHeaderValue<EditgroupEdits>,
+ ) -> std::result::Result<Self, Self::Error> {
+ let hdr_value = hdr_value.to_string();
+ match hyper::header::HeaderValue::from_str(&hdr_value) {
+ std::result::Result::Ok(value) => std::result::Result::Ok(value),
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Invalid header value for EditgroupEdits - value: {} is invalid {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<EditgroupEdits> {
+ type Error = String;
+
+ fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
+ match hdr_value.to_str() {
+ std::result::Result::Ok(value) => {
+ match <EditgroupEdits as std::str::FromStr>::from_str(value) {
+ std::result::Result::Ok(value) => {
+ std::result::Result::Ok(header::IntoHeaderValue(value))
+ }
+ std::result::Result::Err(err) => std::result::Result::Err(format!(
+ "Unable to convert header value '{}' into EditgroupEdits - {}",
+ value, err
+ )),
+ }
+ }
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Unable to convert header: {:?} to string: {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
+#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct EditgroupEdits {
#[serde(rename = "containers")]
#[serde(skip_serializing_if = "Option::is_none")]
@@ -449,7 +2119,181 @@ impl EditgroupEdits {
}
}
-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+/// Converts the EditgroupEdits value to the Query Parameters representation (style=form, explode=false)
+/// specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde serializer
+impl std::string::ToString for EditgroupEdits {
+ fn to_string(&self) -> String {
+ let mut params: Vec<String> = vec![];
+ // Skipping containers in query parameter serialization
+
+ // Skipping creators in query parameter serialization
+
+ // Skipping files in query parameter serialization
+
+ // Skipping filesets in query parameter serialization
+
+ // Skipping webcaptures in query parameter serialization
+
+ // Skipping releases in query parameter serialization
+
+ // Skipping works in query parameter serialization
+
+ params.join(",").to_string()
+ }
+}
+
+/// Converts Query Parameters representation (style=form, explode=false) to a EditgroupEdits value
+/// as specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde deserializer
+impl std::str::FromStr for EditgroupEdits {
+ type Err = String;
+
+ fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
+ #[derive(Default)]
+ // An intermediate representation of the struct to use for parsing.
+ struct IntermediateRep {
+ pub containers: Vec<Vec<models::EntityEdit>>,
+ pub creators: Vec<Vec<models::EntityEdit>>,
+ pub files: Vec<Vec<models::EntityEdit>>,
+ pub filesets: Vec<Vec<models::EntityEdit>>,
+ pub webcaptures: Vec<Vec<models::EntityEdit>>,
+ pub releases: Vec<Vec<models::EntityEdit>>,
+ pub works: Vec<Vec<models::EntityEdit>>,
+ }
+
+ let mut intermediate_rep = IntermediateRep::default();
+
+ // Parse into intermediate representation
+ let mut string_iter = s.split(',').into_iter();
+ let mut key_result = string_iter.next();
+
+ while key_result.is_some() {
+ let val = match string_iter.next() {
+ Some(x) => x,
+ None => {
+ return std::result::Result::Err(
+ "Missing value while parsing EditgroupEdits".to_string(),
+ )
+ }
+ };
+
+ if let Some(key) = key_result {
+ match key {
+ "containers" => {
+ return std::result::Result::Err(
+ "Parsing a container in this style is not supported in EditgroupEdits"
+ .to_string(),
+ )
+ }
+ "creators" => {
+ return std::result::Result::Err(
+ "Parsing a container in this style is not supported in EditgroupEdits"
+ .to_string(),
+ )
+ }
+ "files" => {
+ return std::result::Result::Err(
+ "Parsing a container in this style is not supported in EditgroupEdits"
+ .to_string(),
+ )
+ }
+ "filesets" => {
+ return std::result::Result::Err(
+ "Parsing a container in this style is not supported in EditgroupEdits"
+ .to_string(),
+ )
+ }
+ "webcaptures" => {
+ return std::result::Result::Err(
+ "Parsing a container in this style is not supported in EditgroupEdits"
+ .to_string(),
+ )
+ }
+ "releases" => {
+ return std::result::Result::Err(
+ "Parsing a container in this style is not supported in EditgroupEdits"
+ .to_string(),
+ )
+ }
+ "works" => {
+ return std::result::Result::Err(
+ "Parsing a container in this style is not supported in EditgroupEdits"
+ .to_string(),
+ )
+ }
+ _ => {
+ return std::result::Result::Err(
+ "Unexpected key while parsing EditgroupEdits".to_string(),
+ )
+ }
+ }
+ }
+
+ // Get the next key
+ key_result = string_iter.next();
+ }
+
+ // Use the intermediate representation to return the struct
+ std::result::Result::Ok(EditgroupEdits {
+ containers: intermediate_rep.containers.into_iter().next(),
+ creators: intermediate_rep.creators.into_iter().next(),
+ files: intermediate_rep.files.into_iter().next(),
+ filesets: intermediate_rep.filesets.into_iter().next(),
+ webcaptures: intermediate_rep.webcaptures.into_iter().next(),
+ releases: intermediate_rep.releases.into_iter().next(),
+ works: intermediate_rep.works.into_iter().next(),
+ })
+ }
+}
+
+// Methods for converting between header::IntoHeaderValue<Editor> and hyper::header::HeaderValue
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<header::IntoHeaderValue<Editor>> for hyper::header::HeaderValue {
+ type Error = String;
+
+ fn try_from(
+ hdr_value: header::IntoHeaderValue<Editor>,
+ ) -> std::result::Result<Self, Self::Error> {
+ let hdr_value = hdr_value.to_string();
+ match hyper::header::HeaderValue::from_str(&hdr_value) {
+ std::result::Result::Ok(value) => std::result::Result::Ok(value),
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Invalid header value for Editor - value: {} is invalid {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<Editor> {
+ type Error = String;
+
+ fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
+ match hdr_value.to_str() {
+ std::result::Result::Ok(value) => {
+ match <Editor as std::str::FromStr>::from_str(value) {
+ std::result::Result::Ok(value) => {
+ std::result::Result::Ok(header::IntoHeaderValue(value))
+ }
+ std::result::Result::Err(err) => std::result::Result::Err(format!(
+ "Unable to convert header value '{}' into Editor - {}",
+ value, err
+ )),
+ }
+ }
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Unable to convert header: {:?} to string: {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
+#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct Editor {
/// Fatcat identifier for the editor. Can not be changed.
#[serde(rename = "editor_id")]
@@ -488,7 +2332,164 @@ impl Editor {
}
}
-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+/// Converts the Editor value to the Query Parameters representation (style=form, explode=false)
+/// specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde serializer
+impl std::string::ToString for Editor {
+ fn to_string(&self) -> String {
+ let mut params: Vec<String> = vec![];
+
+ if let Some(ref editor_id) = self.editor_id {
+ params.push("editor_id".to_string());
+ params.push(editor_id.to_string());
+ }
+
+ params.push("username".to_string());
+ params.push(self.username.to_string());
+
+ if let Some(ref is_admin) = self.is_admin {
+ params.push("is_admin".to_string());
+ params.push(is_admin.to_string());
+ }
+
+ if let Some(ref is_bot) = self.is_bot {
+ params.push("is_bot".to_string());
+ params.push(is_bot.to_string());
+ }
+
+ if let Some(ref is_active) = self.is_active {
+ params.push("is_active".to_string());
+ params.push(is_active.to_string());
+ }
+
+ params.join(",").to_string()
+ }
+}
+
+/// Converts Query Parameters representation (style=form, explode=false) to a Editor value
+/// as specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde deserializer
+impl std::str::FromStr for Editor {
+ type Err = String;
+
+ fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
+ #[derive(Default)]
+ // An intermediate representation of the struct to use for parsing.
+ struct IntermediateRep {
+ pub editor_id: Vec<String>,
+ pub username: Vec<String>,
+ pub is_admin: Vec<bool>,
+ pub is_bot: Vec<bool>,
+ pub is_active: Vec<bool>,
+ }
+
+ let mut intermediate_rep = IntermediateRep::default();
+
+ // Parse into intermediate representation
+ let mut string_iter = s.split(',').into_iter();
+ let mut key_result = string_iter.next();
+
+ while key_result.is_some() {
+ let val = match string_iter.next() {
+ Some(x) => x,
+ None => {
+ return std::result::Result::Err(
+ "Missing value while parsing Editor".to_string(),
+ )
+ }
+ };
+
+ if let Some(key) = key_result {
+ match key {
+ "editor_id" => intermediate_rep
+ .editor_id
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "username" => intermediate_rep
+ .username
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "is_admin" => intermediate_rep
+ .is_admin
+ .push(bool::from_str(val).map_err(|x| format!("{}", x))?),
+ "is_bot" => intermediate_rep
+ .is_bot
+ .push(bool::from_str(val).map_err(|x| format!("{}", x))?),
+ "is_active" => intermediate_rep
+ .is_active
+ .push(bool::from_str(val).map_err(|x| format!("{}", x))?),
+ _ => {
+ return std::result::Result::Err(
+ "Unexpected key while parsing Editor".to_string(),
+ )
+ }
+ }
+ }
+
+ // Get the next key
+ key_result = string_iter.next();
+ }
+
+ // Use the intermediate representation to return the struct
+ std::result::Result::Ok(Editor {
+ editor_id: intermediate_rep.editor_id.into_iter().next(),
+ username: intermediate_rep
+ .username
+ .into_iter()
+ .next()
+ .ok_or("username missing in Editor".to_string())?,
+ is_admin: intermediate_rep.is_admin.into_iter().next(),
+ is_bot: intermediate_rep.is_bot.into_iter().next(),
+ is_active: intermediate_rep.is_active.into_iter().next(),
+ })
+ }
+}
+
+// Methods for converting between header::IntoHeaderValue<EntityEdit> and hyper::header::HeaderValue
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<header::IntoHeaderValue<EntityEdit>> for hyper::header::HeaderValue {
+ type Error = String;
+
+ fn try_from(
+ hdr_value: header::IntoHeaderValue<EntityEdit>,
+ ) -> std::result::Result<Self, Self::Error> {
+ let hdr_value = hdr_value.to_string();
+ match hyper::header::HeaderValue::from_str(&hdr_value) {
+ std::result::Result::Ok(value) => std::result::Result::Ok(value),
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Invalid header value for EntityEdit - value: {} is invalid {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<EntityEdit> {
+ type Error = String;
+
+ fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
+ match hdr_value.to_str() {
+ std::result::Result::Ok(value) => {
+ match <EntityEdit as std::str::FromStr>::from_str(value) {
+ std::result::Result::Ok(value) => {
+ std::result::Result::Ok(header::IntoHeaderValue(value))
+ }
+ std::result::Result::Err(err) => std::result::Result::Err(format!(
+ "Unable to convert header value '{}' into EntityEdit - {}",
+ value, err
+ )),
+ }
+ }
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Unable to convert header: {:?} to string: {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
+#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct EntityEdit {
/// Unique UUID for this specific edit object.
#[serde(rename = "edit_id")]
@@ -519,7 +2520,7 @@ pub struct EntityEdit {
#[serde(rename = "extra")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub extra: Option<serde_json::Value>,
+ pub extra: Option<std::collections::HashMap<String, serde_json::Value>>,
}
impl EntityEdit {
@@ -536,7 +2537,193 @@ impl EntityEdit {
}
}
-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+/// Converts the EntityEdit value to the Query Parameters representation (style=form, explode=false)
+/// specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde serializer
+impl std::string::ToString for EntityEdit {
+ fn to_string(&self) -> String {
+ let mut params: Vec<String> = vec![];
+
+ params.push("edit_id".to_string());
+ params.push(self.edit_id.to_string());
+
+ params.push("ident".to_string());
+ params.push(self.ident.to_string());
+
+ if let Some(ref revision) = self.revision {
+ params.push("revision".to_string());
+ params.push(revision.to_string());
+ }
+
+ if let Some(ref prev_revision) = self.prev_revision {
+ params.push("prev_revision".to_string());
+ params.push(prev_revision.to_string());
+ }
+
+ if let Some(ref redirect_ident) = self.redirect_ident {
+ params.push("redirect_ident".to_string());
+ params.push(redirect_ident.to_string());
+ }
+
+ params.push("editgroup_id".to_string());
+ params.push(self.editgroup_id.to_string());
+
+ // Skipping extra in query parameter serialization
+ // Skipping extra in query parameter serialization
+
+ params.join(",").to_string()
+ }
+}
+
+/// Converts Query Parameters representation (style=form, explode=false) to a EntityEdit value
+/// as specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde deserializer
+impl std::str::FromStr for EntityEdit {
+ type Err = String;
+
+ fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
+ #[derive(Default)]
+ // An intermediate representation of the struct to use for parsing.
+ struct IntermediateRep {
+ pub edit_id: Vec<String>,
+ pub ident: Vec<String>,
+ pub revision: Vec<String>,
+ pub prev_revision: Vec<String>,
+ pub redirect_ident: Vec<String>,
+ pub editgroup_id: Vec<String>,
+ pub extra: Vec<std::collections::HashMap<String, serde_json::Value>>,
+ }
+
+ let mut intermediate_rep = IntermediateRep::default();
+
+ // Parse into intermediate representation
+ let mut string_iter = s.split(',').into_iter();
+ let mut key_result = string_iter.next();
+
+ while key_result.is_some() {
+ let val = match string_iter.next() {
+ Some(x) => x,
+ None => {
+ return std::result::Result::Err(
+ "Missing value while parsing EntityEdit".to_string(),
+ )
+ }
+ };
+
+ if let Some(key) = key_result {
+ match key {
+ "edit_id" => intermediate_rep
+ .edit_id
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "ident" => intermediate_rep
+ .ident
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "revision" => intermediate_rep
+ .revision
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "prev_revision" => intermediate_rep
+ .prev_revision
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "redirect_ident" => intermediate_rep
+ .redirect_ident
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "editgroup_id" => intermediate_rep
+ .editgroup_id
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "extra" => {
+ return std::result::Result::Err(
+ "Parsing a container in this style is not supported in EntityEdit"
+ .to_string(),
+ )
+ }
+ _ => {
+ return std::result::Result::Err(
+ "Unexpected key while parsing EntityEdit".to_string(),
+ )
+ }
+ }
+ }
+
+ // Get the next key
+ key_result = string_iter.next();
+ }
+
+ // Use the intermediate representation to return the struct
+ std::result::Result::Ok(EntityEdit {
+ edit_id: intermediate_rep
+ .edit_id
+ .into_iter()
+ .next()
+ .ok_or("edit_id missing in EntityEdit".to_string())?,
+ ident: intermediate_rep
+ .ident
+ .into_iter()
+ .next()
+ .ok_or("ident missing in EntityEdit".to_string())?,
+ revision: intermediate_rep.revision.into_iter().next(),
+ prev_revision: intermediate_rep.prev_revision.into_iter().next(),
+ redirect_ident: intermediate_rep.redirect_ident.into_iter().next(),
+ editgroup_id: intermediate_rep
+ .editgroup_id
+ .into_iter()
+ .next()
+ .ok_or("editgroup_id missing in EntityEdit".to_string())?,
+ extra: intermediate_rep.extra.into_iter().next(),
+ })
+ }
+}
+
+// Methods for converting between header::IntoHeaderValue<EntityHistoryEntry> and hyper::header::HeaderValue
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<header::IntoHeaderValue<EntityHistoryEntry>>
+ for hyper::header::HeaderValue
+{
+ type Error = String;
+
+ fn try_from(
+ hdr_value: header::IntoHeaderValue<EntityHistoryEntry>,
+ ) -> std::result::Result<Self, Self::Error> {
+ let hdr_value = hdr_value.to_string();
+ match hyper::header::HeaderValue::from_str(&hdr_value) {
+ std::result::Result::Ok(value) => std::result::Result::Ok(value),
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Invalid header value for EntityHistoryEntry - value: {} is invalid {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<hyper::header::HeaderValue>
+ for header::IntoHeaderValue<EntityHistoryEntry>
+{
+ type Error = String;
+
+ fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
+ match hdr_value.to_str() {
+ std::result::Result::Ok(value) => {
+ match <EntityHistoryEntry as std::str::FromStr>::from_str(value) {
+ std::result::Result::Ok(value) => {
+ std::result::Result::Ok(header::IntoHeaderValue(value))
+ }
+ std::result::Result::Err(err) => std::result::Result::Err(format!(
+ "Unable to convert header value '{}' into EntityHistoryEntry - {}",
+ value, err
+ )),
+ }
+ }
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Unable to convert header: {:?} to string: {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
+#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct EntityHistoryEntry {
#[serde(rename = "edit")]
pub edit: models::EntityEdit,
@@ -549,7 +2736,11 @@ pub struct EntityHistoryEntry {
}
impl EntityHistoryEntry {
- pub fn new(edit: models::EntityEdit, editgroup: models::Editgroup, changelog_entry: models::ChangelogEntry) -> EntityHistoryEntry {
+ pub fn new(
+ edit: models::EntityEdit,
+ editgroup: models::Editgroup,
+ changelog_entry: models::ChangelogEntry,
+ ) -> EntityHistoryEntry {
EntityHistoryEntry {
edit: edit,
editgroup: editgroup,
@@ -558,7 +2749,144 @@ impl EntityHistoryEntry {
}
}
-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+/// Converts the EntityHistoryEntry value to the Query Parameters representation (style=form, explode=false)
+/// specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde serializer
+impl std::string::ToString for EntityHistoryEntry {
+ fn to_string(&self) -> String {
+ let mut params: Vec<String> = vec![];
+ // Skipping edit in query parameter serialization
+
+ // Skipping editgroup in query parameter serialization
+
+ // Skipping changelog_entry in query parameter serialization
+
+ params.join(",").to_string()
+ }
+}
+
+/// Converts Query Parameters representation (style=form, explode=false) to a EntityHistoryEntry value
+/// as specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde deserializer
+impl std::str::FromStr for EntityHistoryEntry {
+ type Err = String;
+
+ fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
+ #[derive(Default)]
+ // An intermediate representation of the struct to use for parsing.
+ struct IntermediateRep {
+ pub edit: Vec<models::EntityEdit>,
+ pub editgroup: Vec<models::Editgroup>,
+ pub changelog_entry: Vec<models::ChangelogEntry>,
+ }
+
+ let mut intermediate_rep = IntermediateRep::default();
+
+ // Parse into intermediate representation
+ let mut string_iter = s.split(',').into_iter();
+ let mut key_result = string_iter.next();
+
+ while key_result.is_some() {
+ let val = match string_iter.next() {
+ Some(x) => x,
+ None => {
+ return std::result::Result::Err(
+ "Missing value while parsing EntityHistoryEntry".to_string(),
+ )
+ }
+ };
+
+ if let Some(key) = key_result {
+ match key {
+ "edit" => intermediate_rep
+ .edit
+ .push(models::EntityEdit::from_str(val).map_err(|x| format!("{}", x))?),
+ "editgroup" => intermediate_rep
+ .editgroup
+ .push(models::Editgroup::from_str(val).map_err(|x| format!("{}", x))?),
+ "changelog_entry" => intermediate_rep
+ .changelog_entry
+ .push(models::ChangelogEntry::from_str(val).map_err(|x| format!("{}", x))?),
+ _ => {
+ return std::result::Result::Err(
+ "Unexpected key while parsing EntityHistoryEntry".to_string(),
+ )
+ }
+ }
+ }
+
+ // Get the next key
+ key_result = string_iter.next();
+ }
+
+ // Use the intermediate representation to return the struct
+ std::result::Result::Ok(EntityHistoryEntry {
+ edit: intermediate_rep
+ .edit
+ .into_iter()
+ .next()
+ .ok_or("edit missing in EntityHistoryEntry".to_string())?,
+ editgroup: intermediate_rep
+ .editgroup
+ .into_iter()
+ .next()
+ .ok_or("editgroup missing in EntityHistoryEntry".to_string())?,
+ changelog_entry: intermediate_rep
+ .changelog_entry
+ .into_iter()
+ .next()
+ .ok_or("changelog_entry missing in EntityHistoryEntry".to_string())?,
+ })
+ }
+}
+
+// Methods for converting between header::IntoHeaderValue<ErrorResponse> and hyper::header::HeaderValue
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<header::IntoHeaderValue<ErrorResponse>> for hyper::header::HeaderValue {
+ type Error = String;
+
+ fn try_from(
+ hdr_value: header::IntoHeaderValue<ErrorResponse>,
+ ) -> std::result::Result<Self, Self::Error> {
+ let hdr_value = hdr_value.to_string();
+ match hyper::header::HeaderValue::from_str(&hdr_value) {
+ std::result::Result::Ok(value) => std::result::Result::Ok(value),
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Invalid header value for ErrorResponse - value: {} is invalid {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<ErrorResponse> {
+ type Error = String;
+
+ fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
+ match hdr_value.to_str() {
+ std::result::Result::Ok(value) => {
+ match <ErrorResponse as std::str::FromStr>::from_str(value) {
+ std::result::Result::Ok(value) => {
+ std::result::Result::Ok(header::IntoHeaderValue(value))
+ }
+ std::result::Result::Err(err) => std::result::Result::Err(format!(
+ "Unable to convert header value '{}' into ErrorResponse - {}",
+ value, err
+ )),
+ }
+ }
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Unable to convert header: {:?} to string: {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
+#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ErrorResponse {
#[serde(rename = "success")]
pub success: bool,
@@ -580,7 +2908,148 @@ impl ErrorResponse {
}
}
-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+/// Converts the ErrorResponse value to the Query Parameters representation (style=form, explode=false)
+/// specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde serializer
+impl std::string::ToString for ErrorResponse {
+ fn to_string(&self) -> String {
+ let mut params: Vec<String> = vec![];
+
+ params.push("success".to_string());
+ params.push(self.success.to_string());
+
+ params.push("error".to_string());
+ params.push(self.error.to_string());
+
+ params.push("message".to_string());
+ params.push(self.message.to_string());
+
+ params.join(",").to_string()
+ }
+}
+
+/// Converts Query Parameters representation (style=form, explode=false) to a ErrorResponse value
+/// as specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde deserializer
+impl std::str::FromStr for ErrorResponse {
+ type Err = String;
+
+ fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
+ #[derive(Default)]
+ // An intermediate representation of the struct to use for parsing.
+ struct IntermediateRep {
+ pub success: Vec<bool>,
+ pub error: Vec<String>,
+ pub message: Vec<String>,
+ }
+
+ let mut intermediate_rep = IntermediateRep::default();
+
+ // Parse into intermediate representation
+ let mut string_iter = s.split(',').into_iter();
+ let mut key_result = string_iter.next();
+
+ while key_result.is_some() {
+ let val = match string_iter.next() {
+ Some(x) => x,
+ None => {
+ return std::result::Result::Err(
+ "Missing value while parsing ErrorResponse".to_string(),
+ )
+ }
+ };
+
+ if let Some(key) = key_result {
+ match key {
+ "success" => intermediate_rep
+ .success
+ .push(bool::from_str(val).map_err(|x| format!("{}", x))?),
+ "error" => intermediate_rep
+ .error
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "message" => intermediate_rep
+ .message
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ _ => {
+ return std::result::Result::Err(
+ "Unexpected key while parsing ErrorResponse".to_string(),
+ )
+ }
+ }
+ }
+
+ // Get the next key
+ key_result = string_iter.next();
+ }
+
+ // Use the intermediate representation to return the struct
+ std::result::Result::Ok(ErrorResponse {
+ success: intermediate_rep
+ .success
+ .into_iter()
+ .next()
+ .ok_or("success missing in ErrorResponse".to_string())?,
+ error: intermediate_rep
+ .error
+ .into_iter()
+ .next()
+ .ok_or("error missing in ErrorResponse".to_string())?,
+ message: intermediate_rep
+ .message
+ .into_iter()
+ .next()
+ .ok_or("message missing in ErrorResponse".to_string())?,
+ })
+ }
+}
+
+// Methods for converting between header::IntoHeaderValue<FileAutoBatch> and hyper::header::HeaderValue
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<header::IntoHeaderValue<FileAutoBatch>> for hyper::header::HeaderValue {
+ type Error = String;
+
+ fn try_from(
+ hdr_value: header::IntoHeaderValue<FileAutoBatch>,
+ ) -> std::result::Result<Self, Self::Error> {
+ let hdr_value = hdr_value.to_string();
+ match hyper::header::HeaderValue::from_str(&hdr_value) {
+ std::result::Result::Ok(value) => std::result::Result::Ok(value),
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Invalid header value for FileAutoBatch - value: {} is invalid {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<FileAutoBatch> {
+ type Error = String;
+
+ fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
+ match hdr_value.to_str() {
+ std::result::Result::Ok(value) => {
+ match <FileAutoBatch as std::str::FromStr>::from_str(value) {
+ std::result::Result::Ok(value) => {
+ std::result::Result::Ok(header::IntoHeaderValue(value))
+ }
+ std::result::Result::Err(err) => std::result::Result::Err(format!(
+ "Unable to convert header value '{}' into FileAutoBatch - {}",
+ value, err
+ )),
+ }
+ }
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Unable to convert header: {:?} to string: {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
+#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct FileAutoBatch {
#[serde(rename = "editgroup")]
pub editgroup: models::Editgroup,
@@ -590,7 +3059,10 @@ pub struct FileAutoBatch {
}
impl FileAutoBatch {
- pub fn new(editgroup: models::Editgroup, entity_list: Vec<models::FileEntity>) -> FileAutoBatch {
+ pub fn new(
+ editgroup: models::Editgroup,
+ entity_list: Vec<models::FileEntity>,
+ ) -> FileAutoBatch {
FileAutoBatch {
editgroup: editgroup,
entity_list: entity_list,
@@ -598,99 +3070,485 @@ impl FileAutoBatch {
}
}
-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
-pub struct FileEntity {
- /// Full release entities, included in GET responses when `releases` included in `expand` parameter. Ignored if included in PUT or POST requests.
- #[serde(rename = "releases")]
- #[serde(skip_serializing_if = "Option::is_none")]
- pub releases: Option<Vec<models::ReleaseEntity>>,
+/// Converts the FileAutoBatch value to the Query Parameters representation (style=form, explode=false)
+/// specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde serializer
+impl std::string::ToString for FileAutoBatch {
+ fn to_string(&self) -> String {
+ let mut params: Vec<String> = vec![];
+ // Skipping editgroup in query parameter serialization
- /// Set of identifier of release entities this file represents a full manifestation of. Usually a single release, but some files contain content of multiple full releases (eg, an issue of a journal).
- #[serde(rename = "release_ids")]
+ // Skipping entity_list in query parameter serialization
+
+ params.join(",").to_string()
+ }
+}
+
+/// Converts Query Parameters representation (style=form, explode=false) to a FileAutoBatch value
+/// as specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde deserializer
+impl std::str::FromStr for FileAutoBatch {
+ type Err = String;
+
+ fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
+ #[derive(Default)]
+ // An intermediate representation of the struct to use for parsing.
+ struct IntermediateRep {
+ pub editgroup: Vec<models::Editgroup>,
+ pub entity_list: Vec<Vec<models::FileEntity>>,
+ }
+
+ let mut intermediate_rep = IntermediateRep::default();
+
+ // Parse into intermediate representation
+ let mut string_iter = s.split(',').into_iter();
+ let mut key_result = string_iter.next();
+
+ while key_result.is_some() {
+ let val = match string_iter.next() {
+ Some(x) => x,
+ None => {
+ return std::result::Result::Err(
+ "Missing value while parsing FileAutoBatch".to_string(),
+ )
+ }
+ };
+
+ if let Some(key) = key_result {
+ match key {
+ "editgroup" => intermediate_rep
+ .editgroup
+ .push(models::Editgroup::from_str(val).map_err(|x| format!("{}", x))?),
+ "entity_list" => {
+ return std::result::Result::Err(
+ "Parsing a container in this style is not supported in FileAutoBatch"
+ .to_string(),
+ )
+ }
+ _ => {
+ return std::result::Result::Err(
+ "Unexpected key while parsing FileAutoBatch".to_string(),
+ )
+ }
+ }
+ }
+
+ // Get the next key
+ key_result = string_iter.next();
+ }
+
+ // Use the intermediate representation to return the struct
+ std::result::Result::Ok(FileAutoBatch {
+ editgroup: intermediate_rep
+ .editgroup
+ .into_iter()
+ .next()
+ .ok_or("editgroup missing in FileAutoBatch".to_string())?,
+ entity_list: intermediate_rep
+ .entity_list
+ .into_iter()
+ .next()
+ .ok_or("entity_list missing in FileAutoBatch".to_string())?,
+ })
+ }
+}
+
+// Methods for converting between header::IntoHeaderValue<FileEntity> and hyper::header::HeaderValue
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<header::IntoHeaderValue<FileEntity>> for hyper::header::HeaderValue {
+ type Error = String;
+
+ fn try_from(
+ hdr_value: header::IntoHeaderValue<FileEntity>,
+ ) -> std::result::Result<Self, Self::Error> {
+ let hdr_value = hdr_value.to_string();
+ match hyper::header::HeaderValue::from_str(&hdr_value) {
+ std::result::Result::Ok(value) => std::result::Result::Ok(value),
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Invalid header value for FileEntity - value: {} is invalid {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<FileEntity> {
+ type Error = String;
+
+ fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
+ match hdr_value.to_str() {
+ std::result::Result::Ok(value) => {
+ match <FileEntity as std::str::FromStr>::from_str(value) {
+ std::result::Result::Ok(value) => {
+ std::result::Result::Ok(header::IntoHeaderValue(value))
+ }
+ std::result::Result::Err(err) => std::result::Result::Err(format!(
+ "Unable to convert header value '{}' into FileEntity - {}",
+ value, err
+ )),
+ }
+ }
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Unable to convert header: {:?} to string: {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
+#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
+pub struct FileEntity {
+ // Note: inline enums are not fully supported by openapi-generator
+ #[serde(rename = "state")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub release_ids: Option<Vec<String>>,
+ pub state: Option<String>,
- #[serde(rename = "mimetype")]
+ /// base32-encoded unique identifier
+ #[serde(rename = "ident")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub mimetype: Option<String>,
+ pub ident: Option<String>,
- #[serde(rename = "urls")]
+ /// UUID (lower-case, dash-separated, hex-encoded 128-bit)
+ #[serde(rename = "revision")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub urls: Option<Vec<models::FileUrl>>,
+ pub revision: Option<String>,
- /// SHA-256 hash of data, in hex encoding
- #[serde(rename = "sha256")]
+ /// base32-encoded unique identifier
+ #[serde(rename = "redirect")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub sha256: Option<String>,
+ pub redirect: Option<String>,
- /// SHA-1 hash of data, in hex encoding
- #[serde(rename = "sha1")]
+ /// Free-form JSON metadata that will be stored with the other entity metadata. See guide for (unenforced) schema conventions.
+ #[serde(rename = "extra")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub sha1: Option<String>,
+ pub extra: Option<std::collections::HashMap<String, serde_json::Value>>,
- /// MD5 hash of data, in hex encoding
- #[serde(rename = "md5")]
+ /// Free-form JSON metadata that will be stored with specific entity edits (eg, creation/update/delete).
+ #[serde(rename = "edit_extra")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub md5: Option<String>,
+ pub edit_extra: Option<std::collections::HashMap<String, serde_json::Value>>,
/// Size of file in bytes. Non-zero.
#[serde(rename = "size")]
#[serde(skip_serializing_if = "Option::is_none")]
pub size: Option<i64>,
- /// Free-form JSON metadata that will be stored with specific entity edits (eg, creation/update/delete).
- #[serde(rename = "edit_extra")]
+ /// MD5 hash of data, in hex encoding
+ #[serde(rename = "md5")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub edit_extra: Option<serde_json::Value>,
+ pub md5: Option<String>,
- /// Free-form JSON metadata that will be stored with the other entity metadata. See guide for (unenforced) schema conventions.
- #[serde(rename = "extra")]
+ /// SHA-1 hash of data, in hex encoding
+ #[serde(rename = "sha1")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub extra: Option<serde_json::Value>,
+ pub sha1: Option<String>,
- /// base32-encoded unique identifier
- #[serde(rename = "redirect")]
+ /// SHA-256 hash of data, in hex encoding
+ #[serde(rename = "sha256")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub redirect: Option<String>,
+ pub sha256: Option<String>,
- /// UUID (lower-case, dash-separated, hex-encoded 128-bit)
- #[serde(rename = "revision")]
+ #[serde(rename = "urls")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub revision: Option<String>,
+ pub urls: Option<Vec<models::FileUrl>>,
- /// base32-encoded unique identifier
- #[serde(rename = "ident")]
+ #[serde(rename = "mimetype")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub ident: Option<String>,
+ pub mimetype: Option<String>,
- // Note: inline enums are not fully supported by swagger-codegen
- #[serde(rename = "state")]
+ /// Set of identifier of release entities this file represents a full manifestation of. Usually a single release, but some files contain content of multiple full releases (eg, an issue of a journal).
+ #[serde(rename = "release_ids")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub state: Option<String>,
+ pub release_ids: Option<Vec<String>>,
+
+ /// Full release entities, included in GET responses when `releases` included in `expand` parameter. Ignored if included in PUT or POST requests.
+ #[serde(rename = "releases")]
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub releases: Option<Vec<models::ReleaseEntity>>,
}
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,
+ ident: None,
+ revision: None,
+ redirect: None,
+ extra: None,
+ edit_extra: None,
+ size: None,
+ md5: None,
+ sha1: None,
+ sha256: None,
+ urls: None,
+ mimetype: None,
+ release_ids: None,
+ releases: None,
}
}
}
-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+/// Converts the FileEntity value to the Query Parameters representation (style=form, explode=false)
+/// specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde serializer
+impl std::string::ToString for FileEntity {
+ fn to_string(&self) -> String {
+ let mut params: Vec<String> = vec![];
+
+ if let Some(ref state) = self.state {
+ params.push("state".to_string());
+ params.push(state.to_string());
+ }
+
+ if let Some(ref ident) = self.ident {
+ params.push("ident".to_string());
+ params.push(ident.to_string());
+ }
+
+ if let Some(ref revision) = self.revision {
+ params.push("revision".to_string());
+ params.push(revision.to_string());
+ }
+
+ if let Some(ref redirect) = self.redirect {
+ params.push("redirect".to_string());
+ params.push(redirect.to_string());
+ }
+
+ // Skipping extra in query parameter serialization
+ // Skipping extra in query parameter serialization
+
+ // Skipping edit_extra in query parameter serialization
+ // Skipping edit_extra in query parameter serialization
+
+ if let Some(ref size) = self.size {
+ params.push("size".to_string());
+ params.push(size.to_string());
+ }
+
+ if let Some(ref md5) = self.md5 {
+ params.push("md5".to_string());
+ params.push(md5.to_string());
+ }
+
+ if let Some(ref sha1) = self.sha1 {
+ params.push("sha1".to_string());
+ params.push(sha1.to_string());
+ }
+
+ if let Some(ref sha256) = self.sha256 {
+ params.push("sha256".to_string());
+ params.push(sha256.to_string());
+ }
+
+ // Skipping urls in query parameter serialization
+
+ if let Some(ref mimetype) = self.mimetype {
+ params.push("mimetype".to_string());
+ params.push(mimetype.to_string());
+ }
+
+ if let Some(ref release_ids) = self.release_ids {
+ params.push("release_ids".to_string());
+ params.push(
+ release_ids
+ .iter()
+ .map(|x| x.to_string())
+ .collect::<Vec<_>>()
+ .join(",")
+ .to_string(),
+ );
+ }
+
+ // Skipping releases in query parameter serialization
+
+ params.join(",").to_string()
+ }
+}
+
+/// Converts Query Parameters representation (style=form, explode=false) to a FileEntity value
+/// as specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde deserializer
+impl std::str::FromStr for FileEntity {
+ type Err = String;
+
+ fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
+ #[derive(Default)]
+ // An intermediate representation of the struct to use for parsing.
+ struct IntermediateRep {
+ pub state: Vec<String>,
+ pub ident: Vec<String>,
+ pub revision: Vec<String>,
+ pub redirect: Vec<String>,
+ pub extra: Vec<std::collections::HashMap<String, serde_json::Value>>,
+ pub edit_extra: Vec<std::collections::HashMap<String, serde_json::Value>>,
+ pub size: Vec<i64>,
+ pub md5: Vec<String>,
+ pub sha1: Vec<String>,
+ pub sha256: Vec<String>,
+ pub urls: Vec<Vec<models::FileUrl>>,
+ pub mimetype: Vec<String>,
+ pub release_ids: Vec<Vec<String>>,
+ pub releases: Vec<Vec<models::ReleaseEntity>>,
+ }
+
+ let mut intermediate_rep = IntermediateRep::default();
+
+ // Parse into intermediate representation
+ let mut string_iter = s.split(',').into_iter();
+ let mut key_result = string_iter.next();
+
+ while key_result.is_some() {
+ let val = match string_iter.next() {
+ Some(x) => x,
+ None => {
+ return std::result::Result::Err(
+ "Missing value while parsing FileEntity".to_string(),
+ )
+ }
+ };
+
+ if let Some(key) = key_result {
+ match key {
+ "state" => intermediate_rep
+ .state
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "ident" => intermediate_rep
+ .ident
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "revision" => intermediate_rep
+ .revision
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "redirect" => intermediate_rep
+ .redirect
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "extra" => {
+ return std::result::Result::Err(
+ "Parsing a container in this style is not supported in FileEntity"
+ .to_string(),
+ )
+ }
+ "edit_extra" => {
+ return std::result::Result::Err(
+ "Parsing a container in this style is not supported in FileEntity"
+ .to_string(),
+ )
+ }
+ "size" => intermediate_rep
+ .size
+ .push(i64::from_str(val).map_err(|x| format!("{}", x))?),
+ "md5" => intermediate_rep
+ .md5
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "sha1" => intermediate_rep
+ .sha1
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "sha256" => intermediate_rep
+ .sha256
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "urls" => {
+ return std::result::Result::Err(
+ "Parsing a container in this style is not supported in FileEntity"
+ .to_string(),
+ )
+ }
+ "mimetype" => intermediate_rep
+ .mimetype
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "release_ids" => {
+ return std::result::Result::Err(
+ "Parsing a container in this style is not supported in FileEntity"
+ .to_string(),
+ )
+ }
+ "releases" => {
+ return std::result::Result::Err(
+ "Parsing a container in this style is not supported in FileEntity"
+ .to_string(),
+ )
+ }
+ _ => {
+ return std::result::Result::Err(
+ "Unexpected key while parsing FileEntity".to_string(),
+ )
+ }
+ }
+ }
+
+ // Get the next key
+ key_result = string_iter.next();
+ }
+
+ // Use the intermediate representation to return the struct
+ std::result::Result::Ok(FileEntity {
+ state: intermediate_rep.state.into_iter().next(),
+ ident: intermediate_rep.ident.into_iter().next(),
+ revision: intermediate_rep.revision.into_iter().next(),
+ redirect: intermediate_rep.redirect.into_iter().next(),
+ extra: intermediate_rep.extra.into_iter().next(),
+ edit_extra: intermediate_rep.edit_extra.into_iter().next(),
+ size: intermediate_rep.size.into_iter().next(),
+ md5: intermediate_rep.md5.into_iter().next(),
+ sha1: intermediate_rep.sha1.into_iter().next(),
+ sha256: intermediate_rep.sha256.into_iter().next(),
+ urls: intermediate_rep.urls.into_iter().next(),
+ mimetype: intermediate_rep.mimetype.into_iter().next(),
+ release_ids: intermediate_rep.release_ids.into_iter().next(),
+ releases: intermediate_rep.releases.into_iter().next(),
+ })
+ }
+}
+
+// Methods for converting between header::IntoHeaderValue<FileUrl> and hyper::header::HeaderValue
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<header::IntoHeaderValue<FileUrl>> for hyper::header::HeaderValue {
+ type Error = String;
+
+ fn try_from(
+ hdr_value: header::IntoHeaderValue<FileUrl>,
+ ) -> std::result::Result<Self, Self::Error> {
+ let hdr_value = hdr_value.to_string();
+ match hyper::header::HeaderValue::from_str(&hdr_value) {
+ std::result::Result::Ok(value) => std::result::Result::Ok(value),
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Invalid header value for FileUrl - value: {} is invalid {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<FileUrl> {
+ type Error = String;
+
+ fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
+ match hdr_value.to_str() {
+ std::result::Result::Ok(value) => {
+ match <FileUrl as std::str::FromStr>::from_str(value) {
+ std::result::Result::Ok(value) => {
+ std::result::Result::Ok(header::IntoHeaderValue(value))
+ }
+ std::result::Result::Err(err) => std::result::Result::Err(format!(
+ "Unable to convert header value '{}' into FileUrl - {}",
+ value, err
+ )),
+ }
+ }
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Unable to convert header: {:?} to string: {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
+#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct FileUrl {
/// URL/URI pointing directly to a machine retrievable copy of this exact file.
#[serde(rename = "url")]
@@ -707,7 +3565,140 @@ impl FileUrl {
}
}
-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+/// Converts the FileUrl value to the Query Parameters representation (style=form, explode=false)
+/// specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde serializer
+impl std::string::ToString for FileUrl {
+ fn to_string(&self) -> String {
+ let mut params: Vec<String> = vec![];
+
+ params.push("url".to_string());
+ params.push(self.url.to_string());
+
+ params.push("rel".to_string());
+ params.push(self.rel.to_string());
+
+ params.join(",").to_string()
+ }
+}
+
+/// Converts Query Parameters representation (style=form, explode=false) to a FileUrl value
+/// as specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde deserializer
+impl std::str::FromStr for FileUrl {
+ type Err = String;
+
+ fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
+ #[derive(Default)]
+ // An intermediate representation of the struct to use for parsing.
+ struct IntermediateRep {
+ pub url: Vec<String>,
+ pub rel: Vec<String>,
+ }
+
+ let mut intermediate_rep = IntermediateRep::default();
+
+ // Parse into intermediate representation
+ let mut string_iter = s.split(',').into_iter();
+ let mut key_result = string_iter.next();
+
+ while key_result.is_some() {
+ let val = match string_iter.next() {
+ Some(x) => x,
+ None => {
+ return std::result::Result::Err(
+ "Missing value while parsing FileUrl".to_string(),
+ )
+ }
+ };
+
+ if let Some(key) = key_result {
+ match key {
+ "url" => intermediate_rep
+ .url
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "rel" => intermediate_rep
+ .rel
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ _ => {
+ return std::result::Result::Err(
+ "Unexpected key while parsing FileUrl".to_string(),
+ )
+ }
+ }
+ }
+
+ // Get the next key
+ key_result = string_iter.next();
+ }
+
+ // Use the intermediate representation to return the struct
+ std::result::Result::Ok(FileUrl {
+ url: intermediate_rep
+ .url
+ .into_iter()
+ .next()
+ .ok_or("url missing in FileUrl".to_string())?,
+ rel: intermediate_rep
+ .rel
+ .into_iter()
+ .next()
+ .ok_or("rel missing in FileUrl".to_string())?,
+ })
+ }
+}
+
+// Methods for converting between header::IntoHeaderValue<FilesetAutoBatch> and hyper::header::HeaderValue
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<header::IntoHeaderValue<FilesetAutoBatch>>
+ for hyper::header::HeaderValue
+{
+ type Error = String;
+
+ fn try_from(
+ hdr_value: header::IntoHeaderValue<FilesetAutoBatch>,
+ ) -> std::result::Result<Self, Self::Error> {
+ let hdr_value = hdr_value.to_string();
+ match hyper::header::HeaderValue::from_str(&hdr_value) {
+ std::result::Result::Ok(value) => std::result::Result::Ok(value),
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Invalid header value for FilesetAutoBatch - value: {} is invalid {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<hyper::header::HeaderValue>
+ for header::IntoHeaderValue<FilesetAutoBatch>
+{
+ type Error = String;
+
+ fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
+ match hdr_value.to_str() {
+ std::result::Result::Ok(value) => {
+ match <FilesetAutoBatch as std::str::FromStr>::from_str(value) {
+ std::result::Result::Ok(value) => {
+ std::result::Result::Ok(header::IntoHeaderValue(value))
+ }
+ std::result::Result::Err(err) => std::result::Result::Err(format!(
+ "Unable to convert header value '{}' into FilesetAutoBatch - {}",
+ value, err
+ )),
+ }
+ }
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Unable to convert header: {:?} to string: {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
+#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct FilesetAutoBatch {
#[serde(rename = "editgroup")]
pub editgroup: models::Editgroup,
@@ -717,7 +3708,10 @@ pub struct FilesetAutoBatch {
}
impl FilesetAutoBatch {
- pub fn new(editgroup: models::Editgroup, entity_list: Vec<models::FilesetEntity>) -> FilesetAutoBatch {
+ pub fn new(
+ editgroup: models::Editgroup,
+ entity_list: Vec<models::FilesetEntity>,
+ ) -> FilesetAutoBatch {
FilesetAutoBatch {
editgroup: editgroup,
entity_list: entity_list,
@@ -725,27 +3719,136 @@ impl FilesetAutoBatch {
}
}
-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
-pub struct FilesetEntity {
- /// Full release entities, included in GET responses when `releases` included in `expand` parameter. Ignored if included in PUT or POST requests.
- #[serde(rename = "releases")]
- #[serde(skip_serializing_if = "Option::is_none")]
- pub releases: Option<Vec<models::ReleaseEntity>>,
+/// Converts the FilesetAutoBatch value to the Query Parameters representation (style=form, explode=false)
+/// specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde serializer
+impl std::string::ToString for FilesetAutoBatch {
+ fn to_string(&self) -> String {
+ let mut params: Vec<String> = vec![];
+ // Skipping editgroup in query parameter serialization
- /// Set of identifier of release entities this fileset represents a full manifestation of. Usually a single release.
- #[serde(rename = "release_ids")]
- #[serde(skip_serializing_if = "Option::is_none")]
- pub release_ids: Option<Vec<String>>,
+ // Skipping entity_list in query parameter serialization
- #[serde(rename = "urls")]
- #[serde(skip_serializing_if = "Option::is_none")]
- pub urls: Option<Vec<models::FilesetUrl>>,
+ params.join(",").to_string()
+ }
+}
- #[serde(rename = "manifest")]
- #[serde(skip_serializing_if = "Option::is_none")]
- pub manifest: Option<Vec<models::FilesetFile>>,
+/// Converts Query Parameters representation (style=form, explode=false) to a FilesetAutoBatch value
+/// as specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde deserializer
+impl std::str::FromStr for FilesetAutoBatch {
+ type Err = String;
+
+ fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
+ #[derive(Default)]
+ // An intermediate representation of the struct to use for parsing.
+ struct IntermediateRep {
+ pub editgroup: Vec<models::Editgroup>,
+ pub entity_list: Vec<Vec<models::FilesetEntity>>,
+ }
+
+ let mut intermediate_rep = IntermediateRep::default();
+
+ // Parse into intermediate representation
+ let mut string_iter = s.split(',').into_iter();
+ let mut key_result = string_iter.next();
+
+ while key_result.is_some() {
+ let val = match string_iter.next() {
+ Some(x) => x,
+ None => {
+ return std::result::Result::Err(
+ "Missing value while parsing FilesetAutoBatch".to_string(),
+ )
+ }
+ };
+
+ if let Some(key) = key_result {
+ match key {
+ "editgroup" => intermediate_rep
+ .editgroup
+ .push(models::Editgroup::from_str(val).map_err(|x| format!("{}", x))?),
+ "entity_list" => return std::result::Result::Err(
+ "Parsing a container in this style is not supported in FilesetAutoBatch"
+ .to_string(),
+ ),
+ _ => {
+ return std::result::Result::Err(
+ "Unexpected key while parsing FilesetAutoBatch".to_string(),
+ )
+ }
+ }
+ }
+
+ // Get the next key
+ key_result = string_iter.next();
+ }
+
+ // Use the intermediate representation to return the struct
+ std::result::Result::Ok(FilesetAutoBatch {
+ editgroup: intermediate_rep
+ .editgroup
+ .into_iter()
+ .next()
+ .ok_or("editgroup missing in FilesetAutoBatch".to_string())?,
+ entity_list: intermediate_rep
+ .entity_list
+ .into_iter()
+ .next()
+ .ok_or("entity_list missing in FilesetAutoBatch".to_string())?,
+ })
+ }
+}
- // Note: inline enums are not fully supported by swagger-codegen
+// Methods for converting between header::IntoHeaderValue<FilesetEntity> and hyper::header::HeaderValue
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<header::IntoHeaderValue<FilesetEntity>> for hyper::header::HeaderValue {
+ type Error = String;
+
+ fn try_from(
+ hdr_value: header::IntoHeaderValue<FilesetEntity>,
+ ) -> std::result::Result<Self, Self::Error> {
+ let hdr_value = hdr_value.to_string();
+ match hyper::header::HeaderValue::from_str(&hdr_value) {
+ std::result::Result::Ok(value) => std::result::Result::Ok(value),
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Invalid header value for FilesetEntity - value: {} is invalid {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<FilesetEntity> {
+ type Error = String;
+
+ fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
+ match hdr_value.to_str() {
+ std::result::Result::Ok(value) => {
+ match <FilesetEntity as std::str::FromStr>::from_str(value) {
+ std::result::Result::Ok(value) => {
+ std::result::Result::Ok(header::IntoHeaderValue(value))
+ }
+ std::result::Result::Err(err) => std::result::Result::Err(format!(
+ "Unable to convert header value '{}' into FilesetEntity - {}",
+ value, err
+ )),
+ }
+ }
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Unable to convert header: {:?} to string: {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
+#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
+pub struct FilesetEntity {
+ // Note: inline enums are not fully supported by openapi-generator
#[serde(rename = "state")]
#[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<String>,
@@ -768,32 +3871,267 @@ pub struct FilesetEntity {
/// Free-form JSON metadata that will be stored with the other entity metadata. See guide for (unenforced) schema conventions.
#[serde(rename = "extra")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub extra: Option<serde_json::Value>,
+ pub extra: Option<std::collections::HashMap<String, serde_json::Value>>,
/// Free-form JSON metadata that will be stored with specific entity edits (eg, creation/update/delete).
#[serde(rename = "edit_extra")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub edit_extra: Option<serde_json::Value>,
+ pub edit_extra: Option<std::collections::HashMap<String, serde_json::Value>>,
+
+ #[serde(rename = "manifest")]
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub manifest: Option<Vec<models::FilesetFile>>,
+
+ #[serde(rename = "urls")]
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub urls: Option<Vec<models::FilesetUrl>>,
+
+ /// Set of identifier of release entities this fileset represents a full manifestation of. Usually a single release.
+ #[serde(rename = "release_ids")]
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub release_ids: Option<Vec<String>>,
+
+ /// Full release entities, included in GET responses when `releases` included in `expand` parameter. Ignored if included in PUT or POST requests.
+ #[serde(rename = "releases")]
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub releases: Option<Vec<models::ReleaseEntity>>,
}
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,
+ manifest: None,
+ urls: None,
+ release_ids: None,
+ releases: None,
+ }
+ }
+}
+
+/// Converts the FilesetEntity value to the Query Parameters representation (style=form, explode=false)
+/// specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde serializer
+impl std::string::ToString for FilesetEntity {
+ fn to_string(&self) -> String {
+ let mut params: Vec<String> = vec![];
+
+ if let Some(ref state) = self.state {
+ params.push("state".to_string());
+ params.push(state.to_string());
+ }
+
+ if let Some(ref ident) = self.ident {
+ params.push("ident".to_string());
+ params.push(ident.to_string());
+ }
+
+ if let Some(ref revision) = self.revision {
+ params.push("revision".to_string());
+ params.push(revision.to_string());
+ }
+
+ if let Some(ref redirect) = self.redirect {
+ params.push("redirect".to_string());
+ params.push(redirect.to_string());
}
+
+ // Skipping extra in query parameter serialization
+ // Skipping extra in query parameter serialization
+
+ // Skipping edit_extra in query parameter serialization
+ // Skipping edit_extra in query parameter serialization
+
+ // Skipping manifest in query parameter serialization
+
+ // Skipping urls in query parameter serialization
+
+ if let Some(ref release_ids) = self.release_ids {
+ params.push("release_ids".to_string());
+ params.push(
+ release_ids
+ .iter()
+ .map(|x| x.to_string())
+ .collect::<Vec<_>>()
+ .join(",")
+ .to_string(),
+ );
+ }
+
+ // Skipping releases in query parameter serialization
+
+ params.join(",").to_string()
}
}
-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+/// Converts Query Parameters representation (style=form, explode=false) to a FilesetEntity value
+/// as specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde deserializer
+impl std::str::FromStr for FilesetEntity {
+ type Err = String;
+
+ fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
+ #[derive(Default)]
+ // An intermediate representation of the struct to use for parsing.
+ struct IntermediateRep {
+ pub state: Vec<String>,
+ pub ident: Vec<String>,
+ pub revision: Vec<String>,
+ pub redirect: Vec<String>,
+ pub extra: Vec<std::collections::HashMap<String, serde_json::Value>>,
+ pub edit_extra: Vec<std::collections::HashMap<String, serde_json::Value>>,
+ pub manifest: Vec<Vec<models::FilesetFile>>,
+ pub urls: Vec<Vec<models::FilesetUrl>>,
+ pub release_ids: Vec<Vec<String>>,
+ pub releases: Vec<Vec<models::ReleaseEntity>>,
+ }
+
+ let mut intermediate_rep = IntermediateRep::default();
+
+ // Parse into intermediate representation
+ let mut string_iter = s.split(',').into_iter();
+ let mut key_result = string_iter.next();
+
+ while key_result.is_some() {
+ let val = match string_iter.next() {
+ Some(x) => x,
+ None => {
+ return std::result::Result::Err(
+ "Missing value while parsing FilesetEntity".to_string(),
+ )
+ }
+ };
+
+ if let Some(key) = key_result {
+ match key {
+ "state" => intermediate_rep
+ .state
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "ident" => intermediate_rep
+ .ident
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "revision" => intermediate_rep
+ .revision
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "redirect" => intermediate_rep
+ .redirect
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "extra" => {
+ return std::result::Result::Err(
+ "Parsing a container in this style is not supported in FilesetEntity"
+ .to_string(),
+ )
+ }
+ "edit_extra" => {
+ return std::result::Result::Err(
+ "Parsing a container in this style is not supported in FilesetEntity"
+ .to_string(),
+ )
+ }
+ "manifest" => {
+ return std::result::Result::Err(
+ "Parsing a container in this style is not supported in FilesetEntity"
+ .to_string(),
+ )
+ }
+ "urls" => {
+ return std::result::Result::Err(
+ "Parsing a container in this style is not supported in FilesetEntity"
+ .to_string(),
+ )
+ }
+ "release_ids" => {
+ return std::result::Result::Err(
+ "Parsing a container in this style is not supported in FilesetEntity"
+ .to_string(),
+ )
+ }
+ "releases" => {
+ return std::result::Result::Err(
+ "Parsing a container in this style is not supported in FilesetEntity"
+ .to_string(),
+ )
+ }
+ _ => {
+ return std::result::Result::Err(
+ "Unexpected key while parsing FilesetEntity".to_string(),
+ )
+ }
+ }
+ }
+
+ // Get the next key
+ key_result = string_iter.next();
+ }
+
+ // Use the intermediate representation to return the struct
+ std::result::Result::Ok(FilesetEntity {
+ state: intermediate_rep.state.into_iter().next(),
+ ident: intermediate_rep.ident.into_iter().next(),
+ revision: intermediate_rep.revision.into_iter().next(),
+ redirect: intermediate_rep.redirect.into_iter().next(),
+ extra: intermediate_rep.extra.into_iter().next(),
+ edit_extra: intermediate_rep.edit_extra.into_iter().next(),
+ manifest: intermediate_rep.manifest.into_iter().next(),
+ urls: intermediate_rep.urls.into_iter().next(),
+ release_ids: intermediate_rep.release_ids.into_iter().next(),
+ releases: intermediate_rep.releases.into_iter().next(),
+ })
+ }
+}
+
+// Methods for converting between header::IntoHeaderValue<FilesetFile> and hyper::header::HeaderValue
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<header::IntoHeaderValue<FilesetFile>> for hyper::header::HeaderValue {
+ type Error = String;
+
+ fn try_from(
+ hdr_value: header::IntoHeaderValue<FilesetFile>,
+ ) -> std::result::Result<Self, Self::Error> {
+ let hdr_value = hdr_value.to_string();
+ match hyper::header::HeaderValue::from_str(&hdr_value) {
+ std::result::Result::Ok(value) => std::result::Result::Ok(value),
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Invalid header value for FilesetFile - value: {} is invalid {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<FilesetFile> {
+ type Error = String;
+
+ fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
+ match hdr_value.to_str() {
+ std::result::Result::Ok(value) => {
+ match <FilesetFile as std::str::FromStr>::from_str(value) {
+ std::result::Result::Ok(value) => {
+ std::result::Result::Ok(header::IntoHeaderValue(value))
+ }
+ std::result::Result::Err(err) => std::result::Result::Err(format!(
+ "Unable to convert header value '{}' into FilesetFile - {}",
+ value, err
+ )),
+ }
+ }
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Unable to convert header: {:?} to string: {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
+#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct FilesetFile {
/// Path name of file within this fileset (eg, directory)
#[serde(rename = "path")]
@@ -821,7 +4159,7 @@ pub struct FilesetFile {
/// Free-form additional metadata about this specific file in the set. Eg, `mimetype`. See guide for nomative (but unenforced) schema fields.
#[serde(rename = "extra")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub extra: Option<serde_json::Value>,
+ pub extra: Option<std::collections::HashMap<String, serde_json::Value>>,
}
impl FilesetFile {
@@ -837,7 +4175,177 @@ impl FilesetFile {
}
}
-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+/// Converts the FilesetFile value to the Query Parameters representation (style=form, explode=false)
+/// specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde serializer
+impl std::string::ToString for FilesetFile {
+ fn to_string(&self) -> String {
+ let mut params: Vec<String> = vec![];
+
+ params.push("path".to_string());
+ params.push(self.path.to_string());
+
+ params.push("size".to_string());
+ params.push(self.size.to_string());
+
+ if let Some(ref md5) = self.md5 {
+ params.push("md5".to_string());
+ params.push(md5.to_string());
+ }
+
+ if let Some(ref sha1) = self.sha1 {
+ params.push("sha1".to_string());
+ params.push(sha1.to_string());
+ }
+
+ if let Some(ref sha256) = self.sha256 {
+ params.push("sha256".to_string());
+ params.push(sha256.to_string());
+ }
+
+ // Skipping extra in query parameter serialization
+ // Skipping extra in query parameter serialization
+
+ params.join(",").to_string()
+ }
+}
+
+/// Converts Query Parameters representation (style=form, explode=false) to a FilesetFile value
+/// as specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde deserializer
+impl std::str::FromStr for FilesetFile {
+ type Err = String;
+
+ fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
+ #[derive(Default)]
+ // An intermediate representation of the struct to use for parsing.
+ struct IntermediateRep {
+ pub path: Vec<String>,
+ pub size: Vec<i64>,
+ pub md5: Vec<String>,
+ pub sha1: Vec<String>,
+ pub sha256: Vec<String>,
+ pub extra: Vec<std::collections::HashMap<String, serde_json::Value>>,
+ }
+
+ let mut intermediate_rep = IntermediateRep::default();
+
+ // Parse into intermediate representation
+ let mut string_iter = s.split(',').into_iter();
+ let mut key_result = string_iter.next();
+
+ while key_result.is_some() {
+ let val = match string_iter.next() {
+ Some(x) => x,
+ None => {
+ return std::result::Result::Err(
+ "Missing value while parsing FilesetFile".to_string(),
+ )
+ }
+ };
+
+ if let Some(key) = key_result {
+ match key {
+ "path" => intermediate_rep
+ .path
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "size" => intermediate_rep
+ .size
+ .push(i64::from_str(val).map_err(|x| format!("{}", x))?),
+ "md5" => intermediate_rep
+ .md5
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "sha1" => intermediate_rep
+ .sha1
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "sha256" => intermediate_rep
+ .sha256
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "extra" => {
+ return std::result::Result::Err(
+ "Parsing a container in this style is not supported in FilesetFile"
+ .to_string(),
+ )
+ }
+ _ => {
+ return std::result::Result::Err(
+ "Unexpected key while parsing FilesetFile".to_string(),
+ )
+ }
+ }
+ }
+
+ // Get the next key
+ key_result = string_iter.next();
+ }
+
+ // Use the intermediate representation to return the struct
+ std::result::Result::Ok(FilesetFile {
+ path: intermediate_rep
+ .path
+ .into_iter()
+ .next()
+ .ok_or("path missing in FilesetFile".to_string())?,
+ size: intermediate_rep
+ .size
+ .into_iter()
+ .next()
+ .ok_or("size missing in FilesetFile".to_string())?,
+ md5: intermediate_rep.md5.into_iter().next(),
+ sha1: intermediate_rep.sha1.into_iter().next(),
+ sha256: intermediate_rep.sha256.into_iter().next(),
+ extra: intermediate_rep.extra.into_iter().next(),
+ })
+ }
+}
+
+// Methods for converting between header::IntoHeaderValue<FilesetUrl> and hyper::header::HeaderValue
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<header::IntoHeaderValue<FilesetUrl>> for hyper::header::HeaderValue {
+ type Error = String;
+
+ fn try_from(
+ hdr_value: header::IntoHeaderValue<FilesetUrl>,
+ ) -> std::result::Result<Self, Self::Error> {
+ let hdr_value = hdr_value.to_string();
+ match hyper::header::HeaderValue::from_str(&hdr_value) {
+ std::result::Result::Ok(value) => std::result::Result::Ok(value),
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Invalid header value for FilesetUrl - value: {} is invalid {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<FilesetUrl> {
+ type Error = String;
+
+ fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
+ match hdr_value.to_str() {
+ std::result::Result::Ok(value) => {
+ match <FilesetUrl as std::str::FromStr>::from_str(value) {
+ std::result::Result::Ok(value) => {
+ std::result::Result::Ok(header::IntoHeaderValue(value))
+ }
+ std::result::Result::Err(err) => std::result::Result::Err(format!(
+ "Unable to convert header value '{}' into FilesetUrl - {}",
+ value, err
+ )),
+ }
+ }
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Unable to convert header: {:?} to string: {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
+#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct FilesetUrl {
#[serde(rename = "url")]
pub url: String,
@@ -853,7 +4361,140 @@ impl FilesetUrl {
}
}
-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+/// Converts the FilesetUrl value to the Query Parameters representation (style=form, explode=false)
+/// specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde serializer
+impl std::string::ToString for FilesetUrl {
+ fn to_string(&self) -> String {
+ let mut params: Vec<String> = vec![];
+
+ params.push("url".to_string());
+ params.push(self.url.to_string());
+
+ params.push("rel".to_string());
+ params.push(self.rel.to_string());
+
+ params.join(",").to_string()
+ }
+}
+
+/// Converts Query Parameters representation (style=form, explode=false) to a FilesetUrl value
+/// as specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde deserializer
+impl std::str::FromStr for FilesetUrl {
+ type Err = String;
+
+ fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
+ #[derive(Default)]
+ // An intermediate representation of the struct to use for parsing.
+ struct IntermediateRep {
+ pub url: Vec<String>,
+ pub rel: Vec<String>,
+ }
+
+ let mut intermediate_rep = IntermediateRep::default();
+
+ // Parse into intermediate representation
+ let mut string_iter = s.split(',').into_iter();
+ let mut key_result = string_iter.next();
+
+ while key_result.is_some() {
+ let val = match string_iter.next() {
+ Some(x) => x,
+ None => {
+ return std::result::Result::Err(
+ "Missing value while parsing FilesetUrl".to_string(),
+ )
+ }
+ };
+
+ if let Some(key) = key_result {
+ match key {
+ "url" => intermediate_rep
+ .url
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "rel" => intermediate_rep
+ .rel
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ _ => {
+ return std::result::Result::Err(
+ "Unexpected key while parsing FilesetUrl".to_string(),
+ )
+ }
+ }
+ }
+
+ // Get the next key
+ key_result = string_iter.next();
+ }
+
+ // Use the intermediate representation to return the struct
+ std::result::Result::Ok(FilesetUrl {
+ url: intermediate_rep
+ .url
+ .into_iter()
+ .next()
+ .ok_or("url missing in FilesetUrl".to_string())?,
+ rel: intermediate_rep
+ .rel
+ .into_iter()
+ .next()
+ .ok_or("rel missing in FilesetUrl".to_string())?,
+ })
+ }
+}
+
+// Methods for converting between header::IntoHeaderValue<ReleaseAbstract> and hyper::header::HeaderValue
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<header::IntoHeaderValue<ReleaseAbstract>>
+ for hyper::header::HeaderValue
+{
+ type Error = String;
+
+ fn try_from(
+ hdr_value: header::IntoHeaderValue<ReleaseAbstract>,
+ ) -> std::result::Result<Self, Self::Error> {
+ let hdr_value = hdr_value.to_string();
+ match hyper::header::HeaderValue::from_str(&hdr_value) {
+ std::result::Result::Ok(value) => std::result::Result::Ok(value),
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Invalid header value for ReleaseAbstract - value: {} is invalid {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<hyper::header::HeaderValue>
+ for header::IntoHeaderValue<ReleaseAbstract>
+{
+ type Error = String;
+
+ fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
+ match hdr_value.to_str() {
+ std::result::Result::Ok(value) => {
+ match <ReleaseAbstract as std::str::FromStr>::from_str(value) {
+ std::result::Result::Ok(value) => {
+ std::result::Result::Ok(header::IntoHeaderValue(value))
+ }
+ std::result::Result::Err(err) => std::result::Result::Err(format!(
+ "Unable to convert header value '{}' into ReleaseAbstract - {}",
+ value, err
+ )),
+ }
+ }
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Unable to convert header: {:?} to string: {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
+#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ReleaseAbstract {
/// SHA-1 hash of data, in hex encoding
#[serde(rename = "sha1")]
@@ -887,7 +4528,156 @@ impl ReleaseAbstract {
}
}
-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+/// Converts the ReleaseAbstract value to the Query Parameters representation (style=form, explode=false)
+/// specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde serializer
+impl std::string::ToString for ReleaseAbstract {
+ fn to_string(&self) -> String {
+ let mut params: Vec<String> = vec![];
+
+ if let Some(ref sha1) = self.sha1 {
+ params.push("sha1".to_string());
+ params.push(sha1.to_string());
+ }
+
+ if let Some(ref content) = self.content {
+ params.push("content".to_string());
+ params.push(content.to_string());
+ }
+
+ if let Some(ref mimetype) = self.mimetype {
+ params.push("mimetype".to_string());
+ params.push(mimetype.to_string());
+ }
+
+ if let Some(ref lang) = self.lang {
+ params.push("lang".to_string());
+ params.push(lang.to_string());
+ }
+
+ params.join(",").to_string()
+ }
+}
+
+/// Converts Query Parameters representation (style=form, explode=false) to a ReleaseAbstract value
+/// as specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde deserializer
+impl std::str::FromStr for ReleaseAbstract {
+ type Err = String;
+
+ fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
+ #[derive(Default)]
+ // An intermediate representation of the struct to use for parsing.
+ struct IntermediateRep {
+ pub sha1: Vec<String>,
+ pub content: Vec<String>,
+ pub mimetype: Vec<String>,
+ pub lang: Vec<String>,
+ }
+
+ let mut intermediate_rep = IntermediateRep::default();
+
+ // Parse into intermediate representation
+ let mut string_iter = s.split(',').into_iter();
+ let mut key_result = string_iter.next();
+
+ while key_result.is_some() {
+ let val = match string_iter.next() {
+ Some(x) => x,
+ None => {
+ return std::result::Result::Err(
+ "Missing value while parsing ReleaseAbstract".to_string(),
+ )
+ }
+ };
+
+ if let Some(key) = key_result {
+ match key {
+ "sha1" => intermediate_rep
+ .sha1
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "content" => intermediate_rep
+ .content
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "mimetype" => intermediate_rep
+ .mimetype
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "lang" => intermediate_rep
+ .lang
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ _ => {
+ return std::result::Result::Err(
+ "Unexpected key while parsing ReleaseAbstract".to_string(),
+ )
+ }
+ }
+ }
+
+ // Get the next key
+ key_result = string_iter.next();
+ }
+
+ // Use the intermediate representation to return the struct
+ std::result::Result::Ok(ReleaseAbstract {
+ sha1: intermediate_rep.sha1.into_iter().next(),
+ content: intermediate_rep.content.into_iter().next(),
+ mimetype: intermediate_rep.mimetype.into_iter().next(),
+ lang: intermediate_rep.lang.into_iter().next(),
+ })
+ }
+}
+
+// Methods for converting between header::IntoHeaderValue<ReleaseAutoBatch> and hyper::header::HeaderValue
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<header::IntoHeaderValue<ReleaseAutoBatch>>
+ for hyper::header::HeaderValue
+{
+ type Error = String;
+
+ fn try_from(
+ hdr_value: header::IntoHeaderValue<ReleaseAutoBatch>,
+ ) -> std::result::Result<Self, Self::Error> {
+ let hdr_value = hdr_value.to_string();
+ match hyper::header::HeaderValue::from_str(&hdr_value) {
+ std::result::Result::Ok(value) => std::result::Result::Ok(value),
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Invalid header value for ReleaseAutoBatch - value: {} is invalid {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<hyper::header::HeaderValue>
+ for header::IntoHeaderValue<ReleaseAutoBatch>
+{
+ type Error = String;
+
+ fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
+ match hdr_value.to_str() {
+ std::result::Result::Ok(value) => {
+ match <ReleaseAutoBatch as std::str::FromStr>::from_str(value) {
+ std::result::Result::Ok(value) => {
+ std::result::Result::Ok(header::IntoHeaderValue(value))
+ }
+ std::result::Result::Err(err) => std::result::Result::Err(format!(
+ "Unable to convert header value '{}' into ReleaseAutoBatch - {}",
+ value, err
+ )),
+ }
+ }
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Unable to convert header: {:?} to string: {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
+#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ReleaseAutoBatch {
#[serde(rename = "editgroup")]
pub editgroup: models::Editgroup,
@@ -897,7 +4687,10 @@ pub struct ReleaseAutoBatch {
}
impl ReleaseAutoBatch {
- pub fn new(editgroup: models::Editgroup, entity_list: Vec<models::ReleaseEntity>) -> ReleaseAutoBatch {
+ pub fn new(
+ editgroup: models::Editgroup,
+ entity_list: Vec<models::ReleaseEntity>,
+ ) -> ReleaseAutoBatch {
ReleaseAutoBatch {
editgroup: editgroup,
entity_list: entity_list,
@@ -905,7 +4698,134 @@ impl ReleaseAutoBatch {
}
}
-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+/// Converts the ReleaseAutoBatch value to the Query Parameters representation (style=form, explode=false)
+/// specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde serializer
+impl std::string::ToString for ReleaseAutoBatch {
+ fn to_string(&self) -> String {
+ let mut params: Vec<String> = vec![];
+ // Skipping editgroup in query parameter serialization
+
+ // Skipping entity_list in query parameter serialization
+
+ params.join(",").to_string()
+ }
+}
+
+/// Converts Query Parameters representation (style=form, explode=false) to a ReleaseAutoBatch value
+/// as specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde deserializer
+impl std::str::FromStr for ReleaseAutoBatch {
+ type Err = String;
+
+ fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
+ #[derive(Default)]
+ // An intermediate representation of the struct to use for parsing.
+ struct IntermediateRep {
+ pub editgroup: Vec<models::Editgroup>,
+ pub entity_list: Vec<Vec<models::ReleaseEntity>>,
+ }
+
+ let mut intermediate_rep = IntermediateRep::default();
+
+ // Parse into intermediate representation
+ let mut string_iter = s.split(',').into_iter();
+ let mut key_result = string_iter.next();
+
+ while key_result.is_some() {
+ let val = match string_iter.next() {
+ Some(x) => x,
+ None => {
+ return std::result::Result::Err(
+ "Missing value while parsing ReleaseAutoBatch".to_string(),
+ )
+ }
+ };
+
+ if let Some(key) = key_result {
+ match key {
+ "editgroup" => intermediate_rep
+ .editgroup
+ .push(models::Editgroup::from_str(val).map_err(|x| format!("{}", x))?),
+ "entity_list" => return std::result::Result::Err(
+ "Parsing a container in this style is not supported in ReleaseAutoBatch"
+ .to_string(),
+ ),
+ _ => {
+ return std::result::Result::Err(
+ "Unexpected key while parsing ReleaseAutoBatch".to_string(),
+ )
+ }
+ }
+ }
+
+ // Get the next key
+ key_result = string_iter.next();
+ }
+
+ // Use the intermediate representation to return the struct
+ std::result::Result::Ok(ReleaseAutoBatch {
+ editgroup: intermediate_rep
+ .editgroup
+ .into_iter()
+ .next()
+ .ok_or("editgroup missing in ReleaseAutoBatch".to_string())?,
+ entity_list: intermediate_rep
+ .entity_list
+ .into_iter()
+ .next()
+ .ok_or("entity_list missing in ReleaseAutoBatch".to_string())?,
+ })
+ }
+}
+
+// Methods for converting between header::IntoHeaderValue<ReleaseContrib> and hyper::header::HeaderValue
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<header::IntoHeaderValue<ReleaseContrib>> for hyper::header::HeaderValue {
+ type Error = String;
+
+ fn try_from(
+ hdr_value: header::IntoHeaderValue<ReleaseContrib>,
+ ) -> std::result::Result<Self, Self::Error> {
+ let hdr_value = hdr_value.to_string();
+ match hyper::header::HeaderValue::from_str(&hdr_value) {
+ std::result::Result::Ok(value) => std::result::Result::Ok(value),
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Invalid header value for ReleaseContrib - value: {} is invalid {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<ReleaseContrib> {
+ type Error = String;
+
+ fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
+ match hdr_value.to_str() {
+ std::result::Result::Ok(value) => {
+ match <ReleaseContrib as std::str::FromStr>::from_str(value) {
+ std::result::Result::Ok(value) => {
+ std::result::Result::Ok(header::IntoHeaderValue(value))
+ }
+ std::result::Result::Err(err) => std::result::Result::Err(format!(
+ "Unable to convert header value '{}' into ReleaseContrib - {}",
+ value, err
+ )),
+ }
+ }
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Unable to convert header: {:?} to string: {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
+#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ReleaseContrib {
/// Internally assigned zero-indexed sequence number of contribution. Authors should come first; this encodes the order of attriubtion.
#[serde(rename = "index")]
@@ -917,7 +4837,6 @@ pub struct ReleaseContrib {
#[serde(skip_serializing_if = "Option::is_none")]
pub creator_id: Option<String>,
- /// Complete creator entity. Only returned in GET responses, and only if `contribs` included in the `expand` query parameter.
#[serde(rename = "creator")]
#[serde(skip_serializing_if = "Option::is_none")]
pub creator: Option<models::CreatorEntity>,
@@ -950,7 +4869,7 @@ pub struct ReleaseContrib {
/// Additional free-form JSON metadata about this contributor/contribution. See guide for normative schema.
#[serde(rename = "extra")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub extra: Option<serde_json::Value>,
+ pub extra: Option<std::collections::HashMap<String, serde_json::Value>>,
}
impl ReleaseContrib {
@@ -969,219 +4888,851 @@ impl ReleaseContrib {
}
}
-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+/// Converts the ReleaseContrib value to the Query Parameters representation (style=form, explode=false)
+/// specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde serializer
+impl std::string::ToString for ReleaseContrib {
+ fn to_string(&self) -> String {
+ let mut params: Vec<String> = vec![];
+
+ if let Some(ref index) = self.index {
+ params.push("index".to_string());
+ params.push(index.to_string());
+ }
+
+ if let Some(ref creator_id) = self.creator_id {
+ params.push("creator_id".to_string());
+ params.push(creator_id.to_string());
+ }
+
+ // Skipping creator in query parameter serialization
+
+ if let Some(ref raw_name) = self.raw_name {
+ params.push("raw_name".to_string());
+ params.push(raw_name.to_string());
+ }
+
+ if let Some(ref given_name) = self.given_name {
+ params.push("given_name".to_string());
+ params.push(given_name.to_string());
+ }
+
+ if let Some(ref surname) = self.surname {
+ params.push("surname".to_string());
+ params.push(surname.to_string());
+ }
+
+ if let Some(ref role) = self.role {
+ params.push("role".to_string());
+ params.push(role.to_string());
+ }
+
+ if let Some(ref raw_affiliation) = self.raw_affiliation {
+ params.push("raw_affiliation".to_string());
+ params.push(raw_affiliation.to_string());
+ }
+
+ // Skipping extra in query parameter serialization
+ // Skipping extra in query parameter serialization
+
+ params.join(",").to_string()
+ }
+}
+
+/// Converts Query Parameters representation (style=form, explode=false) to a ReleaseContrib value
+/// as specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde deserializer
+impl std::str::FromStr for ReleaseContrib {
+ type Err = String;
+
+ fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
+ #[derive(Default)]
+ // An intermediate representation of the struct to use for parsing.
+ struct IntermediateRep {
+ pub index: Vec<i64>,
+ pub creator_id: Vec<String>,
+ pub creator: Vec<models::CreatorEntity>,
+ pub raw_name: Vec<String>,
+ pub given_name: Vec<String>,
+ pub surname: Vec<String>,
+ pub role: Vec<String>,
+ pub raw_affiliation: Vec<String>,
+ pub extra: Vec<std::collections::HashMap<String, serde_json::Value>>,
+ }
+
+ let mut intermediate_rep = IntermediateRep::default();
+
+ // Parse into intermediate representation
+ let mut string_iter = s.split(',').into_iter();
+ let mut key_result = string_iter.next();
+
+ while key_result.is_some() {
+ let val = match string_iter.next() {
+ Some(x) => x,
+ None => {
+ return std::result::Result::Err(
+ "Missing value while parsing ReleaseContrib".to_string(),
+ )
+ }
+ };
+
+ if let Some(key) = key_result {
+ match key {
+ "index" => intermediate_rep
+ .index
+ .push(i64::from_str(val).map_err(|x| format!("{}", x))?),
+ "creator_id" => intermediate_rep
+ .creator_id
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "creator" => intermediate_rep
+ .creator
+ .push(models::CreatorEntity::from_str(val).map_err(|x| format!("{}", x))?),
+ "raw_name" => intermediate_rep
+ .raw_name
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "given_name" => intermediate_rep
+ .given_name
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "surname" => intermediate_rep
+ .surname
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "role" => intermediate_rep
+ .role
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "raw_affiliation" => intermediate_rep
+ .raw_affiliation
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "extra" => {
+ return std::result::Result::Err(
+ "Parsing a container in this style is not supported in ReleaseContrib"
+ .to_string(),
+ )
+ }
+ _ => {
+ return std::result::Result::Err(
+ "Unexpected key while parsing ReleaseContrib".to_string(),
+ )
+ }
+ }
+ }
+
+ // Get the next key
+ key_result = string_iter.next();
+ }
+
+ // Use the intermediate representation to return the struct
+ std::result::Result::Ok(ReleaseContrib {
+ index: intermediate_rep.index.into_iter().next(),
+ creator_id: intermediate_rep.creator_id.into_iter().next(),
+ creator: intermediate_rep.creator.into_iter().next(),
+ raw_name: intermediate_rep.raw_name.into_iter().next(),
+ given_name: intermediate_rep.given_name.into_iter().next(),
+ surname: intermediate_rep.surname.into_iter().next(),
+ role: intermediate_rep.role.into_iter().next(),
+ raw_affiliation: intermediate_rep.raw_affiliation.into_iter().next(),
+ extra: intermediate_rep.extra.into_iter().next(),
+ })
+ }
+}
+
+// Methods for converting between header::IntoHeaderValue<ReleaseEntity> and hyper::header::HeaderValue
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<header::IntoHeaderValue<ReleaseEntity>> for hyper::header::HeaderValue {
+ type Error = String;
+
+ fn try_from(
+ hdr_value: header::IntoHeaderValue<ReleaseEntity>,
+ ) -> std::result::Result<Self, Self::Error> {
+ let hdr_value = hdr_value.to_string();
+ match hyper::header::HeaderValue::from_str(&hdr_value) {
+ std::result::Result::Ok(value) => std::result::Result::Ok(value),
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Invalid header value for ReleaseEntity - value: {} is invalid {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<ReleaseEntity> {
+ type Error = String;
+
+ fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
+ match hdr_value.to_str() {
+ std::result::Result::Ok(value) => {
+ match <ReleaseEntity as std::str::FromStr>::from_str(value) {
+ std::result::Result::Ok(value) => {
+ std::result::Result::Ok(header::IntoHeaderValue(value))
+ }
+ std::result::Result::Err(err) => std::result::Result::Err(format!(
+ "Unable to convert header value '{}' into ReleaseEntity - {}",
+ value, err
+ )),
+ }
+ }
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Unable to convert header: {:?} to string: {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
+#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ReleaseEntity {
- #[serde(rename = "abstracts")]
+ // Note: inline enums are not fully supported by openapi-generator
+ #[serde(rename = "state")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub abstracts: Option<Vec<models::ReleaseAbstract>>,
+ pub state: Option<String>,
- #[serde(rename = "refs")]
+ /// base32-encoded unique identifier
+ #[serde(rename = "ident")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub refs: Option<Vec<models::ReleaseRef>>,
+ pub ident: Option<String>,
- #[serde(rename = "contribs")]
+ /// UUID (lower-case, dash-separated, hex-encoded 128-bit)
+ #[serde(rename = "revision")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub contribs: Option<Vec<models::ReleaseContrib>>,
+ pub revision: Option<String>,
- /// Short string (slug) name of license under which release is openly published (if applicable).
- #[serde(rename = "license_slug")]
+ /// base32-encoded unique identifier
+ #[serde(rename = "redirect")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub license_slug: Option<String>,
+ pub redirect: Option<String>,
- /// Primary language of the content of the full release. Two-letter RFC1766/ISO639-1 language code, with some custom extensions/additions. See guide.
- #[serde(rename = "language")]
+ /// Free-form JSON metadata that will be stored with the other entity metadata. See guide for (unenforced) schema conventions.
+ #[serde(rename = "extra")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub language: Option<String>,
+ pub extra: Option<std::collections::HashMap<String, serde_json::Value>>,
- /// Name, usually English, of the entity or institution responsible for publication of this release. Not necessarily the imprint/brand. See guide.
- #[serde(rename = "publisher")]
+ /// Free-form JSON metadata that will be stored with specific entity edits (eg, creation/update/delete).
+ #[serde(rename = "edit_extra")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub publisher: Option<String>,
+ pub edit_extra: Option<std::collections::HashMap<String, serde_json::Value>>,
- /// For, eg, updated technical reports or software packages, where the version string may be the only field disambiguating between releases.
- #[serde(rename = "version")]
+ /// Required for valid entities. The title used in citations and for display. Sometimes the English translation of title e even if release content is not English.
+ #[serde(rename = "title")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub version: Option<String>,
+ pub title: Option<String>,
- /// For, eg, technical reports, which are published in series or assigned some other institutional or container-specific identifier.
- #[serde(rename = "number")]
+ /// Subtitle of release. In many cases, better to merge with title than include as separate field (unless combined title would be very long). See guide for details.
+ #[serde(rename = "subtitle")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub number: Option<String>,
+ pub subtitle: Option<String>,
- /// Either a single page number (\"first page\") or a range of pages separated by a dash (\"-\"). See guide for details.
- #[serde(rename = "pages")]
+ /// Title in original language if `title` field has been translated. See guide for details.
+ #[serde(rename = "original_title")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub pages: Option<String>,
+ pub original_title: Option<String>,
- /// Issue number of volume/container that this release was published in. Sometimes coresponds to a month number in the year, but can be any string. See guide.
- #[serde(rename = "issue")]
+ /// Identifier of work this release is part of. In creation (POST) requests, a work entity will be created automatically if this field is not set.
+ #[serde(rename = "work_id")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub issue: Option<String>,
+ pub work_id: Option<String>,
- /// Volume number of container that this release was published in. Often corresponds to the \"Nth\" year of publication, but can be any string. See guide.
- #[serde(rename = "volume")]
+ #[serde(rename = "container")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub volume: Option<String>,
-
- /// Set of external identifiers for this release.
- #[serde(rename = "ext_ids")]
- pub ext_ids: models::ReleaseExtIds,
+ pub container: Option<models::ContainerEntity>,
- /// Year corresponding with `withdrawn_date` like `release_year`/`release_date`.
- #[serde(rename = "withdrawn_year")]
+ /// Complete file entities identified by `file_ids` field. Only included in GET responses when `files` included in `expand` parameter; ignored in PUT or POST requests.
+ #[serde(rename = "files")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub withdrawn_year: Option<i64>,
+ pub files: Option<Vec<models::FileEntity>>,
- /// Full date when this release was formally withdrawn (if applicable). ISO format, like `release_date`.
- #[serde(rename = "withdrawn_date")]
+ /// Complete file entities identified by `filesets_ids` field. Only included in GET responses when `filesets` included in `expand` parameter; ignored in PUT or POST requests.
+ #[serde(rename = "filesets")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub withdrawn_date: Option<chrono::NaiveDate>,
+ pub filesets: Option<Vec<models::FilesetEntity>>,
- /// Type of withdrawl or retraction of this release, if applicable. If release has not been withdrawn, should be `null` (aka, not set, not the string \"null\" or an empty string).
- #[serde(rename = "withdrawn_status")]
+ /// Complete webcapture entities identified by `webcapture_ids` field. Only included in GET responses when `webcaptures` included in `expand` parameter; ignored in PUT or POST requests.
+ #[serde(rename = "webcaptures")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub withdrawn_status: Option<String>,
+ pub webcaptures: Option<Vec<models::WebcaptureEntity>>,
- /// Year when this release was formally published. Must match `release_date` if that field is set; this field exists because sometimes only the year is known.
- #[serde(rename = "release_year")]
+ /// Used to link this release to a container entity that the release was published as part of.
+ #[serde(rename = "container_id")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub release_year: Option<i64>,
+ pub container_id: Option<String>,
- /// Full date when this release was formally published. ISO format, like `2019-03-05`. See guide for semantics.
- #[serde(rename = "release_date")]
+ /// \"Type\" or \"medium\" that this release is published as. See guide for valid values.
+ #[serde(rename = "release_type")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub release_date: Option<chrono::NaiveDate>,
+ pub release_type: Option<String>,
/// The stage of publication of this specific release. See guide for valid values and semantics.
#[serde(rename = "release_stage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub release_stage: Option<String>,
- /// \"Type\" or \"medium\" that this release is published as. See guide for valid values.
- #[serde(rename = "release_type")]
+ /// Full date when this release was formally published. ISO format, like `2019-03-05`. See guide for semantics.
+ #[serde(rename = "release_date")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub release_type: Option<String>,
+ pub release_date: Option<chrono::DateTime<chrono::Utc>>,
- /// Used to link this release to a container entity that the release was published as part of.
- #[serde(rename = "container_id")]
+ /// Year when this release was formally published. Must match `release_date` if that field is set; this field exists because sometimes only the year is known.
+ #[serde(rename = "release_year")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub container_id: Option<String>,
+ pub release_year: Option<i64>,
- /// Complete webcapture entities identified by `webcapture_ids` field. Only included in GET responses when `webcaptures` included in `expand` parameter; ignored in PUT or POST requests.
- #[serde(rename = "webcaptures")]
+ /// Type of withdrawl or retraction of this release, if applicable. If release has not been withdrawn, should be `null` (aka, not set, not the string \"null\" or an empty string).
+ #[serde(rename = "withdrawn_status")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub webcaptures: Option<Vec<models::WebcaptureEntity>>,
+ pub withdrawn_status: Option<String>,
- /// Complete file entities identified by `filesets_ids` field. Only included in GET responses when `filesets` included in `expand` parameter; ignored in PUT or POST requests.
- #[serde(rename = "filesets")]
+ /// Full date when this release was formally withdrawn (if applicable). ISO format, like `release_date`.
+ #[serde(rename = "withdrawn_date")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub filesets: Option<Vec<models::FilesetEntity>>,
+ pub withdrawn_date: Option<chrono::DateTime<chrono::Utc>>,
- /// Complete file entities identified by `file_ids` field. Only included in GET responses when `files` included in `expand` parameter; ignored in PUT or POST requests.
- #[serde(rename = "files")]
+ /// Year corresponding with `withdrawn_date` like `release_year`/`release_date`.
+ #[serde(rename = "withdrawn_year")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub files: Option<Vec<models::FileEntity>>,
+ pub withdrawn_year: Option<i64>,
- /// Complete container entity identified by `container_id` field. Only included in GET reponses when `container` included in `expand` parameter; ignored in PUT or POST requests.
- #[serde(rename = "container")]
+ #[serde(rename = "ext_ids")]
+ pub ext_ids: models::ReleaseExtIds,
+
+ /// Volume number of container that this release was published in. Often corresponds to the \"Nth\" year of publication, but can be any string. See guide.
+ #[serde(rename = "volume")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub container: Option<models::ContainerEntity>,
+ pub volume: Option<String>,
- /// Identifier of work this release is part of. In creation (POST) requests, a work entity will be created automatically if this field is not set.
- #[serde(rename = "work_id")]
+ /// Issue number of volume/container that this release was published in. Sometimes coresponds to a month number in the year, but can be any string. See guide.
+ #[serde(rename = "issue")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub work_id: Option<String>,
+ pub issue: Option<String>,
- /// Title in original language if `title` field has been translated. See guide for details.
- #[serde(rename = "original_title")]
+ /// Either a single page number (\"first page\") or a range of pages separated by a dash (\"-\"). See guide for details.
+ #[serde(rename = "pages")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub original_title: Option<String>,
+ pub pages: Option<String>,
- /// Subtitle of release. In many cases, better to merge with title than include as separate field (unless combined title would be very long). See guide for details.
- #[serde(rename = "subtitle")]
+ /// For, eg, technical reports, which are published in series or assigned some other institutional or container-specific identifier.
+ #[serde(rename = "number")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub subtitle: Option<String>,
+ pub number: Option<String>,
- /// Required for valid entities. The title used in citations and for display. Sometimes the English translation of title e even if release content is not English.
- #[serde(rename = "title")]
+ /// For, eg, updated technical reports or software packages, where the version string may be the only field disambiguating between releases.
+ #[serde(rename = "version")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub title: Option<String>,
+ pub version: Option<String>,
- // Note: inline enums are not fully supported by swagger-codegen
- #[serde(rename = "state")]
+ /// Name, usually English, of the entity or institution responsible for publication of this release. Not necessarily the imprint/brand. See guide.
+ #[serde(rename = "publisher")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub state: Option<String>,
+ pub publisher: Option<String>,
- /// base32-encoded unique identifier
- #[serde(rename = "ident")]
+ /// Primary language of the content of the full release. Two-letter RFC1766/ISO639-1 language code, with some custom extensions/additions. See guide.
+ #[serde(rename = "language")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub ident: Option<String>,
+ pub language: Option<String>,
- /// UUID (lower-case, dash-separated, hex-encoded 128-bit)
- #[serde(rename = "revision")]
+ /// Short string (slug) name of license under which release is openly published (if applicable).
+ #[serde(rename = "license_slug")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub revision: Option<String>,
+ pub license_slug: Option<String>,
- /// base32-encoded unique identifier
- #[serde(rename = "redirect")]
+ #[serde(rename = "contribs")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub redirect: Option<String>,
+ pub contribs: Option<Vec<models::ReleaseContrib>>,
- /// Free-form JSON metadata that will be stored with the other entity metadata. See guide for (unenforced) schema conventions.
- #[serde(rename = "extra")]
+ #[serde(rename = "refs")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub extra: Option<serde_json::Value>,
+ pub refs: Option<Vec<models::ReleaseRef>>,
- /// Free-form JSON metadata that will be stored with specific entity edits (eg, creation/update/delete).
- #[serde(rename = "edit_extra")]
+ #[serde(rename = "abstracts")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub edit_extra: Option<serde_json::Value>,
+ pub abstracts: Option<Vec<models::ReleaseAbstract>>,
}
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,
+ title: None,
+ subtitle: None,
+ original_title: None,
+ work_id: None,
+ container: None,
+ files: None,
+ filesets: None,
+ webcaptures: None,
+ container_id: None,
+ release_type: None,
+ release_stage: None,
+ release_date: None,
+ release_year: None,
+ withdrawn_status: None,
+ withdrawn_date: None,
+ withdrawn_year: None,
+ ext_ids: ext_ids,
+ volume: None,
+ issue: None,
+ pages: None,
+ number: None,
+ version: None,
+ publisher: None,
+ language: None,
+ license_slug: None,
+ contribs: None,
+ refs: None,
+ abstracts: None,
+ }
+ }
+}
+
+/// Converts the ReleaseEntity value to the Query Parameters representation (style=form, explode=false)
+/// specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde serializer
+impl std::string::ToString for ReleaseEntity {
+ fn to_string(&self) -> String {
+ let mut params: Vec<String> = vec![];
+
+ if let Some(ref state) = self.state {
+ params.push("state".to_string());
+ params.push(state.to_string());
+ }
+
+ if let Some(ref ident) = self.ident {
+ params.push("ident".to_string());
+ params.push(ident.to_string());
+ }
+
+ if let Some(ref revision) = self.revision {
+ params.push("revision".to_string());
+ params.push(revision.to_string());
+ }
+
+ if let Some(ref redirect) = self.redirect {
+ params.push("redirect".to_string());
+ params.push(redirect.to_string());
+ }
+
+ // Skipping extra in query parameter serialization
+ // Skipping extra in query parameter serialization
+
+ // Skipping edit_extra in query parameter serialization
+ // Skipping edit_extra in query parameter serialization
+
+ if let Some(ref title) = self.title {
+ params.push("title".to_string());
+ params.push(title.to_string());
+ }
+
+ if let Some(ref subtitle) = self.subtitle {
+ params.push("subtitle".to_string());
+ params.push(subtitle.to_string());
+ }
+
+ if let Some(ref original_title) = self.original_title {
+ params.push("original_title".to_string());
+ params.push(original_title.to_string());
+ }
+
+ if let Some(ref work_id) = self.work_id {
+ params.push("work_id".to_string());
+ params.push(work_id.to_string());
+ }
+
+ // Skipping container in query parameter serialization
+
+ // Skipping files in query parameter serialization
+
+ // Skipping filesets in query parameter serialization
+
+ // Skipping webcaptures in query parameter serialization
+
+ if let Some(ref container_id) = self.container_id {
+ params.push("container_id".to_string());
+ params.push(container_id.to_string());
+ }
+
+ if let Some(ref release_type) = self.release_type {
+ params.push("release_type".to_string());
+ params.push(release_type.to_string());
+ }
+
+ if let Some(ref release_stage) = self.release_stage {
+ params.push("release_stage".to_string());
+ params.push(release_stage.to_string());
+ }
+
+ // Skipping release_date in query parameter serialization
+
+ if let Some(ref release_year) = self.release_year {
+ params.push("release_year".to_string());
+ params.push(release_year.to_string());
+ }
+
+ if let Some(ref withdrawn_status) = self.withdrawn_status {
+ params.push("withdrawn_status".to_string());
+ params.push(withdrawn_status.to_string());
+ }
+
+ // Skipping withdrawn_date in query parameter serialization
+
+ if let Some(ref withdrawn_year) = self.withdrawn_year {
+ params.push("withdrawn_year".to_string());
+ params.push(withdrawn_year.to_string());
+ }
+
+ // Skipping ext_ids in query parameter serialization
+
+ if let Some(ref volume) = self.volume {
+ params.push("volume".to_string());
+ params.push(volume.to_string());
+ }
+
+ if let Some(ref issue) = self.issue {
+ params.push("issue".to_string());
+ params.push(issue.to_string());
+ }
+
+ if let Some(ref pages) = self.pages {
+ params.push("pages".to_string());
+ params.push(pages.to_string());
+ }
+
+ if let Some(ref number) = self.number {
+ params.push("number".to_string());
+ params.push(number.to_string());
+ }
+
+ if let Some(ref version) = self.version {
+ params.push("version".to_string());
+ params.push(version.to_string());
}
+
+ if let Some(ref publisher) = self.publisher {
+ params.push("publisher".to_string());
+ params.push(publisher.to_string());
+ }
+
+ if let Some(ref language) = self.language {
+ params.push("language".to_string());
+ params.push(language.to_string());
+ }
+
+ if let Some(ref license_slug) = self.license_slug {
+ params.push("license_slug".to_string());
+ params.push(license_slug.to_string());
+ }
+
+ // Skipping contribs in query parameter serialization
+
+ // Skipping refs in query parameter serialization
+
+ // Skipping abstracts in query parameter serialization
+
+ params.join(",").to_string()
}
}
-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+/// Converts Query Parameters representation (style=form, explode=false) to a ReleaseEntity value
+/// as specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde deserializer
+impl std::str::FromStr for ReleaseEntity {
+ type Err = String;
+
+ fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
+ #[derive(Default)]
+ // An intermediate representation of the struct to use for parsing.
+ struct IntermediateRep {
+ pub state: Vec<String>,
+ pub ident: Vec<String>,
+ pub revision: Vec<String>,
+ pub redirect: Vec<String>,
+ pub extra: Vec<std::collections::HashMap<String, serde_json::Value>>,
+ pub edit_extra: Vec<std::collections::HashMap<String, serde_json::Value>>,
+ pub title: Vec<String>,
+ pub subtitle: Vec<String>,
+ pub original_title: Vec<String>,
+ pub work_id: Vec<String>,
+ pub container: Vec<models::ContainerEntity>,
+ pub files: Vec<Vec<models::FileEntity>>,
+ pub filesets: Vec<Vec<models::FilesetEntity>>,
+ pub webcaptures: Vec<Vec<models::WebcaptureEntity>>,
+ pub container_id: Vec<String>,
+ pub release_type: Vec<String>,
+ pub release_stage: Vec<String>,
+ pub release_date: Vec<chrono::DateTime<chrono::Utc>>,
+ pub release_year: Vec<i64>,
+ pub withdrawn_status: Vec<String>,
+ pub withdrawn_date: Vec<chrono::DateTime<chrono::Utc>>,
+ pub withdrawn_year: Vec<i64>,
+ pub ext_ids: Vec<models::ReleaseExtIds>,
+ pub volume: Vec<String>,
+ pub issue: Vec<String>,
+ pub pages: Vec<String>,
+ pub number: Vec<String>,
+ pub version: Vec<String>,
+ pub publisher: Vec<String>,
+ pub language: Vec<String>,
+ pub license_slug: Vec<String>,
+ pub contribs: Vec<Vec<models::ReleaseContrib>>,
+ pub refs: Vec<Vec<models::ReleaseRef>>,
+ pub abstracts: Vec<Vec<models::ReleaseAbstract>>,
+ }
+
+ let mut intermediate_rep = IntermediateRep::default();
+
+ // Parse into intermediate representation
+ let mut string_iter = s.split(',').into_iter();
+ let mut key_result = string_iter.next();
+
+ while key_result.is_some() {
+ let val = match string_iter.next() {
+ Some(x) => x,
+ None => {
+ return std::result::Result::Err(
+ "Missing value while parsing ReleaseEntity".to_string(),
+ )
+ }
+ };
+
+ if let Some(key) = key_result {
+ match key {
+ "state" => intermediate_rep
+ .state
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "ident" => intermediate_rep
+ .ident
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "revision" => intermediate_rep
+ .revision
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "redirect" => intermediate_rep
+ .redirect
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "extra" => {
+ return std::result::Result::Err(
+ "Parsing a container in this style is not supported in ReleaseEntity"
+ .to_string(),
+ )
+ }
+ "edit_extra" => {
+ return std::result::Result::Err(
+ "Parsing a container in this style is not supported in ReleaseEntity"
+ .to_string(),
+ )
+ }
+ "title" => intermediate_rep
+ .title
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "subtitle" => intermediate_rep
+ .subtitle
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "original_title" => intermediate_rep
+ .original_title
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "work_id" => intermediate_rep
+ .work_id
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "container" => intermediate_rep.container.push(
+ models::ContainerEntity::from_str(val).map_err(|x| format!("{}", x))?,
+ ),
+ "files" => {
+ return std::result::Result::Err(
+ "Parsing a container in this style is not supported in ReleaseEntity"
+ .to_string(),
+ )
+ }
+ "filesets" => {
+ return std::result::Result::Err(
+ "Parsing a container in this style is not supported in ReleaseEntity"
+ .to_string(),
+ )
+ }
+ "webcaptures" => {
+ return std::result::Result::Err(
+ "Parsing a container in this style is not supported in ReleaseEntity"
+ .to_string(),
+ )
+ }
+ "container_id" => intermediate_rep
+ .container_id
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "release_type" => intermediate_rep
+ .release_type
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "release_stage" => intermediate_rep
+ .release_stage
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "release_date" => intermediate_rep.release_date.push(
+ chrono::DateTime::<chrono::Utc>::from_str(val)
+ .map_err(|x| format!("{}", x))?,
+ ),
+ "release_year" => intermediate_rep
+ .release_year
+ .push(i64::from_str(val).map_err(|x| format!("{}", x))?),
+ "withdrawn_status" => intermediate_rep
+ .withdrawn_status
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "withdrawn_date" => intermediate_rep.withdrawn_date.push(
+ chrono::DateTime::<chrono::Utc>::from_str(val)
+ .map_err(|x| format!("{}", x))?,
+ ),
+ "withdrawn_year" => intermediate_rep
+ .withdrawn_year
+ .push(i64::from_str(val).map_err(|x| format!("{}", x))?),
+ "ext_ids" => intermediate_rep
+ .ext_ids
+ .push(models::ReleaseExtIds::from_str(val).map_err(|x| format!("{}", x))?),
+ "volume" => intermediate_rep
+ .volume
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "issue" => intermediate_rep
+ .issue
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "pages" => intermediate_rep
+ .pages
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "number" => intermediate_rep
+ .number
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "version" => intermediate_rep
+ .version
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "publisher" => intermediate_rep
+ .publisher
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "language" => intermediate_rep
+ .language
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "license_slug" => intermediate_rep
+ .license_slug
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "contribs" => {
+ return std::result::Result::Err(
+ "Parsing a container in this style is not supported in ReleaseEntity"
+ .to_string(),
+ )
+ }
+ "refs" => {
+ return std::result::Result::Err(
+ "Parsing a container in this style is not supported in ReleaseEntity"
+ .to_string(),
+ )
+ }
+ "abstracts" => {
+ return std::result::Result::Err(
+ "Parsing a container in this style is not supported in ReleaseEntity"
+ .to_string(),
+ )
+ }
+ _ => {
+ return std::result::Result::Err(
+ "Unexpected key while parsing ReleaseEntity".to_string(),
+ )
+ }
+ }
+ }
+
+ // Get the next key
+ key_result = string_iter.next();
+ }
+
+ // Use the intermediate representation to return the struct
+ std::result::Result::Ok(ReleaseEntity {
+ state: intermediate_rep.state.into_iter().next(),
+ ident: intermediate_rep.ident.into_iter().next(),
+ revision: intermediate_rep.revision.into_iter().next(),
+ redirect: intermediate_rep.redirect.into_iter().next(),
+ extra: intermediate_rep.extra.into_iter().next(),
+ edit_extra: intermediate_rep.edit_extra.into_iter().next(),
+ title: intermediate_rep.title.into_iter().next(),
+ subtitle: intermediate_rep.subtitle.into_iter().next(),
+ original_title: intermediate_rep.original_title.into_iter().next(),
+ work_id: intermediate_rep.work_id.into_iter().next(),
+ container: intermediate_rep.container.into_iter().next(),
+ files: intermediate_rep.files.into_iter().next(),
+ filesets: intermediate_rep.filesets.into_iter().next(),
+ webcaptures: intermediate_rep.webcaptures.into_iter().next(),
+ container_id: intermediate_rep.container_id.into_iter().next(),
+ release_type: intermediate_rep.release_type.into_iter().next(),
+ release_stage: intermediate_rep.release_stage.into_iter().next(),
+ release_date: intermediate_rep.release_date.into_iter().next(),
+ release_year: intermediate_rep.release_year.into_iter().next(),
+ withdrawn_status: intermediate_rep.withdrawn_status.into_iter().next(),
+ withdrawn_date: intermediate_rep.withdrawn_date.into_iter().next(),
+ withdrawn_year: intermediate_rep.withdrawn_year.into_iter().next(),
+ ext_ids: intermediate_rep
+ .ext_ids
+ .into_iter()
+ .next()
+ .ok_or("ext_ids missing in ReleaseEntity".to_string())?,
+ volume: intermediate_rep.volume.into_iter().next(),
+ issue: intermediate_rep.issue.into_iter().next(),
+ pages: intermediate_rep.pages.into_iter().next(),
+ number: intermediate_rep.number.into_iter().next(),
+ version: intermediate_rep.version.into_iter().next(),
+ publisher: intermediate_rep.publisher.into_iter().next(),
+ language: intermediate_rep.language.into_iter().next(),
+ license_slug: intermediate_rep.license_slug.into_iter().next(),
+ contribs: intermediate_rep.contribs.into_iter().next(),
+ refs: intermediate_rep.refs.into_iter().next(),
+ abstracts: intermediate_rep.abstracts.into_iter().next(),
+ })
+ }
+}
+
+// Methods for converting between header::IntoHeaderValue<ReleaseExtIds> and hyper::header::HeaderValue
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<header::IntoHeaderValue<ReleaseExtIds>> for hyper::header::HeaderValue {
+ type Error = String;
+
+ fn try_from(
+ hdr_value: header::IntoHeaderValue<ReleaseExtIds>,
+ ) -> std::result::Result<Self, Self::Error> {
+ let hdr_value = hdr_value.to_string();
+ match hyper::header::HeaderValue::from_str(&hdr_value) {
+ std::result::Result::Ok(value) => std::result::Result::Ok(value),
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Invalid header value for ReleaseExtIds - value: {} is invalid {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<ReleaseExtIds> {
+ type Error = String;
+
+ fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
+ match hdr_value.to_str() {
+ std::result::Result::Ok(value) => {
+ match <ReleaseExtIds as std::str::FromStr>::from_str(value) {
+ std::result::Result::Ok(value) => {
+ std::result::Result::Ok(header::IntoHeaderValue(value))
+ }
+ std::result::Result::Err(err) => std::result::Result::Err(format!(
+ "Unable to convert header value '{}' into ReleaseExtIds - {}",
+ value, err
+ )),
+ }
+ }
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Unable to convert header: {:?} to string: {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
+#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ReleaseExtIds {
- /// Digital serde_json::Value Identifier (DOI), mostly for published papers and datasets. Should be registered and resolvable via https://doi.org/
+ /// Digital Object Identifier (DOI), mostly for published papers and datasets. Should be registered and resolvable via https://doi.org/
#[serde(rename = "doi")]
#[serde(skip_serializing_if = "Option::is_none")]
pub doi: Option<String>,
@@ -1249,7 +5800,212 @@ impl ReleaseExtIds {
}
}
-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+/// Converts the ReleaseExtIds value to the Query Parameters representation (style=form, explode=false)
+/// specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde serializer
+impl std::string::ToString for ReleaseExtIds {
+ fn to_string(&self) -> String {
+ let mut params: Vec<String> = vec![];
+
+ if let Some(ref doi) = self.doi {
+ params.push("doi".to_string());
+ params.push(doi.to_string());
+ }
+
+ if let Some(ref wikidata_qid) = self.wikidata_qid {
+ params.push("wikidata_qid".to_string());
+ params.push(wikidata_qid.to_string());
+ }
+
+ if let Some(ref isbn13) = self.isbn13 {
+ params.push("isbn13".to_string());
+ params.push(isbn13.to_string());
+ }
+
+ if let Some(ref pmid) = self.pmid {
+ params.push("pmid".to_string());
+ params.push(pmid.to_string());
+ }
+
+ if let Some(ref pmcid) = self.pmcid {
+ params.push("pmcid".to_string());
+ params.push(pmcid.to_string());
+ }
+
+ if let Some(ref core) = self.core {
+ params.push("core".to_string());
+ params.push(core.to_string());
+ }
+
+ if let Some(ref arxiv) = self.arxiv {
+ params.push("arxiv".to_string());
+ params.push(arxiv.to_string());
+ }
+
+ if let Some(ref jstor) = self.jstor {
+ params.push("jstor".to_string());
+ params.push(jstor.to_string());
+ }
+
+ if let Some(ref ark) = self.ark {
+ params.push("ark".to_string());
+ params.push(ark.to_string());
+ }
+
+ if let Some(ref mag) = self.mag {
+ params.push("mag".to_string());
+ params.push(mag.to_string());
+ }
+
+ params.join(",").to_string()
+ }
+}
+
+/// Converts Query Parameters representation (style=form, explode=false) to a ReleaseExtIds value
+/// as specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde deserializer
+impl std::str::FromStr for ReleaseExtIds {
+ type Err = String;
+
+ fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
+ #[derive(Default)]
+ // An intermediate representation of the struct to use for parsing.
+ struct IntermediateRep {
+ pub doi: Vec<String>,
+ pub wikidata_qid: Vec<String>,
+ pub isbn13: Vec<String>,
+ pub pmid: Vec<String>,
+ pub pmcid: Vec<String>,
+ pub core: Vec<String>,
+ pub arxiv: Vec<String>,
+ pub jstor: Vec<String>,
+ pub ark: Vec<String>,
+ pub mag: Vec<String>,
+ }
+
+ let mut intermediate_rep = IntermediateRep::default();
+
+ // Parse into intermediate representation
+ let mut string_iter = s.split(',').into_iter();
+ let mut key_result = string_iter.next();
+
+ while key_result.is_some() {
+ let val = match string_iter.next() {
+ Some(x) => x,
+ None => {
+ return std::result::Result::Err(
+ "Missing value while parsing ReleaseExtIds".to_string(),
+ )
+ }
+ };
+
+ if let Some(key) = key_result {
+ match key {
+ "doi" => intermediate_rep
+ .doi
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "wikidata_qid" => intermediate_rep
+ .wikidata_qid
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "isbn13" => intermediate_rep
+ .isbn13
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "pmid" => intermediate_rep
+ .pmid
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "pmcid" => intermediate_rep
+ .pmcid
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "core" => intermediate_rep
+ .core
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "arxiv" => intermediate_rep
+ .arxiv
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "jstor" => intermediate_rep
+ .jstor
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "ark" => intermediate_rep
+ .ark
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "mag" => intermediate_rep
+ .mag
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ _ => {
+ return std::result::Result::Err(
+ "Unexpected key while parsing ReleaseExtIds".to_string(),
+ )
+ }
+ }
+ }
+
+ // Get the next key
+ key_result = string_iter.next();
+ }
+
+ // Use the intermediate representation to return the struct
+ std::result::Result::Ok(ReleaseExtIds {
+ doi: intermediate_rep.doi.into_iter().next(),
+ wikidata_qid: intermediate_rep.wikidata_qid.into_iter().next(),
+ isbn13: intermediate_rep.isbn13.into_iter().next(),
+ pmid: intermediate_rep.pmid.into_iter().next(),
+ pmcid: intermediate_rep.pmcid.into_iter().next(),
+ core: intermediate_rep.core.into_iter().next(),
+ arxiv: intermediate_rep.arxiv.into_iter().next(),
+ jstor: intermediate_rep.jstor.into_iter().next(),
+ ark: intermediate_rep.ark.into_iter().next(),
+ mag: intermediate_rep.mag.into_iter().next(),
+ })
+ }
+}
+
+// Methods for converting between header::IntoHeaderValue<ReleaseRef> and hyper::header::HeaderValue
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<header::IntoHeaderValue<ReleaseRef>> for hyper::header::HeaderValue {
+ type Error = String;
+
+ fn try_from(
+ hdr_value: header::IntoHeaderValue<ReleaseRef>,
+ ) -> std::result::Result<Self, Self::Error> {
+ let hdr_value = hdr_value.to_string();
+ match hyper::header::HeaderValue::from_str(&hdr_value) {
+ std::result::Result::Ok(value) => std::result::Result::Ok(value),
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Invalid header value for ReleaseRef - value: {} is invalid {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<ReleaseRef> {
+ type Error = String;
+
+ fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
+ match hdr_value.to_str() {
+ std::result::Result::Ok(value) => {
+ match <ReleaseRef as std::str::FromStr>::from_str(value) {
+ std::result::Result::Ok(value) => {
+ std::result::Result::Ok(header::IntoHeaderValue(value))
+ }
+ std::result::Result::Err(err) => std::result::Result::Err(format!(
+ "Unable to convert header value '{}' into ReleaseRef - {}",
+ value, err
+ )),
+ }
+ }
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Unable to convert header: {:?} to string: {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
+#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ReleaseRef {
/// Zero-indexed sequence number of this reference in the list of references. Assigned automatically and used internally; don't confuse with `key`.
#[serde(rename = "index")]
@@ -1264,7 +6020,7 @@ pub struct ReleaseRef {
/// Additional free-form JSON metadata about this citation. Generally follows Citation Style Language (CSL) JSON schema. See guide for details.
#[serde(rename = "extra")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub extra: Option<serde_json::Value>,
+ pub extra: Option<std::collections::HashMap<String, serde_json::Value>>,
/// Short string used to indicate this reference from within the release text; or numbering of references as typeset in the release itself. Optional; don't confuse with `index` field.
#[serde(rename = "key")]
@@ -1307,7 +6063,193 @@ impl ReleaseRef {
}
}
-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+/// Converts the ReleaseRef value to the Query Parameters representation (style=form, explode=false)
+/// specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde serializer
+impl std::string::ToString for ReleaseRef {
+ fn to_string(&self) -> String {
+ let mut params: Vec<String> = vec![];
+
+ if let Some(ref index) = self.index {
+ params.push("index".to_string());
+ params.push(index.to_string());
+ }
+
+ if let Some(ref target_release_id) = self.target_release_id {
+ params.push("target_release_id".to_string());
+ params.push(target_release_id.to_string());
+ }
+
+ // Skipping extra in query parameter serialization
+ // Skipping extra in query parameter serialization
+
+ if let Some(ref key) = self.key {
+ params.push("key".to_string());
+ params.push(key.to_string());
+ }
+
+ if let Some(ref year) = self.year {
+ params.push("year".to_string());
+ params.push(year.to_string());
+ }
+
+ if let Some(ref container_name) = self.container_name {
+ params.push("container_name".to_string());
+ params.push(container_name.to_string());
+ }
+
+ if let Some(ref title) = self.title {
+ params.push("title".to_string());
+ params.push(title.to_string());
+ }
+
+ if let Some(ref locator) = self.locator {
+ params.push("locator".to_string());
+ params.push(locator.to_string());
+ }
+
+ params.join(",").to_string()
+ }
+}
+
+/// Converts Query Parameters representation (style=form, explode=false) to a ReleaseRef value
+/// as specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde deserializer
+impl std::str::FromStr for ReleaseRef {
+ type Err = String;
+
+ fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
+ #[derive(Default)]
+ // An intermediate representation of the struct to use for parsing.
+ struct IntermediateRep {
+ pub index: Vec<i64>,
+ pub target_release_id: Vec<String>,
+ pub extra: Vec<std::collections::HashMap<String, serde_json::Value>>,
+ pub key: Vec<String>,
+ pub year: Vec<i64>,
+ pub container_name: Vec<String>,
+ pub title: Vec<String>,
+ pub locator: Vec<String>,
+ }
+
+ let mut intermediate_rep = IntermediateRep::default();
+
+ // Parse into intermediate representation
+ let mut string_iter = s.split(',').into_iter();
+ let mut key_result = string_iter.next();
+
+ while key_result.is_some() {
+ let val = match string_iter.next() {
+ Some(x) => x,
+ None => {
+ return std::result::Result::Err(
+ "Missing value while parsing ReleaseRef".to_string(),
+ )
+ }
+ };
+
+ if let Some(key) = key_result {
+ match key {
+ "index" => intermediate_rep
+ .index
+ .push(i64::from_str(val).map_err(|x| format!("{}", x))?),
+ "target_release_id" => intermediate_rep
+ .target_release_id
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "extra" => {
+ return std::result::Result::Err(
+ "Parsing a container in this style is not supported in ReleaseRef"
+ .to_string(),
+ )
+ }
+ "key" => intermediate_rep
+ .key
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "year" => intermediate_rep
+ .year
+ .push(i64::from_str(val).map_err(|x| format!("{}", x))?),
+ "container_name" => intermediate_rep
+ .container_name
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "title" => intermediate_rep
+ .title
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "locator" => intermediate_rep
+ .locator
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ _ => {
+ return std::result::Result::Err(
+ "Unexpected key while parsing ReleaseRef".to_string(),
+ )
+ }
+ }
+ }
+
+ // Get the next key
+ key_result = string_iter.next();
+ }
+
+ // Use the intermediate representation to return the struct
+ std::result::Result::Ok(ReleaseRef {
+ index: intermediate_rep.index.into_iter().next(),
+ target_release_id: intermediate_rep.target_release_id.into_iter().next(),
+ extra: intermediate_rep.extra.into_iter().next(),
+ key: intermediate_rep.key.into_iter().next(),
+ year: intermediate_rep.year.into_iter().next(),
+ container_name: intermediate_rep.container_name.into_iter().next(),
+ title: intermediate_rep.title.into_iter().next(),
+ locator: intermediate_rep.locator.into_iter().next(),
+ })
+ }
+}
+
+// Methods for converting between header::IntoHeaderValue<Success> and hyper::header::HeaderValue
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<header::IntoHeaderValue<Success>> for hyper::header::HeaderValue {
+ type Error = String;
+
+ fn try_from(
+ hdr_value: header::IntoHeaderValue<Success>,
+ ) -> std::result::Result<Self, Self::Error> {
+ let hdr_value = hdr_value.to_string();
+ match hyper::header::HeaderValue::from_str(&hdr_value) {
+ std::result::Result::Ok(value) => std::result::Result::Ok(value),
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Invalid header value for Success - value: {} is invalid {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<Success> {
+ type Error = String;
+
+ fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
+ match hdr_value.to_str() {
+ std::result::Result::Ok(value) => {
+ match <Success as std::str::FromStr>::from_str(value) {
+ std::result::Result::Ok(value) => {
+ std::result::Result::Ok(header::IntoHeaderValue(value))
+ }
+ std::result::Result::Err(err) => std::result::Result::Err(format!(
+ "Unable to convert header value '{}' into Success - {}",
+ value, err
+ )),
+ }
+ }
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Unable to convert header: {:?} to string: {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
+#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct Success {
#[serde(rename = "success")]
pub success: bool,
@@ -1318,11 +6260,147 @@ pub struct Success {
impl Success {
pub fn new(success: bool, message: String) -> Success {
- Success { success: success, message: message }
+ Success {
+ success: success,
+ message: message,
+ }
+ }
+}
+
+/// Converts the Success value to the Query Parameters representation (style=form, explode=false)
+/// specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde serializer
+impl std::string::ToString for Success {
+ fn to_string(&self) -> String {
+ let mut params: Vec<String> = vec![];
+
+ params.push("success".to_string());
+ params.push(self.success.to_string());
+
+ params.push("message".to_string());
+ params.push(self.message.to_string());
+
+ params.join(",").to_string()
+ }
+}
+
+/// Converts Query Parameters representation (style=form, explode=false) to a Success value
+/// as specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde deserializer
+impl std::str::FromStr for Success {
+ type Err = String;
+
+ fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
+ #[derive(Default)]
+ // An intermediate representation of the struct to use for parsing.
+ struct IntermediateRep {
+ pub success: Vec<bool>,
+ pub message: Vec<String>,
+ }
+
+ let mut intermediate_rep = IntermediateRep::default();
+
+ // Parse into intermediate representation
+ let mut string_iter = s.split(',').into_iter();
+ let mut key_result = string_iter.next();
+
+ while key_result.is_some() {
+ let val = match string_iter.next() {
+ Some(x) => x,
+ None => {
+ return std::result::Result::Err(
+ "Missing value while parsing Success".to_string(),
+ )
+ }
+ };
+
+ if let Some(key) = key_result {
+ match key {
+ "success" => intermediate_rep
+ .success
+ .push(bool::from_str(val).map_err(|x| format!("{}", x))?),
+ "message" => intermediate_rep
+ .message
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ _ => {
+ return std::result::Result::Err(
+ "Unexpected key while parsing Success".to_string(),
+ )
+ }
+ }
+ }
+
+ // Get the next key
+ key_result = string_iter.next();
+ }
+
+ // Use the intermediate representation to return the struct
+ std::result::Result::Ok(Success {
+ success: intermediate_rep
+ .success
+ .into_iter()
+ .next()
+ .ok_or("success missing in Success".to_string())?,
+ message: intermediate_rep
+ .message
+ .into_iter()
+ .next()
+ .ok_or("message missing in Success".to_string())?,
+ })
}
}
-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+// Methods for converting between header::IntoHeaderValue<WebcaptureAutoBatch> and hyper::header::HeaderValue
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<header::IntoHeaderValue<WebcaptureAutoBatch>>
+ for hyper::header::HeaderValue
+{
+ type Error = String;
+
+ fn try_from(
+ hdr_value: header::IntoHeaderValue<WebcaptureAutoBatch>,
+ ) -> std::result::Result<Self, Self::Error> {
+ let hdr_value = hdr_value.to_string();
+ match hyper::header::HeaderValue::from_str(&hdr_value) {
+ std::result::Result::Ok(value) => std::result::Result::Ok(value),
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Invalid header value for WebcaptureAutoBatch - value: {} is invalid {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<hyper::header::HeaderValue>
+ for header::IntoHeaderValue<WebcaptureAutoBatch>
+{
+ type Error = String;
+
+ fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
+ match hdr_value.to_str() {
+ std::result::Result::Ok(value) => {
+ match <WebcaptureAutoBatch as std::str::FromStr>::from_str(value) {
+ std::result::Result::Ok(value) => {
+ std::result::Result::Ok(header::IntoHeaderValue(value))
+ }
+ std::result::Result::Err(err) => std::result::Result::Err(format!(
+ "Unable to convert header value '{}' into WebcaptureAutoBatch - {}",
+ value, err
+ )),
+ }
+ }
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Unable to convert header: {:?} to string: {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
+#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct WebcaptureAutoBatch {
#[serde(rename = "editgroup")]
pub editgroup: models::Editgroup,
@@ -1332,7 +6410,10 @@ pub struct WebcaptureAutoBatch {
}
impl WebcaptureAutoBatch {
- pub fn new(editgroup: models::Editgroup, entity_list: Vec<models::WebcaptureEntity>) -> WebcaptureAutoBatch {
+ pub fn new(
+ editgroup: models::Editgroup,
+ entity_list: Vec<models::WebcaptureEntity>,
+ ) -> WebcaptureAutoBatch {
WebcaptureAutoBatch {
editgroup: editgroup,
entity_list: entity_list,
@@ -1340,7 +6421,138 @@ impl WebcaptureAutoBatch {
}
}
-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+/// Converts the WebcaptureAutoBatch value to the Query Parameters representation (style=form, explode=false)
+/// specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde serializer
+impl std::string::ToString for WebcaptureAutoBatch {
+ fn to_string(&self) -> String {
+ let mut params: Vec<String> = vec![];
+ // Skipping editgroup in query parameter serialization
+
+ // Skipping entity_list in query parameter serialization
+
+ params.join(",").to_string()
+ }
+}
+
+/// Converts Query Parameters representation (style=form, explode=false) to a WebcaptureAutoBatch value
+/// as specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde deserializer
+impl std::str::FromStr for WebcaptureAutoBatch {
+ type Err = String;
+
+ fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
+ #[derive(Default)]
+ // An intermediate representation of the struct to use for parsing.
+ struct IntermediateRep {
+ pub editgroup: Vec<models::Editgroup>,
+ pub entity_list: Vec<Vec<models::WebcaptureEntity>>,
+ }
+
+ let mut intermediate_rep = IntermediateRep::default();
+
+ // Parse into intermediate representation
+ let mut string_iter = s.split(',').into_iter();
+ let mut key_result = string_iter.next();
+
+ while key_result.is_some() {
+ let val = match string_iter.next() {
+ Some(x) => x,
+ None => {
+ return std::result::Result::Err(
+ "Missing value while parsing WebcaptureAutoBatch".to_string(),
+ )
+ }
+ };
+
+ if let Some(key) = key_result {
+ match key {
+ "editgroup" => intermediate_rep
+ .editgroup
+ .push(models::Editgroup::from_str(val).map_err(|x| format!("{}", x))?),
+ "entity_list" => return std::result::Result::Err(
+ "Parsing a container in this style is not supported in WebcaptureAutoBatch"
+ .to_string(),
+ ),
+ _ => {
+ return std::result::Result::Err(
+ "Unexpected key while parsing WebcaptureAutoBatch".to_string(),
+ )
+ }
+ }
+ }
+
+ // Get the next key
+ key_result = string_iter.next();
+ }
+
+ // Use the intermediate representation to return the struct
+ std::result::Result::Ok(WebcaptureAutoBatch {
+ editgroup: intermediate_rep
+ .editgroup
+ .into_iter()
+ .next()
+ .ok_or("editgroup missing in WebcaptureAutoBatch".to_string())?,
+ entity_list: intermediate_rep
+ .entity_list
+ .into_iter()
+ .next()
+ .ok_or("entity_list missing in WebcaptureAutoBatch".to_string())?,
+ })
+ }
+}
+
+// Methods for converting between header::IntoHeaderValue<WebcaptureCdxLine> and hyper::header::HeaderValue
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<header::IntoHeaderValue<WebcaptureCdxLine>>
+ for hyper::header::HeaderValue
+{
+ type Error = String;
+
+ fn try_from(
+ hdr_value: header::IntoHeaderValue<WebcaptureCdxLine>,
+ ) -> std::result::Result<Self, Self::Error> {
+ let hdr_value = hdr_value.to_string();
+ match hyper::header::HeaderValue::from_str(&hdr_value) {
+ std::result::Result::Ok(value) => std::result::Result::Ok(value),
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Invalid header value for WebcaptureCdxLine - value: {} is invalid {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<hyper::header::HeaderValue>
+ for header::IntoHeaderValue<WebcaptureCdxLine>
+{
+ type Error = String;
+
+ fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
+ match hdr_value.to_str() {
+ std::result::Result::Ok(value) => {
+ match <WebcaptureCdxLine as std::str::FromStr>::from_str(value) {
+ std::result::Result::Ok(value) => {
+ std::result::Result::Ok(header::IntoHeaderValue(value))
+ }
+ std::result::Result::Err(err) => std::result::Result::Err(format!(
+ "Unable to convert header value '{}' into WebcaptureCdxLine - {}",
+ value, err
+ )),
+ }
+ }
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Unable to convert header: {:?} to string: {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
+#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct WebcaptureCdxLine {
/// \"Sortable URL\" format. See guide for details.
#[serde(rename = "surt")]
@@ -1380,7 +6592,12 @@ pub struct WebcaptureCdxLine {
}
impl WebcaptureCdxLine {
- pub fn new(surt: String, timestamp: chrono::DateTime<chrono::Utc>, url: String, sha1: String) -> WebcaptureCdxLine {
+ pub fn new(
+ surt: String,
+ timestamp: chrono::DateTime<chrono::Utc>,
+ url: String,
+ sha1: String,
+ ) -> WebcaptureCdxLine {
WebcaptureCdxLine {
surt: surt,
timestamp: timestamp,
@@ -1394,87 +6611,507 @@ impl WebcaptureCdxLine {
}
}
-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
-pub struct WebcaptureEntity {
- /// Full release entities, included in GET responses when `releases` included in `expand` parameter. Ignored if included in PUT or POST requests.
- #[serde(rename = "releases")]
- #[serde(skip_serializing_if = "Option::is_none")]
- pub releases: Option<Vec<models::ReleaseEntity>>,
+/// Converts the WebcaptureCdxLine value to the Query Parameters representation (style=form, explode=false)
+/// specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde serializer
+impl std::string::ToString for WebcaptureCdxLine {
+ fn to_string(&self) -> String {
+ let mut params: Vec<String> = vec![];
- /// Set of identifier of release entities this fileset represents a full manifestation of. Usually a single release.
- #[serde(rename = "release_ids")]
+ params.push("surt".to_string());
+ params.push(self.surt.to_string());
+
+ // Skipping timestamp in query parameter serialization
+
+ params.push("url".to_string());
+ params.push(self.url.to_string());
+
+ if let Some(ref mimetype) = self.mimetype {
+ params.push("mimetype".to_string());
+ params.push(mimetype.to_string());
+ }
+
+ if let Some(ref status_code) = self.status_code {
+ params.push("status_code".to_string());
+ params.push(status_code.to_string());
+ }
+
+ if let Some(ref size) = self.size {
+ params.push("size".to_string());
+ params.push(size.to_string());
+ }
+
+ params.push("sha1".to_string());
+ params.push(self.sha1.to_string());
+
+ if let Some(ref sha256) = self.sha256 {
+ params.push("sha256".to_string());
+ params.push(sha256.to_string());
+ }
+
+ params.join(",").to_string()
+ }
+}
+
+/// Converts Query Parameters representation (style=form, explode=false) to a WebcaptureCdxLine value
+/// as specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde deserializer
+impl std::str::FromStr for WebcaptureCdxLine {
+ type Err = String;
+
+ fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
+ #[derive(Default)]
+ // An intermediate representation of the struct to use for parsing.
+ struct IntermediateRep {
+ pub surt: Vec<String>,
+ pub timestamp: Vec<chrono::DateTime<chrono::Utc>>,
+ pub url: Vec<String>,
+ pub mimetype: Vec<String>,
+ pub status_code: Vec<i64>,
+ pub size: Vec<i64>,
+ pub sha1: Vec<String>,
+ pub sha256: Vec<String>,
+ }
+
+ let mut intermediate_rep = IntermediateRep::default();
+
+ // Parse into intermediate representation
+ let mut string_iter = s.split(',').into_iter();
+ let mut key_result = string_iter.next();
+
+ while key_result.is_some() {
+ let val = match string_iter.next() {
+ Some(x) => x,
+ None => {
+ return std::result::Result::Err(
+ "Missing value while parsing WebcaptureCdxLine".to_string(),
+ )
+ }
+ };
+
+ if let Some(key) = key_result {
+ match key {
+ "surt" => intermediate_rep
+ .surt
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "timestamp" => intermediate_rep.timestamp.push(
+ chrono::DateTime::<chrono::Utc>::from_str(val)
+ .map_err(|x| format!("{}", x))?,
+ ),
+ "url" => intermediate_rep
+ .url
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "mimetype" => intermediate_rep
+ .mimetype
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "status_code" => intermediate_rep
+ .status_code
+ .push(i64::from_str(val).map_err(|x| format!("{}", x))?),
+ "size" => intermediate_rep
+ .size
+ .push(i64::from_str(val).map_err(|x| format!("{}", x))?),
+ "sha1" => intermediate_rep
+ .sha1
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "sha256" => intermediate_rep
+ .sha256
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ _ => {
+ return std::result::Result::Err(
+ "Unexpected key while parsing WebcaptureCdxLine".to_string(),
+ )
+ }
+ }
+ }
+
+ // Get the next key
+ key_result = string_iter.next();
+ }
+
+ // Use the intermediate representation to return the struct
+ std::result::Result::Ok(WebcaptureCdxLine {
+ surt: intermediate_rep
+ .surt
+ .into_iter()
+ .next()
+ .ok_or("surt missing in WebcaptureCdxLine".to_string())?,
+ timestamp: intermediate_rep
+ .timestamp
+ .into_iter()
+ .next()
+ .ok_or("timestamp missing in WebcaptureCdxLine".to_string())?,
+ url: intermediate_rep
+ .url
+ .into_iter()
+ .next()
+ .ok_or("url missing in WebcaptureCdxLine".to_string())?,
+ mimetype: intermediate_rep.mimetype.into_iter().next(),
+ status_code: intermediate_rep.status_code.into_iter().next(),
+ size: intermediate_rep.size.into_iter().next(),
+ sha1: intermediate_rep
+ .sha1
+ .into_iter()
+ .next()
+ .ok_or("sha1 missing in WebcaptureCdxLine".to_string())?,
+ sha256: intermediate_rep.sha256.into_iter().next(),
+ })
+ }
+}
+
+// Methods for converting between header::IntoHeaderValue<WebcaptureEntity> and hyper::header::HeaderValue
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<header::IntoHeaderValue<WebcaptureEntity>>
+ for hyper::header::HeaderValue
+{
+ type Error = String;
+
+ fn try_from(
+ hdr_value: header::IntoHeaderValue<WebcaptureEntity>,
+ ) -> std::result::Result<Self, Self::Error> {
+ let hdr_value = hdr_value.to_string();
+ match hyper::header::HeaderValue::from_str(&hdr_value) {
+ std::result::Result::Ok(value) => std::result::Result::Ok(value),
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Invalid header value for WebcaptureEntity - value: {} is invalid {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<hyper::header::HeaderValue>
+ for header::IntoHeaderValue<WebcaptureEntity>
+{
+ type Error = String;
+
+ fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
+ match hdr_value.to_str() {
+ std::result::Result::Ok(value) => {
+ match <WebcaptureEntity as std::str::FromStr>::from_str(value) {
+ std::result::Result::Ok(value) => {
+ std::result::Result::Ok(header::IntoHeaderValue(value))
+ }
+ std::result::Result::Err(err) => std::result::Result::Err(format!(
+ "Unable to convert header value '{}' into WebcaptureEntity - {}",
+ value, err
+ )),
+ }
+ }
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Unable to convert header: {:?} to string: {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
+#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
+pub struct WebcaptureEntity {
+ // Note: inline enums are not fully supported by openapi-generator
+ #[serde(rename = "state")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub release_ids: Option<Vec<String>>,
+ pub state: Option<String>,
- /// Same format as CDX line timestamp (UTC, etc). Corresponds to the overall capture timestamp. Should generally be the timestamp of capture of the primary resource URL.
- #[serde(rename = "timestamp")]
+ /// base32-encoded unique identifier
+ #[serde(rename = "ident")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub timestamp: Option<chrono::DateTime<chrono::Utc>>,
+ pub ident: Option<String>,
- /// Base URL of the primary resource this is a capture of
- #[serde(rename = "original_url")]
+ /// UUID (lower-case, dash-separated, hex-encoded 128-bit)
+ #[serde(rename = "revision")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub original_url: Option<String>,
+ pub revision: Option<String>,
- #[serde(rename = "archive_urls")]
+ /// base32-encoded unique identifier
+ #[serde(rename = "redirect")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub archive_urls: Option<Vec<models::WebcaptureUrl>>,
+ pub redirect: Option<String>,
- #[serde(rename = "cdx")]
+ /// Free-form JSON metadata that will be stored with the other entity metadata. See guide for (unenforced) schema conventions.
+ #[serde(rename = "extra")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub cdx: Option<Vec<models::WebcaptureCdxLine>>,
+ pub extra: Option<std::collections::HashMap<String, serde_json::Value>>,
/// Free-form JSON metadata that will be stored with specific entity edits (eg, creation/update/delete).
#[serde(rename = "edit_extra")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub edit_extra: Option<serde_json::Value>,
+ pub edit_extra: Option<std::collections::HashMap<String, serde_json::Value>>,
- /// Free-form JSON metadata that will be stored with the other entity metadata. See guide for (unenforced) schema conventions.
- #[serde(rename = "extra")]
+ #[serde(rename = "cdx")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub extra: Option<serde_json::Value>,
+ pub cdx: Option<Vec<models::WebcaptureCdxLine>>,
- /// base32-encoded unique identifier
- #[serde(rename = "redirect")]
+ #[serde(rename = "archive_urls")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub redirect: Option<String>,
+ pub archive_urls: Option<Vec<models::WebcaptureUrl>>,
- /// UUID (lower-case, dash-separated, hex-encoded 128-bit)
- #[serde(rename = "revision")]
+ /// Base URL of the primary resource this is a capture of
+ #[serde(rename = "original_url")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub revision: Option<String>,
+ pub original_url: Option<String>,
- /// base32-encoded unique identifier
- #[serde(rename = "ident")]
+ /// Same format as CDX line timestamp (UTC, etc). Corresponds to the overall capture timestamp. Should generally be the timestamp of capture of the primary resource URL.
+ #[serde(rename = "timestamp")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub ident: Option<String>,
+ pub timestamp: Option<chrono::DateTime<chrono::Utc>>,
- // Note: inline enums are not fully supported by swagger-codegen
- #[serde(rename = "state")]
+ /// Set of identifier of release entities this fileset represents a full manifestation of. Usually a single release.
+ #[serde(rename = "release_ids")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub state: Option<String>,
+ pub release_ids: Option<Vec<String>>,
+
+ /// Full release entities, included in GET responses when `releases` included in `expand` parameter. Ignored if included in PUT or POST requests.
+ #[serde(rename = "releases")]
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub releases: Option<Vec<models::ReleaseEntity>>,
}
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,
+ ident: None,
+ revision: None,
+ redirect: None,
+ extra: None,
+ edit_extra: None,
+ cdx: None,
+ archive_urls: None,
+ original_url: None,
+ timestamp: None,
+ release_ids: None,
+ releases: None,
+ }
+ }
+}
+
+/// Converts the WebcaptureEntity value to the Query Parameters representation (style=form, explode=false)
+/// specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde serializer
+impl std::string::ToString for WebcaptureEntity {
+ fn to_string(&self) -> String {
+ let mut params: Vec<String> = vec![];
+
+ if let Some(ref state) = self.state {
+ params.push("state".to_string());
+ params.push(state.to_string());
+ }
+
+ if let Some(ref ident) = self.ident {
+ params.push("ident".to_string());
+ params.push(ident.to_string());
+ }
+
+ if let Some(ref revision) = self.revision {
+ params.push("revision".to_string());
+ params.push(revision.to_string());
+ }
+
+ if let Some(ref redirect) = self.redirect {
+ params.push("redirect".to_string());
+ params.push(redirect.to_string());
+ }
+
+ // Skipping extra in query parameter serialization
+ // Skipping extra in query parameter serialization
+
+ // Skipping edit_extra in query parameter serialization
+ // Skipping edit_extra in query parameter serialization
+
+ // Skipping cdx in query parameter serialization
+
+ // Skipping archive_urls in query parameter serialization
+
+ if let Some(ref original_url) = self.original_url {
+ params.push("original_url".to_string());
+ params.push(original_url.to_string());
+ }
+
+ // Skipping timestamp in query parameter serialization
+
+ if let Some(ref release_ids) = self.release_ids {
+ params.push("release_ids".to_string());
+ params.push(
+ release_ids
+ .iter()
+ .map(|x| x.to_string())
+ .collect::<Vec<_>>()
+ .join(",")
+ .to_string(),
+ );
+ }
+
+ // Skipping releases in query parameter serialization
+
+ params.join(",").to_string()
+ }
+}
+
+/// Converts Query Parameters representation (style=form, explode=false) to a WebcaptureEntity value
+/// as specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde deserializer
+impl std::str::FromStr for WebcaptureEntity {
+ type Err = String;
+
+ fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
+ #[derive(Default)]
+ // An intermediate representation of the struct to use for parsing.
+ struct IntermediateRep {
+ pub state: Vec<String>,
+ pub ident: Vec<String>,
+ pub revision: Vec<String>,
+ pub redirect: Vec<String>,
+ pub extra: Vec<std::collections::HashMap<String, serde_json::Value>>,
+ pub edit_extra: Vec<std::collections::HashMap<String, serde_json::Value>>,
+ pub cdx: Vec<Vec<models::WebcaptureCdxLine>>,
+ pub archive_urls: Vec<Vec<models::WebcaptureUrl>>,
+ pub original_url: Vec<String>,
+ pub timestamp: Vec<chrono::DateTime<chrono::Utc>>,
+ pub release_ids: Vec<Vec<String>>,
+ pub releases: Vec<Vec<models::ReleaseEntity>>,
+ }
+
+ let mut intermediate_rep = IntermediateRep::default();
+
+ // Parse into intermediate representation
+ let mut string_iter = s.split(',').into_iter();
+ let mut key_result = string_iter.next();
+
+ while key_result.is_some() {
+ let val = match string_iter.next() {
+ Some(x) => x,
+ None => {
+ return std::result::Result::Err(
+ "Missing value while parsing WebcaptureEntity".to_string(),
+ )
+ }
+ };
+
+ if let Some(key) = key_result {
+ match key {
+ "state" => intermediate_rep
+ .state
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "ident" => intermediate_rep
+ .ident
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "revision" => intermediate_rep
+ .revision
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "redirect" => intermediate_rep
+ .redirect
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "extra" => return std::result::Result::Err(
+ "Parsing a container in this style is not supported in WebcaptureEntity"
+ .to_string(),
+ ),
+ "edit_extra" => return std::result::Result::Err(
+ "Parsing a container in this style is not supported in WebcaptureEntity"
+ .to_string(),
+ ),
+ "cdx" => return std::result::Result::Err(
+ "Parsing a container in this style is not supported in WebcaptureEntity"
+ .to_string(),
+ ),
+ "archive_urls" => return std::result::Result::Err(
+ "Parsing a container in this style is not supported in WebcaptureEntity"
+ .to_string(),
+ ),
+ "original_url" => intermediate_rep
+ .original_url
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "timestamp" => intermediate_rep.timestamp.push(
+ chrono::DateTime::<chrono::Utc>::from_str(val)
+ .map_err(|x| format!("{}", x))?,
+ ),
+ "release_ids" => return std::result::Result::Err(
+ "Parsing a container in this style is not supported in WebcaptureEntity"
+ .to_string(),
+ ),
+ "releases" => return std::result::Result::Err(
+ "Parsing a container in this style is not supported in WebcaptureEntity"
+ .to_string(),
+ ),
+ _ => {
+ return std::result::Result::Err(
+ "Unexpected key while parsing WebcaptureEntity".to_string(),
+ )
+ }
+ }
+ }
+
+ // Get the next key
+ key_result = string_iter.next();
+ }
+
+ // Use the intermediate representation to return the struct
+ std::result::Result::Ok(WebcaptureEntity {
+ state: intermediate_rep.state.into_iter().next(),
+ ident: intermediate_rep.ident.into_iter().next(),
+ revision: intermediate_rep.revision.into_iter().next(),
+ redirect: intermediate_rep.redirect.into_iter().next(),
+ extra: intermediate_rep.extra.into_iter().next(),
+ edit_extra: intermediate_rep.edit_extra.into_iter().next(),
+ cdx: intermediate_rep.cdx.into_iter().next(),
+ archive_urls: intermediate_rep.archive_urls.into_iter().next(),
+ original_url: intermediate_rep.original_url.into_iter().next(),
+ timestamp: intermediate_rep.timestamp.into_iter().next(),
+ release_ids: intermediate_rep.release_ids.into_iter().next(),
+ releases: intermediate_rep.releases.into_iter().next(),
+ })
+ }
+}
+
+// Methods for converting between header::IntoHeaderValue<WebcaptureUrl> and hyper::header::HeaderValue
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<header::IntoHeaderValue<WebcaptureUrl>> for hyper::header::HeaderValue {
+ type Error = String;
+
+ fn try_from(
+ hdr_value: header::IntoHeaderValue<WebcaptureUrl>,
+ ) -> std::result::Result<Self, Self::Error> {
+ let hdr_value = hdr_value.to_string();
+ match hyper::header::HeaderValue::from_str(&hdr_value) {
+ std::result::Result::Ok(value) => std::result::Result::Ok(value),
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Invalid header value for WebcaptureUrl - value: {} is invalid {}",
+ hdr_value, e
+ )),
}
}
}
-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<WebcaptureUrl> {
+ type Error = String;
+
+ fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
+ match hdr_value.to_str() {
+ std::result::Result::Ok(value) => {
+ match <WebcaptureUrl as std::str::FromStr>::from_str(value) {
+ std::result::Result::Ok(value) => {
+ std::result::Result::Ok(header::IntoHeaderValue(value))
+ }
+ std::result::Result::Err(err) => std::result::Result::Err(format!(
+ "Unable to convert header value '{}' into WebcaptureUrl - {}",
+ value, err
+ )),
+ }
+ }
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Unable to convert header: {:?} to string: {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
+#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct WebcaptureUrl {
/// URL/URI pointing to archive of this web resource.
#[serde(rename = "url")]
@@ -1491,7 +7128,136 @@ impl WebcaptureUrl {
}
}
-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+/// Converts the WebcaptureUrl value to the Query Parameters representation (style=form, explode=false)
+/// specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde serializer
+impl std::string::ToString for WebcaptureUrl {
+ fn to_string(&self) -> String {
+ let mut params: Vec<String> = vec![];
+
+ params.push("url".to_string());
+ params.push(self.url.to_string());
+
+ params.push("rel".to_string());
+ params.push(self.rel.to_string());
+
+ params.join(",").to_string()
+ }
+}
+
+/// Converts Query Parameters representation (style=form, explode=false) to a WebcaptureUrl value
+/// as specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde deserializer
+impl std::str::FromStr for WebcaptureUrl {
+ type Err = String;
+
+ fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
+ #[derive(Default)]
+ // An intermediate representation of the struct to use for parsing.
+ struct IntermediateRep {
+ pub url: Vec<String>,
+ pub rel: Vec<String>,
+ }
+
+ let mut intermediate_rep = IntermediateRep::default();
+
+ // Parse into intermediate representation
+ let mut string_iter = s.split(',').into_iter();
+ let mut key_result = string_iter.next();
+
+ while key_result.is_some() {
+ let val = match string_iter.next() {
+ Some(x) => x,
+ None => {
+ return std::result::Result::Err(
+ "Missing value while parsing WebcaptureUrl".to_string(),
+ )
+ }
+ };
+
+ if let Some(key) = key_result {
+ match key {
+ "url" => intermediate_rep
+ .url
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "rel" => intermediate_rep
+ .rel
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ _ => {
+ return std::result::Result::Err(
+ "Unexpected key while parsing WebcaptureUrl".to_string(),
+ )
+ }
+ }
+ }
+
+ // Get the next key
+ key_result = string_iter.next();
+ }
+
+ // Use the intermediate representation to return the struct
+ std::result::Result::Ok(WebcaptureUrl {
+ url: intermediate_rep
+ .url
+ .into_iter()
+ .next()
+ .ok_or("url missing in WebcaptureUrl".to_string())?,
+ rel: intermediate_rep
+ .rel
+ .into_iter()
+ .next()
+ .ok_or("rel missing in WebcaptureUrl".to_string())?,
+ })
+ }
+}
+
+// Methods for converting between header::IntoHeaderValue<WorkAutoBatch> and hyper::header::HeaderValue
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<header::IntoHeaderValue<WorkAutoBatch>> for hyper::header::HeaderValue {
+ type Error = String;
+
+ fn try_from(
+ hdr_value: header::IntoHeaderValue<WorkAutoBatch>,
+ ) -> std::result::Result<Self, Self::Error> {
+ let hdr_value = hdr_value.to_string();
+ match hyper::header::HeaderValue::from_str(&hdr_value) {
+ std::result::Result::Ok(value) => std::result::Result::Ok(value),
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Invalid header value for WorkAutoBatch - value: {} is invalid {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<WorkAutoBatch> {
+ type Error = String;
+
+ fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
+ match hdr_value.to_str() {
+ std::result::Result::Ok(value) => {
+ match <WorkAutoBatch as std::str::FromStr>::from_str(value) {
+ std::result::Result::Ok(value) => {
+ std::result::Result::Ok(header::IntoHeaderValue(value))
+ }
+ std::result::Result::Err(err) => std::result::Result::Err(format!(
+ "Unable to convert header value '{}' into WorkAutoBatch - {}",
+ value, err
+ )),
+ }
+ }
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Unable to convert header: {:?} to string: {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
+#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct WorkAutoBatch {
#[serde(rename = "editgroup")]
pub editgroup: models::Editgroup,
@@ -1501,7 +7267,10 @@ pub struct WorkAutoBatch {
}
impl WorkAutoBatch {
- pub fn new(editgroup: models::Editgroup, entity_list: Vec<models::WorkEntity>) -> WorkAutoBatch {
+ pub fn new(
+ editgroup: models::Editgroup,
+ entity_list: Vec<models::WorkEntity>,
+ ) -> WorkAutoBatch {
WorkAutoBatch {
editgroup: editgroup,
entity_list: entity_list,
@@ -1509,22 +7278,146 @@ impl WorkAutoBatch {
}
}
-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
-pub struct WorkEntity {
- /// Free-form JSON metadata that will be stored with specific entity edits (eg, creation/update/delete).
- #[serde(rename = "edit_extra")]
- #[serde(skip_serializing_if = "Option::is_none")]
- pub edit_extra: Option<serde_json::Value>,
+/// Converts the WorkAutoBatch value to the Query Parameters representation (style=form, explode=false)
+/// specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde serializer
+impl std::string::ToString for WorkAutoBatch {
+ fn to_string(&self) -> String {
+ let mut params: Vec<String> = vec![];
+ // Skipping editgroup in query parameter serialization
- /// Free-form JSON metadata that will be stored with the other entity metadata. See guide for (unenforced) schema conventions.
- #[serde(rename = "extra")]
+ // Skipping entity_list in query parameter serialization
+
+ params.join(",").to_string()
+ }
+}
+
+/// Converts Query Parameters representation (style=form, explode=false) to a WorkAutoBatch value
+/// as specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde deserializer
+impl std::str::FromStr for WorkAutoBatch {
+ type Err = String;
+
+ fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
+ #[derive(Default)]
+ // An intermediate representation of the struct to use for parsing.
+ struct IntermediateRep {
+ pub editgroup: Vec<models::Editgroup>,
+ pub entity_list: Vec<Vec<models::WorkEntity>>,
+ }
+
+ let mut intermediate_rep = IntermediateRep::default();
+
+ // Parse into intermediate representation
+ let mut string_iter = s.split(',').into_iter();
+ let mut key_result = string_iter.next();
+
+ while key_result.is_some() {
+ let val = match string_iter.next() {
+ Some(x) => x,
+ None => {
+ return std::result::Result::Err(
+ "Missing value while parsing WorkAutoBatch".to_string(),
+ )
+ }
+ };
+
+ if let Some(key) = key_result {
+ match key {
+ "editgroup" => intermediate_rep
+ .editgroup
+ .push(models::Editgroup::from_str(val).map_err(|x| format!("{}", x))?),
+ "entity_list" => {
+ return std::result::Result::Err(
+ "Parsing a container in this style is not supported in WorkAutoBatch"
+ .to_string(),
+ )
+ }
+ _ => {
+ return std::result::Result::Err(
+ "Unexpected key while parsing WorkAutoBatch".to_string(),
+ )
+ }
+ }
+ }
+
+ // Get the next key
+ key_result = string_iter.next();
+ }
+
+ // Use the intermediate representation to return the struct
+ std::result::Result::Ok(WorkAutoBatch {
+ editgroup: intermediate_rep
+ .editgroup
+ .into_iter()
+ .next()
+ .ok_or("editgroup missing in WorkAutoBatch".to_string())?,
+ entity_list: intermediate_rep
+ .entity_list
+ .into_iter()
+ .next()
+ .ok_or("entity_list missing in WorkAutoBatch".to_string())?,
+ })
+ }
+}
+
+// Methods for converting between header::IntoHeaderValue<WorkEntity> and hyper::header::HeaderValue
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<header::IntoHeaderValue<WorkEntity>> for hyper::header::HeaderValue {
+ type Error = String;
+
+ fn try_from(
+ hdr_value: header::IntoHeaderValue<WorkEntity>,
+ ) -> std::result::Result<Self, Self::Error> {
+ let hdr_value = hdr_value.to_string();
+ match hyper::header::HeaderValue::from_str(&hdr_value) {
+ std::result::Result::Ok(value) => std::result::Result::Ok(value),
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Invalid header value for WorkEntity - value: {} is invalid {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[cfg(any(feature = "client", feature = "server"))]
+impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<WorkEntity> {
+ type Error = String;
+
+ fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
+ match hdr_value.to_str() {
+ std::result::Result::Ok(value) => {
+ match <WorkEntity as std::str::FromStr>::from_str(value) {
+ std::result::Result::Ok(value) => {
+ std::result::Result::Ok(header::IntoHeaderValue(value))
+ }
+ std::result::Result::Err(err) => std::result::Result::Err(format!(
+ "Unable to convert header value '{}' into WorkEntity - {}",
+ value, err
+ )),
+ }
+ }
+ std::result::Result::Err(e) => std::result::Result::Err(format!(
+ "Unable to convert header: {:?} to string: {}",
+ hdr_value, e
+ )),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
+#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
+pub struct WorkEntity {
+ // Note: inline enums are not fully supported by openapi-generator
+ #[serde(rename = "state")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub extra: Option<serde_json::Value>,
+ pub state: Option<String>,
/// base32-encoded unique identifier
- #[serde(rename = "redirect")]
+ #[serde(rename = "ident")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub redirect: Option<String>,
+ pub ident: Option<String>,
/// UUID (lower-case, dash-separated, hex-encoded 128-bit)
#[serde(rename = "revision")]
@@ -1532,25 +7425,151 @@ pub struct WorkEntity {
pub revision: Option<String>,
/// base32-encoded unique identifier
- #[serde(rename = "ident")]
+ #[serde(rename = "redirect")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub ident: Option<String>,
+ pub redirect: Option<String>,
- // Note: inline enums are not fully supported by swagger-codegen
- #[serde(rename = "state")]
+ /// Free-form JSON metadata that will be stored with the other entity metadata. See guide for (unenforced) schema conventions.
+ #[serde(rename = "extra")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub state: Option<String>,
+ pub extra: Option<std::collections::HashMap<String, serde_json::Value>>,
+
+ /// Free-form JSON metadata that will be stored with specific entity edits (eg, creation/update/delete).
+ #[serde(rename = "edit_extra")]
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub edit_extra: Option<std::collections::HashMap<String, serde_json::Value>>,
}
impl WorkEntity {
pub fn new() -> WorkEntity {
WorkEntity {
- edit_extra: None,
- extra: None,
- redirect: None,
- revision: None,
- ident: None,
state: None,
+ ident: None,
+ revision: None,
+ redirect: None,
+ extra: None,
+ edit_extra: None,
+ }
+ }
+}
+
+/// Converts the WorkEntity value to the Query Parameters representation (style=form, explode=false)
+/// specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde serializer
+impl std::string::ToString for WorkEntity {
+ fn to_string(&self) -> String {
+ let mut params: Vec<String> = vec![];
+
+ if let Some(ref state) = self.state {
+ params.push("state".to_string());
+ params.push(state.to_string());
+ }
+
+ if let Some(ref ident) = self.ident {
+ params.push("ident".to_string());
+ params.push(ident.to_string());
+ }
+
+ if let Some(ref revision) = self.revision {
+ params.push("revision".to_string());
+ params.push(revision.to_string());
}
+
+ if let Some(ref redirect) = self.redirect {
+ params.push("redirect".to_string());
+ params.push(redirect.to_string());
+ }
+
+ // Skipping extra in query parameter serialization
+ // Skipping extra in query parameter serialization
+
+ // Skipping edit_extra in query parameter serialization
+ // Skipping edit_extra in query parameter serialization
+
+ params.join(",").to_string()
+ }
+}
+
+/// Converts Query Parameters representation (style=form, explode=false) to a WorkEntity value
+/// as specified in https://swagger.io/docs/specification/serialization/
+/// Should be implemented in a serde deserializer
+impl std::str::FromStr for WorkEntity {
+ type Err = String;
+
+ fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
+ #[derive(Default)]
+ // An intermediate representation of the struct to use for parsing.
+ struct IntermediateRep {
+ pub state: Vec<String>,
+ pub ident: Vec<String>,
+ pub revision: Vec<String>,
+ pub redirect: Vec<String>,
+ pub extra: Vec<std::collections::HashMap<String, serde_json::Value>>,
+ pub edit_extra: Vec<std::collections::HashMap<String, serde_json::Value>>,
+ }
+
+ let mut intermediate_rep = IntermediateRep::default();
+
+ // Parse into intermediate representation
+ let mut string_iter = s.split(',').into_iter();
+ let mut key_result = string_iter.next();
+
+ while key_result.is_some() {
+ let val = match string_iter.next() {
+ Some(x) => x,
+ None => {
+ return std::result::Result::Err(
+ "Missing value while parsing WorkEntity".to_string(),
+ )
+ }
+ };
+
+ if let Some(key) = key_result {
+ match key {
+ "state" => intermediate_rep
+ .state
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "ident" => intermediate_rep
+ .ident
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "revision" => intermediate_rep
+ .revision
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "redirect" => intermediate_rep
+ .redirect
+ .push(String::from_str(val).map_err(|x| format!("{}", x))?),
+ "extra" => {
+ return std::result::Result::Err(
+ "Parsing a container in this style is not supported in WorkEntity"
+ .to_string(),
+ )
+ }
+ "edit_extra" => {
+ return std::result::Result::Err(
+ "Parsing a container in this style is not supported in WorkEntity"
+ .to_string(),
+ )
+ }
+ _ => {
+ return std::result::Result::Err(
+ "Unexpected key while parsing WorkEntity".to_string(),
+ )
+ }
+ }
+ }
+
+ // Get the next key
+ key_result = string_iter.next();
+ }
+
+ // Use the intermediate representation to return the struct
+ std::result::Result::Ok(WorkEntity {
+ state: intermediate_rep.state.into_iter().next(),
+ ident: intermediate_rep.ident.into_iter().next(),
+ revision: intermediate_rep.revision.into_iter().next(),
+ redirect: intermediate_rep.redirect.into_iter().next(),
+ extra: intermediate_rep.extra.into_iter().next(),
+ edit_extra: intermediate_rep.edit_extra.into_iter().next(),
+ })
}
}
diff --git a/rust/fatcat-openapi/src/server.rs b/rust/fatcat-openapi/src/server.rs
deleted file mode 100644
index 539d5d5b..00000000
--- a/rust/fatcat-openapi/src/server.rs
+++ /dev/null
@@ -1,10980 +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 crate::mimetypes;
-use futures::future;
-use futures::Future;
-use futures::{stream, Stream};
-use hyper;
-use hyper::header::{ContentType, Headers};
-
-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 crate::models;
-use crate::{
- AcceptEditgroupResponse, Api, AuthCheckResponse, AuthOidcResponse, CreateAuthTokenResponse, 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<T>(api: T) -> Router
-where
- T: Api + Send + Sync + Clone + 'static,
-{
- let mut router = Router::new();
- add_routes(&mut router, api);
- router
-}
-
-/// Add routes for `Api` to a provided router.
-///
-/// Note that these routes are added straight onto the router. This means that if the router
-/// already has a route for an endpoint which clashes with those provided by this API, then the
-/// old route will be lost.
-///
-/// It is generally a bad idea to add routes in this way to an existing router, which may have
-/// routes on it for other APIs. Distinct APIs should be behind distinct paths to encourage
-/// separation of interfaces, which this function does not enforce. APIs should not overlap.
-///
-/// Alternative approaches include:
-///
-/// - generate an `iron::middleware::Handler` (usually a `router::Router` or
-/// `iron::middleware::chain`) for each interface, and add those handlers inside an existing
-/// router, mounted at different paths - so the interfaces are separated by path
-/// - use a different instance of `iron::Iron` for each interface - so the interfaces are
-/// separated by the address/port they listen on
-///
-/// This function exists to allow legacy code, which doesn't separate its APIs properly, to make
-/// use of this crate.
-#[deprecated(note = "APIs should not overlap - only for use in legacy code.")]
-pub fn route<T>(router: &mut Router, api: T)
-where
- T: Api + Send + Sync + Clone + 'static,
-{
- add_routes(router, api)
-}
-
-/// Add routes for `Api` to a provided router
-fn add_routes<T>(router: &mut Router, api: T)
-where
- T: Api + Send + Sync + Clone + 'static,
-{
- let api_clone = api.clone();
- router.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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<UrlEncodedQuery>().unwrap_or_default();
- let param_role = query_params.get("role").and_then(|list| list.first()).and_then(|x| x.parse::<String>().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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<bodyparser::Raw>()
- .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(&param_oidc_params_raw);
-
- let param_oidc_params: Option<models::AuthOidc> = 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.post(
- "/v0/auth/token/:editor_id",
- move |req: &mut Request| {
- let mut context = Context::default();
-
- // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn handle_request<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<Router>()
- .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::<UrlEncodedQuery>().unwrap_or_default();
- let param_duration_seconds = query_params.get("duration_seconds").and_then(|list| list.first()).and_then(|x| x.parse::<i32>().ok());
-
- match api.create_auth_token(param_editor_id, param_duration_seconds, context).wait() {
- Ok(rsp) => match rsp {
- CreateAuthTokenResponse::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::CREATE_AUTH_TOKEN_SUCCESS.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
- Ok(response)
- }
- CreateAuthTokenResponse::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_AUTH_TOKEN_BAD_REQUEST.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
- Ok(response)
- }
- CreateAuthTokenResponse::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_AUTH_TOKEN_NOT_AUTHORIZED.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
- Ok(response)
- }
- CreateAuthTokenResponse::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_AUTH_TOKEN_FORBIDDEN.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
- Ok(response)
- }
- CreateAuthTokenResponse::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_AUTH_TOKEN_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)
- })
- },
- "CreateAuthToken",
- );
-
- let api_clone = api.clone();
- router.get(
- "/v0/changelog",
- move |req: &mut Request| {
- let mut context = Context::default();
-
- // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn handle_request<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params = req.get::<UrlEncodedQuery>().unwrap_or_default();
- let param_limit = query_params
- .get("limit")
- .and_then(|list| list.first())
- .and_then(|x| Some(x.parse::<i64>()))
- .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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_index = {
- let param = req
- .extensions
- .get::<Router>()
- .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.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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<Router>()
- .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::<bodyparser::Raw>()
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?;
-
- let mut unused_elements = Vec::new();
-
- let param_entity = if let Some(param_entity_raw) = param_entity {
- let deserializer = &mut serde_json::Deserializer::from_str(&param_entity_raw);
-
- let param_entity: Option<models::ContainerEntity> = serde_ignored::deserialize(deserializer, |path| {
- warn!("Ignoring unknown field in body: {}", path);
- unused_elements.push(path.to_string());
- })
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?;
-
- param_entity
- } else {
- None
- };
- let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?;
-
- match api.create_container(param_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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<bodyparser::Raw>()
- .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(&param_auto_batch_raw);
-
- let param_auto_batch: Option<models::ContainerAutoBatch> = 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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<Router>()
- .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::<Router>()
- .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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<Router>()
- .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::<Router>()
- .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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_ident = {
- let param = req
- .extensions
- .get::<Router>()
- .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::<UrlEncodedQuery>().unwrap_or_default();
- let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
- let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::<String>().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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_edit_id = {
- let param = req
- .extensions
- .get::<Router>()
- .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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_ident = {
- let param = req
- .extensions
- .get::<Router>()
- .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::<UrlEncodedQuery>().unwrap_or_default();
- let param_limit = query_params
- .get("limit")
- .and_then(|list| list.first())
- .and_then(|x| Some(x.parse::<i64>()))
- .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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_ident = {
- let param = req
- .extensions
- .get::<Router>()
- .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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_rev_id = {
- let param = req
- .extensions
- .get::<Router>()
- .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::<UrlEncodedQuery>().unwrap_or_default();
- let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
- let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::<String>().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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params = req.get::<UrlEncodedQuery>().unwrap_or_default();
- let param_issnl = query_params.get("issnl").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
- let param_wikidata_qid = query_params.get("wikidata_qid").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
- let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
- let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::<String>().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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<Router>()
- .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::<Router>()
- .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::<bodyparser::Raw>()
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?;
-
- let mut unused_elements = Vec::new();
-
- let param_entity = if let Some(param_entity_raw) = param_entity {
- let deserializer = &mut serde_json::Deserializer::from_str(&param_entity_raw);
-
- let param_entity: Option<models::ContainerEntity> = serde_ignored::deserialize(deserializer, |path| {
- warn!("Ignoring unknown field in body: {}", path);
- unused_elements.push(path.to_string());
- })
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?;
-
- param_entity
- } else {
- None
- };
- let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?;
-
- match api.update_container(param_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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<Router>()
- .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::<bodyparser::Raw>()
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?;
-
- let mut unused_elements = Vec::new();
-
- let param_entity = if let Some(param_entity_raw) = param_entity {
- let deserializer = &mut serde_json::Deserializer::from_str(&param_entity_raw);
-
- let param_entity: Option<models::CreatorEntity> = serde_ignored::deserialize(deserializer, |path| {
- warn!("Ignoring unknown field in body: {}", path);
- unused_elements.push(path.to_string());
- })
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?;
-
- param_entity
- } else {
- None
- };
- let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?;
-
- match api.create_creator(param_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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<bodyparser::Raw>()
- .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(&param_auto_batch_raw);
-
- let param_auto_batch: Option<models::CreatorAutoBatch> = 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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<Router>()
- .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::<Router>()
- .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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<Router>()
- .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::<Router>()
- .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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_ident = {
- let param = req
- .extensions
- .get::<Router>()
- .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::<UrlEncodedQuery>().unwrap_or_default();
- let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
- let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::<String>().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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_edit_id = {
- let param = req
- .extensions
- .get::<Router>()
- .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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_ident = {
- let param = req
- .extensions
- .get::<Router>()
- .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::<UrlEncodedQuery>().unwrap_or_default();
- let param_limit = query_params
- .get("limit")
- .and_then(|list| list.first())
- .and_then(|x| Some(x.parse::<i64>()))
- .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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_ident = {
- let param = req
- .extensions
- .get::<Router>()
- .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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_ident = {
- let param = req
- .extensions
- .get::<Router>()
- .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::<UrlEncodedQuery>().unwrap_or_default();
- let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::<String>().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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_rev_id = {
- let param = req
- .extensions
- .get::<Router>()
- .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::<UrlEncodedQuery>().unwrap_or_default();
- let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
- let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::<String>().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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params = req.get::<UrlEncodedQuery>().unwrap_or_default();
- let param_orcid = query_params.get("orcid").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
- let param_wikidata_qid = query_params.get("wikidata_qid").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
- let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
- let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::<String>().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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<Router>()
- .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::<Router>()
- .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::<bodyparser::Raw>()
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?;
-
- let mut unused_elements = Vec::new();
-
- let param_entity = if let Some(param_entity_raw) = param_entity {
- let deserializer = &mut serde_json::Deserializer::from_str(&param_entity_raw);
-
- let param_entity: Option<models::CreatorEntity> = serde_ignored::deserialize(deserializer, |path| {
- warn!("Ignoring unknown field in body: {}", path);
- unused_elements.push(path.to_string());
- })
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?;
-
- param_entity
- } else {
- None
- };
- let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?;
-
- match api.update_creator(param_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.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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<Router>()
- .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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<bodyparser::Raw>()
- .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(&param_editgroup_raw);
-
- let param_editgroup: Option<models::Editgroup> = serde_ignored::deserialize(deserializer, |path| {
- warn!("Ignoring unknown field in body: {}", path);
- unused_elements.push(path.to_string());
- })
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter 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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<Router>()
- .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::<bodyparser::Raw>()
- .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(&param_annotation_raw);
-
- let param_annotation: Option<models::EditgroupAnnotation> = 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/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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_editgroup_id = {
- let param = req
- .extensions
- .get::<Router>()
- .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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_editgroup_id = {
- let param = req
- .extensions
- .get::<Router>()
- .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::<UrlEncodedQuery>().unwrap_or_default();
- let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
-
- match api.get_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/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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params = req.get::<UrlEncodedQuery>().unwrap_or_default();
- let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
- let param_limit = query_params
- .get("limit")
- .and_then(|list| list.first())
- .and_then(|x| Some(x.parse::<i64>()))
- .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::<chrono::DateTime<chrono::Utc>>()))
- .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::<chrono::DateTime<chrono::Utc>>()))
- .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.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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<Router>()
- .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::<UrlEncodedQuery>().unwrap_or_default();
- let param_submit = query_params
- .get("submit")
- .and_then(|list| list.first())
- .and_then(|x| Some(x.to_lowercase().parse::<bool>()))
- .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::<bodyparser::Raw>()
- .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(&param_editgroup_raw);
-
- let param_editgroup: Option<models::Editgroup> = serde_ignored::deserialize(deserializer, |path| {
- warn!("Ignoring unknown field in body: {}", path);
- unused_elements.push(path.to_string());
- })
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter 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.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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_editor_id = {
- let param = req
- .extensions
- .get::<Router>()
- .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/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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_editor_id = {
- let param = req
- .extensions
- .get::<Router>()
- .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::<UrlEncodedQuery>().unwrap_or_default();
- let param_limit = query_params
- .get("limit")
- .and_then(|list| list.first())
- .and_then(|x| Some(x.parse::<i64>()))
- .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::<chrono::DateTime<chrono::Utc>>()))
- .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::<chrono::DateTime<chrono::Utc>>()))
- .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.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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_editor_id = {
- let param = req
- .extensions
- .get::<Router>()
- .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::<UrlEncodedQuery>().unwrap_or_default();
- let param_limit = query_params
- .get("limit")
- .and_then(|list| list.first())
- .and_then(|x| Some(x.parse::<i64>()))
- .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::<chrono::DateTime<chrono::Utc>>()))
- .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::<chrono::DateTime<chrono::Utc>>()))
- .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/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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<Router>()
- .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::<bodyparser::Raw>()
- .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(&param_editor_raw);
-
- let param_editor: Option<models::Editor> = 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/file",
- move |req: &mut Request| {
- let mut context = Context::default();
-
- // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn handle_request<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<Router>()
- .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::<bodyparser::Raw>()
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?;
-
- let mut unused_elements = Vec::new();
-
- let param_entity = if let Some(param_entity_raw) = param_entity {
- let deserializer = &mut serde_json::Deserializer::from_str(&param_entity_raw);
-
- let param_entity: Option<models::FileEntity> = serde_ignored::deserialize(deserializer, |path| {
- warn!("Ignoring unknown field in body: {}", path);
- unused_elements.push(path.to_string());
- })
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?;
-
- param_entity
- } else {
- None
- };
- let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?;
-
- match api.create_file(param_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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<bodyparser::Raw>()
- .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(&param_auto_batch_raw);
-
- let param_auto_batch: Option<models::FileAutoBatch> = 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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<Router>()
- .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::<Router>()
- .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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<Router>()
- .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::<Router>()
- .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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_ident = {
- let param = req
- .extensions
- .get::<Router>()
- .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::<UrlEncodedQuery>().unwrap_or_default();
- let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
- let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::<String>().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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_edit_id = {
- let param = req
- .extensions
- .get::<Router>()
- .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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_ident = {
- let param = req
- .extensions
- .get::<Router>()
- .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::<UrlEncodedQuery>().unwrap_or_default();
- let param_limit = query_params
- .get("limit")
- .and_then(|list| list.first())
- .and_then(|x| Some(x.parse::<i64>()))
- .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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_ident = {
- let param = req
- .extensions
- .get::<Router>()
- .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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_rev_id = {
- let param = req
- .extensions
- .get::<Router>()
- .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::<UrlEncodedQuery>().unwrap_or_default();
- let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
- let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::<String>().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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params = req.get::<UrlEncodedQuery>().unwrap_or_default();
- let param_md5 = query_params.get("md5").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
- let param_sha1 = query_params.get("sha1").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
- let param_sha256 = query_params.get("sha256").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
- let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
- let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::<String>().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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<Router>()
- .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::<Router>()
- .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::<bodyparser::Raw>()
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?;
-
- let mut unused_elements = Vec::new();
-
- let param_entity = if let Some(param_entity_raw) = param_entity {
- let deserializer = &mut serde_json::Deserializer::from_str(&param_entity_raw);
-
- let param_entity: Option<models::FileEntity> = serde_ignored::deserialize(deserializer, |path| {
- warn!("Ignoring unknown field in body: {}", path);
- unused_elements.push(path.to_string());
- })
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?;
-
- param_entity
- } else {
- None
- };
- let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?;
-
- match api.update_file(param_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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<Router>()
- .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::<bodyparser::Raw>()
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?;
-
- let mut unused_elements = Vec::new();
-
- let param_entity = if let Some(param_entity_raw) = param_entity {
- let deserializer = &mut serde_json::Deserializer::from_str(&param_entity_raw);
-
- let param_entity: Option<models::FilesetEntity> = 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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<bodyparser::Raw>()
- .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(&param_auto_batch_raw);
-
- let param_auto_batch: Option<models::FilesetAutoBatch> = 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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<Router>()
- .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::<Router>()
- .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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<Router>()
- .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::<Router>()
- .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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_ident = {
- let param = req
- .extensions
- .get::<Router>()
- .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::<UrlEncodedQuery>().unwrap_or_default();
- let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
- let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::<String>().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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_edit_id = {
- let param = req
- .extensions
- .get::<Router>()
- .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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_ident = {
- let param = req
- .extensions
- .get::<Router>()
- .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::<UrlEncodedQuery>().unwrap_or_default();
- let param_limit = query_params
- .get("limit")
- .and_then(|list| list.first())
- .and_then(|x| Some(x.parse::<i64>()))
- .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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_ident = {
- let param = req
- .extensions
- .get::<Router>()
- .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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_rev_id = {
- let param = req
- .extensions
- .get::<Router>()
- .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::<UrlEncodedQuery>().unwrap_or_default();
- let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
- let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::<String>().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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<Router>()
- .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::<Router>()
- .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::<bodyparser::Raw>()
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?;
-
- let mut unused_elements = Vec::new();
-
- let param_entity = if let Some(param_entity_raw) = param_entity {
- let deserializer = &mut serde_json::Deserializer::from_str(&param_entity_raw);
-
- let param_entity: Option<models::FilesetEntity> = 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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<Router>()
- .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::<bodyparser::Raw>()
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?;
-
- let mut unused_elements = Vec::new();
-
- let param_entity = if let Some(param_entity_raw) = param_entity {
- let deserializer = &mut serde_json::Deserializer::from_str(&param_entity_raw);
-
- let param_entity: Option<models::ReleaseEntity> = serde_ignored::deserialize(deserializer, |path| {
- warn!("Ignoring unknown field in body: {}", path);
- unused_elements.push(path.to_string());
- })
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?;
-
- param_entity
- } else {
- None
- };
- let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?;
-
- match api.create_release(param_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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<bodyparser::Raw>()
- .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(&param_auto_batch_raw);
-
- let param_auto_batch: Option<models::ReleaseAutoBatch> = 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.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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<Router>()
- .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::<Router>()
- .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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<Router>()
- .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::<Router>()
- .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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_ident = {
- let param = req
- .extensions
- .get::<Router>()
- .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::<UrlEncodedQuery>().unwrap_or_default();
- let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
- let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::<String>().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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_edit_id = {
- let param = req
- .extensions
- .get::<Router>()
- .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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_ident = {
- let param = req
- .extensions
- .get::<Router>()
- .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::<UrlEncodedQuery>().unwrap_or_default();
- let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::<String>().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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_ident = {
- let param = req
- .extensions
- .get::<Router>()
- .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::<UrlEncodedQuery>().unwrap_or_default();
- let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::<String>().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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_ident = {
- let param = req
- .extensions
- .get::<Router>()
- .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::<UrlEncodedQuery>().unwrap_or_default();
- let param_limit = query_params
- .get("limit")
- .and_then(|list| list.first())
- .and_then(|x| Some(x.parse::<i64>()))
- .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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_ident = {
- let param = req
- .extensions
- .get::<Router>()
- .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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_rev_id = {
- let param = req
- .extensions
- .get::<Router>()
- .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::<UrlEncodedQuery>().unwrap_or_default();
- let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
- let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::<String>().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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_ident = {
- let param = req
- .extensions
- .get::<Router>()
- .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::<UrlEncodedQuery>().unwrap_or_default();
- let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::<String>().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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params = req.get::<UrlEncodedQuery>().unwrap_or_default();
- let param_doi = query_params.get("doi").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
- let param_wikidata_qid = query_params.get("wikidata_qid").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
- let param_isbn13 = query_params.get("isbn13").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
- let param_pmid = query_params.get("pmid").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
- let param_pmcid = query_params.get("pmcid").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
- let param_core = query_params.get("core").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
- let param_arxiv = query_params.get("arxiv").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
- let param_jstor = query_params.get("jstor").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
- let param_ark = query_params.get("ark").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
- let param_mag = query_params.get("mag").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
- let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
- let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::<String>().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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<Router>()
- .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::<Router>()
- .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::<bodyparser::Raw>()
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?;
-
- let mut unused_elements = Vec::new();
-
- let param_entity = if let Some(param_entity_raw) = param_entity {
- let deserializer = &mut serde_json::Deserializer::from_str(&param_entity_raw);
-
- let param_entity: Option<models::ReleaseEntity> = serde_ignored::deserialize(deserializer, |path| {
- warn!("Ignoring unknown field in body: {}", path);
- unused_elements.push(path.to_string());
- })
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?;
-
- param_entity
- } else {
- None
- };
- let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?;
-
- match api.update_release(param_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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<Router>()
- .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::<bodyparser::Raw>()
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?;
-
- let mut unused_elements = Vec::new();
-
- let param_entity = if let Some(param_entity_raw) = param_entity {
- let deserializer = &mut serde_json::Deserializer::from_str(&param_entity_raw);
-
- let param_entity: Option<models::WebcaptureEntity> = 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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<bodyparser::Raw>()
- .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(&param_auto_batch_raw);
-
- let param_auto_batch: Option<models::WebcaptureAutoBatch> = 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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<Router>()
- .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::<Router>()
- .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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<Router>()
- .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::<Router>()
- .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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_ident = {
- let param = req
- .extensions
- .get::<Router>()
- .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::<UrlEncodedQuery>().unwrap_or_default();
- let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
- let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::<String>().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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_edit_id = {
- let param = req
- .extensions
- .get::<Router>()
- .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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_ident = {
- let param = req
- .extensions
- .get::<Router>()
- .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::<UrlEncodedQuery>().unwrap_or_default();
- let param_limit = query_params
- .get("limit")
- .and_then(|list| list.first())
- .and_then(|x| Some(x.parse::<i64>()))
- .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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_ident = {
- let param = req
- .extensions
- .get::<Router>()
- .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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_rev_id = {
- let param = req
- .extensions
- .get::<Router>()
- .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::<UrlEncodedQuery>().unwrap_or_default();
- let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
- let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::<String>().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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<Router>()
- .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::<Router>()
- .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::<bodyparser::Raw>()
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?;
-
- let mut unused_elements = Vec::new();
-
- let param_entity = if let Some(param_entity_raw) = param_entity {
- let deserializer = &mut serde_json::Deserializer::from_str(&param_entity_raw);
-
- let param_entity: Option<models::WebcaptureEntity> = 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/: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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<Router>()
- .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::<bodyparser::Raw>()
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?;
-
- let mut unused_elements = Vec::new();
-
- let param_entity = if let Some(param_entity_raw) = param_entity {
- let deserializer = &mut serde_json::Deserializer::from_str(&param_entity_raw);
-
- let param_entity: Option<models::WorkEntity> = serde_ignored::deserialize(deserializer, |path| {
- warn!("Ignoring unknown field in body: {}", path);
- unused_elements.push(path.to_string());
- })
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?;
-
- param_entity
- } else {
- None
- };
- let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?;
-
- match api.create_work(param_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.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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<bodyparser::Raw>()
- .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(&param_auto_batch_raw);
-
- let param_auto_batch: Option<models::WorkAutoBatch> = 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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<Router>()
- .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::<Router>()
- .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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<Router>()
- .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::<Router>()
- .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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_ident = {
- let param = req
- .extensions
- .get::<Router>()
- .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::<UrlEncodedQuery>().unwrap_or_default();
- let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
- let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::<String>().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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_edit_id = {
- let param = req
- .extensions
- .get::<Router>()
- .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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_ident = {
- let param = req
- .extensions
- .get::<Router>()
- .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::<UrlEncodedQuery>().unwrap_or_default();
- let param_limit = query_params
- .get("limit")
- .and_then(|list| list.first())
- .and_then(|x| Some(x.parse::<i64>()))
- .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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_ident = {
- let param = req
- .extensions
- .get::<Router>()
- .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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_ident = {
- let param = req
- .extensions
- .get::<Router>()
- .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::<UrlEncodedQuery>().unwrap_or_default();
- let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::<String>().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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_rev_id = {
- let param = req
- .extensions
- .get::<Router>()
- .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::<UrlEncodedQuery>().unwrap_or_default();
- let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
- let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::<String>().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<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- 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::<Router>()
- .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::<Router>()
- .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::<bodyparser::Raw>()
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?;
-
- let mut unused_elements = Vec::new();
-
- let param_entity = if let Some(param_entity_raw) = param_entity {
- let deserializer = &mut serde_json::Deserializer::from_str(&param_entity_raw);
-
- let param_entity: Option<models::WorkEntity> = serde_ignored::deserialize(deserializer, |path| {
- warn!("Ignoring unknown field in body: {}", path);
- unused_elements.push(path.to_string());
- })
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?;
-
- param_entity
- } else {
- None
- };
- let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?;
-
- match api.update_work(param_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::<ApiKey1>() {
- req.extensions.insert::<AuthData>(AuthData::ApiKey(header.0.clone()));
- return Ok(());
- }
- }
-
- Ok(())
- }
-}
diff --git a/rust/fatcat-openapi/src/server/mod.rs b/rust/fatcat-openapi/src/server/mod.rs
new file mode 100644
index 00000000..e14f7bd7
--- /dev/null
+++ b/rust/fatcat-openapi/src/server/mod.rs
@@ -0,0 +1,15022 @@
+use futures::{future, stream, Future, Stream};
+use hyper;
+use hyper::header::{HeaderName, HeaderValue, CONTENT_TYPE};
+use hyper::{Body, Error, HeaderMap, Request, Response, StatusCode};
+use log::warn;
+use serde_json;
+#[allow(unused_imports)]
+use std::convert::{TryFrom, TryInto};
+use std::io;
+use std::marker::PhantomData;
+#[allow(unused_imports)]
+use swagger;
+pub use swagger::auth::Authorization;
+use swagger::auth::Scopes;
+use swagger::context::ContextualPayload;
+use swagger::{ApiError, Has, RequestParser, XSpanIdString};
+use url::form_urlencoded;
+
+use crate::header;
+#[allow(unused_imports)]
+use crate::models;
+
+pub use crate::context;
+
+use crate::{
+ AcceptEditgroupResponse, Api, AuthCheckResponse, AuthOidcResponse, CreateAuthTokenResponse,
+ 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,
+};
+
+mod paths {
+ use lazy_static::lazy_static;
+
+ lazy_static! {
+ pub static ref GLOBAL_REGEX_SET: regex::RegexSet = regex::RegexSet::new(vec![
+ r"^/v0/auth/check$",
+ r"^/v0/auth/oidc$",
+ r"^/v0/auth/token/(?P<editor_id>[^/?#]*)$",
+ r"^/v0/changelog$",
+ r"^/v0/changelog/(?P<index>[^/?#]*)$",
+ r"^/v0/container/edit/(?P<edit_id>[^/?#]*)$",
+ r"^/v0/container/lookup$",
+ r"^/v0/container/rev/(?P<rev_id>[^/?#]*)$",
+ r"^/v0/container/(?P<ident>[^/?#]*)$",
+ r"^/v0/container/(?P<ident>[^/?#]*)/history$",
+ r"^/v0/container/(?P<ident>[^/?#]*)/redirects$",
+ r"^/v0/creator/edit/(?P<edit_id>[^/?#]*)$",
+ r"^/v0/creator/lookup$",
+ r"^/v0/creator/rev/(?P<rev_id>[^/?#]*)$",
+ r"^/v0/creator/(?P<ident>[^/?#]*)$",
+ r"^/v0/creator/(?P<ident>[^/?#]*)/history$",
+ r"^/v0/creator/(?P<ident>[^/?#]*)/redirects$",
+ r"^/v0/creator/(?P<ident>[^/?#]*)/releases$",
+ r"^/v0/editgroup$",
+ r"^/v0/editgroup/auto/container/batch$",
+ r"^/v0/editgroup/auto/creator/batch$",
+ r"^/v0/editgroup/auto/file/batch$",
+ r"^/v0/editgroup/auto/fileset/batch$",
+ r"^/v0/editgroup/auto/release/batch$",
+ r"^/v0/editgroup/auto/webcapture/batch$",
+ r"^/v0/editgroup/auto/work/batch$",
+ r"^/v0/editgroup/reviewable$",
+ r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)$",
+ r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/accept$",
+ r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/annotation$",
+ r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/annotations$",
+ r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/container$",
+ r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/container/edit/(?P<edit_id>[^/?#]*)$",
+ r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/container/(?P<ident>[^/?#]*)$",
+ r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/creator$",
+ r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/creator/edit/(?P<edit_id>[^/?#]*)$",
+ r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/creator/(?P<ident>[^/?#]*)$",
+ r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/file$",
+ r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/file/edit/(?P<edit_id>[^/?#]*)$",
+ r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/file/(?P<ident>[^/?#]*)$",
+ r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/fileset$",
+ r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/fileset/edit/(?P<edit_id>[^/?#]*)$",
+ r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/fileset/(?P<ident>[^/?#]*)$",
+ r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/release$",
+ r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/release/edit/(?P<edit_id>[^/?#]*)$",
+ r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/release/(?P<ident>[^/?#]*)$",
+ r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/webcapture$",
+ r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/webcapture/edit/(?P<edit_id>[^/?#]*)$",
+ r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/webcapture/(?P<ident>[^/?#]*)$",
+ r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/work$",
+ r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/work/edit/(?P<edit_id>[^/?#]*)$",
+ r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/work/(?P<ident>[^/?#]*)$",
+ r"^/v0/editor/(?P<editor_id>[^/?#]*)$",
+ r"^/v0/editor/(?P<editor_id>[^/?#]*)/annotations$",
+ r"^/v0/editor/(?P<editor_id>[^/?#]*)/editgroups$",
+ r"^/v0/file/edit/(?P<edit_id>[^/?#]*)$",
+ r"^/v0/file/lookup$",
+ r"^/v0/file/rev/(?P<rev_id>[^/?#]*)$",
+ r"^/v0/file/(?P<ident>[^/?#]*)$",
+ r"^/v0/file/(?P<ident>[^/?#]*)/history$",
+ r"^/v0/file/(?P<ident>[^/?#]*)/redirects$",
+ r"^/v0/fileset/edit/(?P<edit_id>[^/?#]*)$",
+ r"^/v0/fileset/rev/(?P<rev_id>[^/?#]*)$",
+ r"^/v0/fileset/(?P<ident>[^/?#]*)$",
+ r"^/v0/fileset/(?P<ident>[^/?#]*)/history$",
+ r"^/v0/fileset/(?P<ident>[^/?#]*)/redirects$",
+ r"^/v0/release/edit/(?P<edit_id>[^/?#]*)$",
+ r"^/v0/release/lookup$",
+ r"^/v0/release/rev/(?P<rev_id>[^/?#]*)$",
+ r"^/v0/release/(?P<ident>[^/?#]*)$",
+ r"^/v0/release/(?P<ident>[^/?#]*)/files$",
+ r"^/v0/release/(?P<ident>[^/?#]*)/filesets$",
+ r"^/v0/release/(?P<ident>[^/?#]*)/history$",
+ r"^/v0/release/(?P<ident>[^/?#]*)/redirects$",
+ r"^/v0/release/(?P<ident>[^/?#]*)/webcaptures$",
+ r"^/v0/webcapture/edit/(?P<edit_id>[^/?#]*)$",
+ r"^/v0/webcapture/rev/(?P<rev_id>[^/?#]*)$",
+ r"^/v0/webcapture/(?P<ident>[^/?#]*)$",
+ r"^/v0/webcapture/(?P<ident>[^/?#]*)/history$",
+ r"^/v0/webcapture/(?P<ident>[^/?#]*)/redirects$",
+ r"^/v0/work/edit/(?P<edit_id>[^/?#]*)$",
+ r"^/v0/work/rev/(?P<rev_id>[^/?#]*)$",
+ r"^/v0/work/(?P<ident>[^/?#]*)$",
+ r"^/v0/work/(?P<ident>[^/?#]*)/history$",
+ r"^/v0/work/(?P<ident>[^/?#]*)/redirects$",
+ r"^/v0/work/(?P<ident>[^/?#]*)/releases$"
+ ])
+ .expect("Unable to create global regex set");
+ }
+ pub(crate) static ID_AUTH_CHECK: usize = 0;
+ pub(crate) static ID_AUTH_OIDC: usize = 1;
+ pub(crate) static ID_AUTH_TOKEN_EDITOR_ID: usize = 2;
+ lazy_static! {
+ pub static ref REGEX_AUTH_TOKEN_EDITOR_ID: regex::Regex =
+ regex::Regex::new(r"^/v0/auth/token/(?P<editor_id>[^/?#]*)$")
+ .expect("Unable to create regex for AUTH_TOKEN_EDITOR_ID");
+ }
+ pub(crate) static ID_CHANGELOG: usize = 3;
+ pub(crate) static ID_CHANGELOG_INDEX: usize = 4;
+ lazy_static! {
+ pub static ref REGEX_CHANGELOG_INDEX: regex::Regex =
+ regex::Regex::new(r"^/v0/changelog/(?P<index>[^/?#]*)$")
+ .expect("Unable to create regex for CHANGELOG_INDEX");
+ }
+ pub(crate) static ID_CONTAINER_EDIT_EDIT_ID: usize = 5;
+ lazy_static! {
+ pub static ref REGEX_CONTAINER_EDIT_EDIT_ID: regex::Regex =
+ regex::Regex::new(r"^/v0/container/edit/(?P<edit_id>[^/?#]*)$")
+ .expect("Unable to create regex for CONTAINER_EDIT_EDIT_ID");
+ }
+ pub(crate) static ID_CONTAINER_LOOKUP: usize = 6;
+ pub(crate) static ID_CONTAINER_REV_REV_ID: usize = 7;
+ lazy_static! {
+ pub static ref REGEX_CONTAINER_REV_REV_ID: regex::Regex =
+ regex::Regex::new(r"^/v0/container/rev/(?P<rev_id>[^/?#]*)$")
+ .expect("Unable to create regex for CONTAINER_REV_REV_ID");
+ }
+ pub(crate) static ID_CONTAINER_IDENT: usize = 8;
+ lazy_static! {
+ pub static ref REGEX_CONTAINER_IDENT: regex::Regex =
+ regex::Regex::new(r"^/v0/container/(?P<ident>[^/?#]*)$")
+ .expect("Unable to create regex for CONTAINER_IDENT");
+ }
+ pub(crate) static ID_CONTAINER_IDENT_HISTORY: usize = 9;
+ lazy_static! {
+ pub static ref REGEX_CONTAINER_IDENT_HISTORY: regex::Regex =
+ regex::Regex::new(r"^/v0/container/(?P<ident>[^/?#]*)/history$")
+ .expect("Unable to create regex for CONTAINER_IDENT_HISTORY");
+ }
+ pub(crate) static ID_CONTAINER_IDENT_REDIRECTS: usize = 10;
+ lazy_static! {
+ pub static ref REGEX_CONTAINER_IDENT_REDIRECTS: regex::Regex =
+ regex::Regex::new(r"^/v0/container/(?P<ident>[^/?#]*)/redirects$")
+ .expect("Unable to create regex for CONTAINER_IDENT_REDIRECTS");
+ }
+ pub(crate) static ID_CREATOR_EDIT_EDIT_ID: usize = 11;
+ lazy_static! {
+ pub static ref REGEX_CREATOR_EDIT_EDIT_ID: regex::Regex =
+ regex::Regex::new(r"^/v0/creator/edit/(?P<edit_id>[^/?#]*)$")
+ .expect("Unable to create regex for CREATOR_EDIT_EDIT_ID");
+ }
+ pub(crate) static ID_CREATOR_LOOKUP: usize = 12;
+ pub(crate) static ID_CREATOR_REV_REV_ID: usize = 13;
+ lazy_static! {
+ pub static ref REGEX_CREATOR_REV_REV_ID: regex::Regex =
+ regex::Regex::new(r"^/v0/creator/rev/(?P<rev_id>[^/?#]*)$")
+ .expect("Unable to create regex for CREATOR_REV_REV_ID");
+ }
+ pub(crate) static ID_CREATOR_IDENT: usize = 14;
+ lazy_static! {
+ pub static ref REGEX_CREATOR_IDENT: regex::Regex =
+ regex::Regex::new(r"^/v0/creator/(?P<ident>[^/?#]*)$")
+ .expect("Unable to create regex for CREATOR_IDENT");
+ }
+ pub(crate) static ID_CREATOR_IDENT_HISTORY: usize = 15;
+ lazy_static! {
+ pub static ref REGEX_CREATOR_IDENT_HISTORY: regex::Regex =
+ regex::Regex::new(r"^/v0/creator/(?P<ident>[^/?#]*)/history$")
+ .expect("Unable to create regex for CREATOR_IDENT_HISTORY");
+ }
+ pub(crate) static ID_CREATOR_IDENT_REDIRECTS: usize = 16;
+ lazy_static! {
+ pub static ref REGEX_CREATOR_IDENT_REDIRECTS: regex::Regex =
+ regex::Regex::new(r"^/v0/creator/(?P<ident>[^/?#]*)/redirects$")
+ .expect("Unable to create regex for CREATOR_IDENT_REDIRECTS");
+ }
+ pub(crate) static ID_CREATOR_IDENT_RELEASES: usize = 17;
+ lazy_static! {
+ pub static ref REGEX_CREATOR_IDENT_RELEASES: regex::Regex =
+ regex::Regex::new(r"^/v0/creator/(?P<ident>[^/?#]*)/releases$")
+ .expect("Unable to create regex for CREATOR_IDENT_RELEASES");
+ }
+ pub(crate) static ID_EDITGROUP: usize = 18;
+ pub(crate) static ID_EDITGROUP_AUTO_CONTAINER_BATCH: usize = 19;
+ pub(crate) static ID_EDITGROUP_AUTO_CREATOR_BATCH: usize = 20;
+ pub(crate) static ID_EDITGROUP_AUTO_FILE_BATCH: usize = 21;
+ pub(crate) static ID_EDITGROUP_AUTO_FILESET_BATCH: usize = 22;
+ pub(crate) static ID_EDITGROUP_AUTO_RELEASE_BATCH: usize = 23;
+ pub(crate) static ID_EDITGROUP_AUTO_WEBCAPTURE_BATCH: usize = 24;
+ pub(crate) static ID_EDITGROUP_AUTO_WORK_BATCH: usize = 25;
+ pub(crate) static ID_EDITGROUP_REVIEWABLE: usize = 26;
+ pub(crate) static ID_EDITGROUP_EDITGROUP_ID: usize = 27;
+ lazy_static! {
+ pub static ref REGEX_EDITGROUP_EDITGROUP_ID: regex::Regex =
+ regex::Regex::new(r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)$")
+ .expect("Unable to create regex for EDITGROUP_EDITGROUP_ID");
+ }
+ pub(crate) static ID_EDITGROUP_EDITGROUP_ID_ACCEPT: usize = 28;
+ lazy_static! {
+ pub static ref REGEX_EDITGROUP_EDITGROUP_ID_ACCEPT: regex::Regex =
+ regex::Regex::new(r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/accept$")
+ .expect("Unable to create regex for EDITGROUP_EDITGROUP_ID_ACCEPT");
+ }
+ pub(crate) static ID_EDITGROUP_EDITGROUP_ID_ANNOTATION: usize = 29;
+ lazy_static! {
+ pub static ref REGEX_EDITGROUP_EDITGROUP_ID_ANNOTATION: regex::Regex =
+ regex::Regex::new(r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/annotation$")
+ .expect("Unable to create regex for EDITGROUP_EDITGROUP_ID_ANNOTATION");
+ }
+ pub(crate) static ID_EDITGROUP_EDITGROUP_ID_ANNOTATIONS: usize = 30;
+ lazy_static! {
+ pub static ref REGEX_EDITGROUP_EDITGROUP_ID_ANNOTATIONS: regex::Regex =
+ regex::Regex::new(r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/annotations$")
+ .expect("Unable to create regex for EDITGROUP_EDITGROUP_ID_ANNOTATIONS");
+ }
+ pub(crate) static ID_EDITGROUP_EDITGROUP_ID_CONTAINER: usize = 31;
+ lazy_static! {
+ pub static ref REGEX_EDITGROUP_EDITGROUP_ID_CONTAINER: regex::Regex =
+ regex::Regex::new(r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/container$")
+ .expect("Unable to create regex for EDITGROUP_EDITGROUP_ID_CONTAINER");
+ }
+ pub(crate) static ID_EDITGROUP_EDITGROUP_ID_CONTAINER_EDIT_EDIT_ID: usize = 32;
+ lazy_static! {
+ pub static ref REGEX_EDITGROUP_EDITGROUP_ID_CONTAINER_EDIT_EDIT_ID: regex::Regex =
+ regex::Regex::new(
+ r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/container/edit/(?P<edit_id>[^/?#]*)$"
+ )
+ .expect("Unable to create regex for EDITGROUP_EDITGROUP_ID_CONTAINER_EDIT_EDIT_ID");
+ }
+ pub(crate) static ID_EDITGROUP_EDITGROUP_ID_CONTAINER_IDENT: usize = 33;
+ lazy_static! {
+ pub static ref REGEX_EDITGROUP_EDITGROUP_ID_CONTAINER_IDENT: regex::Regex =
+ regex::Regex::new(
+ r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/container/(?P<ident>[^/?#]*)$"
+ )
+ .expect("Unable to create regex for EDITGROUP_EDITGROUP_ID_CONTAINER_IDENT");
+ }
+ pub(crate) static ID_EDITGROUP_EDITGROUP_ID_CREATOR: usize = 34;
+ lazy_static! {
+ pub static ref REGEX_EDITGROUP_EDITGROUP_ID_CREATOR: regex::Regex =
+ regex::Regex::new(r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/creator$")
+ .expect("Unable to create regex for EDITGROUP_EDITGROUP_ID_CREATOR");
+ }
+ pub(crate) static ID_EDITGROUP_EDITGROUP_ID_CREATOR_EDIT_EDIT_ID: usize = 35;
+ lazy_static! {
+ pub static ref REGEX_EDITGROUP_EDITGROUP_ID_CREATOR_EDIT_EDIT_ID: regex::Regex =
+ regex::Regex::new(
+ r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/creator/edit/(?P<edit_id>[^/?#]*)$"
+ )
+ .expect("Unable to create regex for EDITGROUP_EDITGROUP_ID_CREATOR_EDIT_EDIT_ID");
+ }
+ pub(crate) static ID_EDITGROUP_EDITGROUP_ID_CREATOR_IDENT: usize = 36;
+ lazy_static! {
+ pub static ref REGEX_EDITGROUP_EDITGROUP_ID_CREATOR_IDENT: regex::Regex =
+ regex::Regex::new(
+ r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/creator/(?P<ident>[^/?#]*)$"
+ )
+ .expect("Unable to create regex for EDITGROUP_EDITGROUP_ID_CREATOR_IDENT");
+ }
+ pub(crate) static ID_EDITGROUP_EDITGROUP_ID_FILE: usize = 37;
+ lazy_static! {
+ pub static ref REGEX_EDITGROUP_EDITGROUP_ID_FILE: regex::Regex =
+ regex::Regex::new(r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/file$")
+ .expect("Unable to create regex for EDITGROUP_EDITGROUP_ID_FILE");
+ }
+ pub(crate) static ID_EDITGROUP_EDITGROUP_ID_FILE_EDIT_EDIT_ID: usize = 38;
+ lazy_static! {
+ pub static ref REGEX_EDITGROUP_EDITGROUP_ID_FILE_EDIT_EDIT_ID: regex::Regex =
+ regex::Regex::new(
+ r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/file/edit/(?P<edit_id>[^/?#]*)$"
+ )
+ .expect("Unable to create regex for EDITGROUP_EDITGROUP_ID_FILE_EDIT_EDIT_ID");
+ }
+ pub(crate) static ID_EDITGROUP_EDITGROUP_ID_FILE_IDENT: usize = 39;
+ lazy_static! {
+ pub static ref REGEX_EDITGROUP_EDITGROUP_ID_FILE_IDENT: regex::Regex =
+ regex::Regex::new(r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/file/(?P<ident>[^/?#]*)$")
+ .expect("Unable to create regex for EDITGROUP_EDITGROUP_ID_FILE_IDENT");
+ }
+ pub(crate) static ID_EDITGROUP_EDITGROUP_ID_FILESET: usize = 40;
+ lazy_static! {
+ pub static ref REGEX_EDITGROUP_EDITGROUP_ID_FILESET: regex::Regex =
+ regex::Regex::new(r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/fileset$")
+ .expect("Unable to create regex for EDITGROUP_EDITGROUP_ID_FILESET");
+ }
+ pub(crate) static ID_EDITGROUP_EDITGROUP_ID_FILESET_EDIT_EDIT_ID: usize = 41;
+ lazy_static! {
+ pub static ref REGEX_EDITGROUP_EDITGROUP_ID_FILESET_EDIT_EDIT_ID: regex::Regex =
+ regex::Regex::new(
+ r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/fileset/edit/(?P<edit_id>[^/?#]*)$"
+ )
+ .expect("Unable to create regex for EDITGROUP_EDITGROUP_ID_FILESET_EDIT_EDIT_ID");
+ }
+ pub(crate) static ID_EDITGROUP_EDITGROUP_ID_FILESET_IDENT: usize = 42;
+ lazy_static! {
+ pub static ref REGEX_EDITGROUP_EDITGROUP_ID_FILESET_IDENT: regex::Regex =
+ regex::Regex::new(
+ r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/fileset/(?P<ident>[^/?#]*)$"
+ )
+ .expect("Unable to create regex for EDITGROUP_EDITGROUP_ID_FILESET_IDENT");
+ }
+ pub(crate) static ID_EDITGROUP_EDITGROUP_ID_RELEASE: usize = 43;
+ lazy_static! {
+ pub static ref REGEX_EDITGROUP_EDITGROUP_ID_RELEASE: regex::Regex =
+ regex::Regex::new(r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/release$")
+ .expect("Unable to create regex for EDITGROUP_EDITGROUP_ID_RELEASE");
+ }
+ pub(crate) static ID_EDITGROUP_EDITGROUP_ID_RELEASE_EDIT_EDIT_ID: usize = 44;
+ lazy_static! {
+ pub static ref REGEX_EDITGROUP_EDITGROUP_ID_RELEASE_EDIT_EDIT_ID: regex::Regex =
+ regex::Regex::new(
+ r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/release/edit/(?P<edit_id>[^/?#]*)$"
+ )
+ .expect("Unable to create regex for EDITGROUP_EDITGROUP_ID_RELEASE_EDIT_EDIT_ID");
+ }
+ pub(crate) static ID_EDITGROUP_EDITGROUP_ID_RELEASE_IDENT: usize = 45;
+ lazy_static! {
+ pub static ref REGEX_EDITGROUP_EDITGROUP_ID_RELEASE_IDENT: regex::Regex =
+ regex::Regex::new(
+ r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/release/(?P<ident>[^/?#]*)$"
+ )
+ .expect("Unable to create regex for EDITGROUP_EDITGROUP_ID_RELEASE_IDENT");
+ }
+ pub(crate) static ID_EDITGROUP_EDITGROUP_ID_WEBCAPTURE: usize = 46;
+ lazy_static! {
+ pub static ref REGEX_EDITGROUP_EDITGROUP_ID_WEBCAPTURE: regex::Regex =
+ regex::Regex::new(r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/webcapture$")
+ .expect("Unable to create regex for EDITGROUP_EDITGROUP_ID_WEBCAPTURE");
+ }
+ pub(crate) static ID_EDITGROUP_EDITGROUP_ID_WEBCAPTURE_EDIT_EDIT_ID: usize = 47;
+ lazy_static! {
+ pub static ref REGEX_EDITGROUP_EDITGROUP_ID_WEBCAPTURE_EDIT_EDIT_ID: regex::Regex =
+ regex::Regex::new(
+ r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/webcapture/edit/(?P<edit_id>[^/?#]*)$"
+ )
+ .expect("Unable to create regex for EDITGROUP_EDITGROUP_ID_WEBCAPTURE_EDIT_EDIT_ID");
+ }
+ pub(crate) static ID_EDITGROUP_EDITGROUP_ID_WEBCAPTURE_IDENT: usize = 48;
+ lazy_static! {
+ pub static ref REGEX_EDITGROUP_EDITGROUP_ID_WEBCAPTURE_IDENT: regex::Regex =
+ regex::Regex::new(
+ r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/webcapture/(?P<ident>[^/?#]*)$"
+ )
+ .expect("Unable to create regex for EDITGROUP_EDITGROUP_ID_WEBCAPTURE_IDENT");
+ }
+ pub(crate) static ID_EDITGROUP_EDITGROUP_ID_WORK: usize = 49;
+ lazy_static! {
+ pub static ref REGEX_EDITGROUP_EDITGROUP_ID_WORK: regex::Regex =
+ regex::Regex::new(r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/work$")
+ .expect("Unable to create regex for EDITGROUP_EDITGROUP_ID_WORK");
+ }
+ pub(crate) static ID_EDITGROUP_EDITGROUP_ID_WORK_EDIT_EDIT_ID: usize = 50;
+ lazy_static! {
+ pub static ref REGEX_EDITGROUP_EDITGROUP_ID_WORK_EDIT_EDIT_ID: regex::Regex =
+ regex::Regex::new(
+ r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/work/edit/(?P<edit_id>[^/?#]*)$"
+ )
+ .expect("Unable to create regex for EDITGROUP_EDITGROUP_ID_WORK_EDIT_EDIT_ID");
+ }
+ pub(crate) static ID_EDITGROUP_EDITGROUP_ID_WORK_IDENT: usize = 51;
+ lazy_static! {
+ pub static ref REGEX_EDITGROUP_EDITGROUP_ID_WORK_IDENT: regex::Regex =
+ regex::Regex::new(r"^/v0/editgroup/(?P<editgroup_id>[^/?#]*)/work/(?P<ident>[^/?#]*)$")
+ .expect("Unable to create regex for EDITGROUP_EDITGROUP_ID_WORK_IDENT");
+ }
+ pub(crate) static ID_EDITOR_EDITOR_ID: usize = 52;
+ lazy_static! {
+ pub static ref REGEX_EDITOR_EDITOR_ID: regex::Regex =
+ regex::Regex::new(r"^/v0/editor/(?P<editor_id>[^/?#]*)$")
+ .expect("Unable to create regex for EDITOR_EDITOR_ID");
+ }
+ pub(crate) static ID_EDITOR_EDITOR_ID_ANNOTATIONS: usize = 53;
+ lazy_static! {
+ pub static ref REGEX_EDITOR_EDITOR_ID_ANNOTATIONS: regex::Regex =
+ regex::Regex::new(r"^/v0/editor/(?P<editor_id>[^/?#]*)/annotations$")
+ .expect("Unable to create regex for EDITOR_EDITOR_ID_ANNOTATIONS");
+ }
+ pub(crate) static ID_EDITOR_EDITOR_ID_EDITGROUPS: usize = 54;
+ lazy_static! {
+ pub static ref REGEX_EDITOR_EDITOR_ID_EDITGROUPS: regex::Regex =
+ regex::Regex::new(r"^/v0/editor/(?P<editor_id>[^/?#]*)/editgroups$")
+ .expect("Unable to create regex for EDITOR_EDITOR_ID_EDITGROUPS");
+ }
+ pub(crate) static ID_FILE_EDIT_EDIT_ID: usize = 55;
+ lazy_static! {
+ pub static ref REGEX_FILE_EDIT_EDIT_ID: regex::Regex =
+ regex::Regex::new(r"^/v0/file/edit/(?P<edit_id>[^/?#]*)$")
+ .expect("Unable to create regex for FILE_EDIT_EDIT_ID");
+ }
+ pub(crate) static ID_FILE_LOOKUP: usize = 56;
+ pub(crate) static ID_FILE_REV_REV_ID: usize = 57;
+ lazy_static! {
+ pub static ref REGEX_FILE_REV_REV_ID: regex::Regex =
+ regex::Regex::new(r"^/v0/file/rev/(?P<rev_id>[^/?#]*)$")
+ .expect("Unable to create regex for FILE_REV_REV_ID");
+ }
+ pub(crate) static ID_FILE_IDENT: usize = 58;
+ lazy_static! {
+ pub static ref REGEX_FILE_IDENT: regex::Regex =
+ regex::Regex::new(r"^/v0/file/(?P<ident>[^/?#]*)$")
+ .expect("Unable to create regex for FILE_IDENT");
+ }
+ pub(crate) static ID_FILE_IDENT_HISTORY: usize = 59;
+ lazy_static! {
+ pub static ref REGEX_FILE_IDENT_HISTORY: regex::Regex =
+ regex::Regex::new(r"^/v0/file/(?P<ident>[^/?#]*)/history$")
+ .expect("Unable to create regex for FILE_IDENT_HISTORY");
+ }
+ pub(crate) static ID_FILE_IDENT_REDIRECTS: usize = 60;
+ lazy_static! {
+ pub static ref REGEX_FILE_IDENT_REDIRECTS: regex::Regex =
+ regex::Regex::new(r"^/v0/file/(?P<ident>[^/?#]*)/redirects$")
+ .expect("Unable to create regex for FILE_IDENT_REDIRECTS");
+ }
+ pub(crate) static ID_FILESET_EDIT_EDIT_ID: usize = 61;
+ lazy_static! {
+ pub static ref REGEX_FILESET_EDIT_EDIT_ID: regex::Regex =
+ regex::Regex::new(r"^/v0/fileset/edit/(?P<edit_id>[^/?#]*)$")
+ .expect("Unable to create regex for FILESET_EDIT_EDIT_ID");
+ }
+ pub(crate) static ID_FILESET_REV_REV_ID: usize = 62;
+ lazy_static! {
+ pub static ref REGEX_FILESET_REV_REV_ID: regex::Regex =
+ regex::Regex::new(r"^/v0/fileset/rev/(?P<rev_id>[^/?#]*)$")
+ .expect("Unable to create regex for FILESET_REV_REV_ID");
+ }
+ pub(crate) static ID_FILESET_IDENT: usize = 63;
+ lazy_static! {
+ pub static ref REGEX_FILESET_IDENT: regex::Regex =
+ regex::Regex::new(r"^/v0/fileset/(?P<ident>[^/?#]*)$")
+ .expect("Unable to create regex for FILESET_IDENT");
+ }
+ pub(crate) static ID_FILESET_IDENT_HISTORY: usize = 64;
+ lazy_static! {
+ pub static ref REGEX_FILESET_IDENT_HISTORY: regex::Regex =
+ regex::Regex::new(r"^/v0/fileset/(?P<ident>[^/?#]*)/history$")
+ .expect("Unable to create regex for FILESET_IDENT_HISTORY");
+ }
+ pub(crate) static ID_FILESET_IDENT_REDIRECTS: usize = 65;
+ lazy_static! {
+ pub static ref REGEX_FILESET_IDENT_REDIRECTS: regex::Regex =
+ regex::Regex::new(r"^/v0/fileset/(?P<ident>[^/?#]*)/redirects$")
+ .expect("Unable to create regex for FILESET_IDENT_REDIRECTS");
+ }
+ pub(crate) static ID_RELEASE_EDIT_EDIT_ID: usize = 66;
+ lazy_static! {
+ pub static ref REGEX_RELEASE_EDIT_EDIT_ID: regex::Regex =
+ regex::Regex::new(r"^/v0/release/edit/(?P<edit_id>[^/?#]*)$")
+ .expect("Unable to create regex for RELEASE_EDIT_EDIT_ID");
+ }
+ pub(crate) static ID_RELEASE_LOOKUP: usize = 67;
+ pub(crate) static ID_RELEASE_REV_REV_ID: usize = 68;
+ lazy_static! {
+ pub static ref REGEX_RELEASE_REV_REV_ID: regex::Regex =
+ regex::Regex::new(r"^/v0/release/rev/(?P<rev_id>[^/?#]*)$")
+ .expect("Unable to create regex for RELEASE_REV_REV_ID");
+ }
+ pub(crate) static ID_RELEASE_IDENT: usize = 69;
+ lazy_static! {
+ pub static ref REGEX_RELEASE_IDENT: regex::Regex =
+ regex::Regex::new(r"^/v0/release/(?P<ident>[^/?#]*)$")
+ .expect("Unable to create regex for RELEASE_IDENT");
+ }
+ pub(crate) static ID_RELEASE_IDENT_FILES: usize = 70;
+ lazy_static! {
+ pub static ref REGEX_RELEASE_IDENT_FILES: regex::Regex =
+ regex::Regex::new(r"^/v0/release/(?P<ident>[^/?#]*)/files$")
+ .expect("Unable to create regex for RELEASE_IDENT_FILES");
+ }
+ pub(crate) static ID_RELEASE_IDENT_FILESETS: usize = 71;
+ lazy_static! {
+ pub static ref REGEX_RELEASE_IDENT_FILESETS: regex::Regex =
+ regex::Regex::new(r"^/v0/release/(?P<ident>[^/?#]*)/filesets$")
+ .expect("Unable to create regex for RELEASE_IDENT_FILESETS");
+ }
+ pub(crate) static ID_RELEASE_IDENT_HISTORY: usize = 72;
+ lazy_static! {
+ pub static ref REGEX_RELEASE_IDENT_HISTORY: regex::Regex =
+ regex::Regex::new(r"^/v0/release/(?P<ident>[^/?#]*)/history$")
+ .expect("Unable to create regex for RELEASE_IDENT_HISTORY");
+ }
+ pub(crate) static ID_RELEASE_IDENT_REDIRECTS: usize = 73;
+ lazy_static! {
+ pub static ref REGEX_RELEASE_IDENT_REDIRECTS: regex::Regex =
+ regex::Regex::new(r"^/v0/release/(?P<ident>[^/?#]*)/redirects$")
+ .expect("Unable to create regex for RELEASE_IDENT_REDIRECTS");
+ }
+ pub(crate) static ID_RELEASE_IDENT_WEBCAPTURES: usize = 74;
+ lazy_static! {
+ pub static ref REGEX_RELEASE_IDENT_WEBCAPTURES: regex::Regex =
+ regex::Regex::new(r"^/v0/release/(?P<ident>[^/?#]*)/webcaptures$")
+ .expect("Unable to create regex for RELEASE_IDENT_WEBCAPTURES");
+ }
+ pub(crate) static ID_WEBCAPTURE_EDIT_EDIT_ID: usize = 75;
+ lazy_static! {
+ pub static ref REGEX_WEBCAPTURE_EDIT_EDIT_ID: regex::Regex =
+ regex::Regex::new(r"^/v0/webcapture/edit/(?P<edit_id>[^/?#]*)$")
+ .expect("Unable to create regex for WEBCAPTURE_EDIT_EDIT_ID");
+ }
+ pub(crate) static ID_WEBCAPTURE_REV_REV_ID: usize = 76;
+ lazy_static! {
+ pub static ref REGEX_WEBCAPTURE_REV_REV_ID: regex::Regex =
+ regex::Regex::new(r"^/v0/webcapture/rev/(?P<rev_id>[^/?#]*)$")
+ .expect("Unable to create regex for WEBCAPTURE_REV_REV_ID");
+ }
+ pub(crate) static ID_WEBCAPTURE_IDENT: usize = 77;
+ lazy_static! {
+ pub static ref REGEX_WEBCAPTURE_IDENT: regex::Regex =
+ regex::Regex::new(r"^/v0/webcapture/(?P<ident>[^/?#]*)$")
+ .expect("Unable to create regex for WEBCAPTURE_IDENT");
+ }
+ pub(crate) static ID_WEBCAPTURE_IDENT_HISTORY: usize = 78;
+ lazy_static! {
+ pub static ref REGEX_WEBCAPTURE_IDENT_HISTORY: regex::Regex =
+ regex::Regex::new(r"^/v0/webcapture/(?P<ident>[^/?#]*)/history$")
+ .expect("Unable to create regex for WEBCAPTURE_IDENT_HISTORY");
+ }
+ pub(crate) static ID_WEBCAPTURE_IDENT_REDIRECTS: usize = 79;
+ lazy_static! {
+ pub static ref REGEX_WEBCAPTURE_IDENT_REDIRECTS: regex::Regex =
+ regex::Regex::new(r"^/v0/webcapture/(?P<ident>[^/?#]*)/redirects$")
+ .expect("Unable to create regex for WEBCAPTURE_IDENT_REDIRECTS");
+ }
+ pub(crate) static ID_WORK_EDIT_EDIT_ID: usize = 80;
+ lazy_static! {
+ pub static ref REGEX_WORK_EDIT_EDIT_ID: regex::Regex =
+ regex::Regex::new(r"^/v0/work/edit/(?P<edit_id>[^/?#]*)$")
+ .expect("Unable to create regex for WORK_EDIT_EDIT_ID");
+ }
+ pub(crate) static ID_WORK_REV_REV_ID: usize = 81;
+ lazy_static! {
+ pub static ref REGEX_WORK_REV_REV_ID: regex::Regex =
+ regex::Regex::new(r"^/v0/work/rev/(?P<rev_id>[^/?#]*)$")
+ .expect("Unable to create regex for WORK_REV_REV_ID");
+ }
+ pub(crate) static ID_WORK_IDENT: usize = 82;
+ lazy_static! {
+ pub static ref REGEX_WORK_IDENT: regex::Regex =
+ regex::Regex::new(r"^/v0/work/(?P<ident>[^/?#]*)$")
+ .expect("Unable to create regex for WORK_IDENT");
+ }
+ pub(crate) static ID_WORK_IDENT_HISTORY: usize = 83;
+ lazy_static! {
+ pub static ref REGEX_WORK_IDENT_HISTORY: regex::Regex =
+ regex::Regex::new(r"^/v0/work/(?P<ident>[^/?#]*)/history$")
+ .expect("Unable to create regex for WORK_IDENT_HISTORY");
+ }
+ pub(crate) static ID_WORK_IDENT_REDIRECTS: usize = 84;
+ lazy_static! {
+ pub static ref REGEX_WORK_IDENT_REDIRECTS: regex::Regex =
+ regex::Regex::new(r"^/v0/work/(?P<ident>[^/?#]*)/redirects$")
+ .expect("Unable to create regex for WORK_IDENT_REDIRECTS");
+ }
+ pub(crate) static ID_WORK_IDENT_RELEASES: usize = 85;
+ lazy_static! {
+ pub static ref REGEX_WORK_IDENT_RELEASES: regex::Regex =
+ regex::Regex::new(r"^/v0/work/(?P<ident>[^/?#]*)/releases$")
+ .expect("Unable to create regex for WORK_IDENT_RELEASES");
+ }
+}
+
+pub struct MakeService<T, RC> {
+ api_impl: T,
+ marker: PhantomData<RC>,
+}
+
+impl<T, RC> MakeService<T, RC>
+where
+ T: Api<RC> + Clone + Send + 'static,
+ RC: Has<XSpanIdString> + Has<Option<Authorization>> + 'static,
+{
+ pub fn new(api_impl: T) -> Self {
+ MakeService {
+ api_impl,
+ marker: PhantomData,
+ }
+ }
+}
+
+impl<'a, T, SC, RC> hyper::service::MakeService<&'a SC> for MakeService<T, RC>
+where
+ T: Api<RC> + Clone + Send + 'static,
+ RC: Has<XSpanIdString> + Has<Option<Authorization>> + 'static + Send,
+{
+ type ReqBody = ContextualPayload<Body, RC>;
+ type ResBody = Body;
+ type Error = Error;
+ type Service = Service<T, RC>;
+ type Future = future::FutureResult<Self::Service, Self::MakeError>;
+ type MakeError = Error;
+
+ fn make_service(&mut self, _ctx: &'a SC) -> Self::Future {
+ future::FutureResult::from(Ok(Service::new(self.api_impl.clone())))
+ }
+}
+
+type ServiceFuture = Box<dyn Future<Item = Response<Body>, Error = Error> + Send>;
+
+fn method_not_allowed() -> ServiceFuture {
+ Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::METHOD_NOT_ALLOWED)
+ .body(Body::empty())
+ .expect("Unable to create Method Not Allowed response"),
+ ))
+}
+
+pub struct Service<T, RC> {
+ api_impl: T,
+ marker: PhantomData<RC>,
+}
+
+impl<T, RC> Service<T, RC>
+where
+ T: Api<RC> + Clone + Send + 'static,
+ RC: Has<XSpanIdString> + Has<Option<Authorization>> + 'static,
+{
+ pub fn new(api_impl: T) -> Self {
+ Service {
+ api_impl: api_impl,
+ marker: PhantomData,
+ }
+ }
+}
+
+impl<T, C> hyper::service::Service for Service<T, C>
+where
+ T: Api<C> + Clone + Send + 'static,
+ C: Has<XSpanIdString> + Has<Option<Authorization>> + 'static + Send,
+{
+ type ReqBody = ContextualPayload<Body, C>;
+ type ResBody = Body;
+ type Error = Error;
+ type Future = ServiceFuture;
+
+ fn call(&mut self, req: Request<Self::ReqBody>) -> Self::Future {
+ let api_impl = self.api_impl.clone();
+ let (parts, body) = req.into_parts();
+ let (method, uri, headers) = (parts.method, parts.uri, parts.headers);
+ let path = paths::GLOBAL_REGEX_SET.matches(uri.path());
+ let mut context = body.context;
+ let body = body.inner;
+
+ match &method {
+ // AcceptEditgroup - POST /editgroup/{editgroup_id}/accept
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_ACCEPT) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_EDITGROUP_EDITGROUP_ID_ACCEPT
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_ACCEPT in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_ACCEPT.as_str())
+ );
+
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
+ Ok(param_editgroup_id) => param_editgroup_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.accept_editgroup(
+ param_editgroup_id,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ AcceptEditgroupResponse::MergedSuccessfully
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for ACCEPT_EDITGROUP_MERGED_SUCCESSFULLY"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ AcceptEditgroupResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for ACCEPT_EDITGROUP_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ AcceptEditgroupResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for ACCEPT_EDITGROUP_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ AcceptEditgroupResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for ACCEPT_EDITGROUP_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ AcceptEditgroupResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for ACCEPT_EDITGROUP_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ AcceptEditgroupResponse::EditConflict
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(409).expect("Unable to turn 409 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for ACCEPT_EDITGROUP_EDIT_CONFLICT"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ AcceptEditgroupResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for ACCEPT_EDITGROUP_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // AuthCheck - GET /auth/check
+ &hyper::Method::GET if path.matched(paths::ID_AUTH_CHECK) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_role = query_params
+ .iter()
+ .filter(|e| e.0 == "role")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_role = param_role.and_then(|param_role| param_role.parse().ok());
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.auth_check(
+ param_role,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ AuthCheckResponse::Success
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for AUTH_CHECK_SUCCESS"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ AuthCheckResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for AUTH_CHECK_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ AuthCheckResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for AUTH_CHECK_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ AuthCheckResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for AUTH_CHECK_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ AuthCheckResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for AUTH_CHECK_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // AuthOidc - POST /auth/oidc
+ &hyper::Method::POST if path.matched(paths::ID_AUTH_OIDC) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // 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.
+ Box::new(body.concat2()
+ .then(move |result| -> Self::Future {
+ match result {
+ Ok(body) => {
+ let mut unused_elements = Vec::new();
+ let param_oidc_params: Option<models::AuthOidc> = if !body.is_empty() {
+ let deserializer = &mut serde_json::Deserializer::from_slice(&*body);
+ match serde_ignored::deserialize(deserializer, |path| {
+ warn!("Ignoring unknown field in body: {}", path);
+ unused_elements.push(path.to_string());
+ }) {
+ Ok(param_oidc_params) => param_oidc_params,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse body parameter oidc_params - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid body parameter oidc_params due to schema"))),
+ }
+ } else {
+ None
+ };
+ let param_oidc_params = match param_oidc_params {
+ Some(param_oidc_params) => param_oidc_params,
+ None => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from("Missing required body parameter oidc_params"))
+ .expect("Unable to create Bad Request response for missing body parameter oidc_params"))),
+ };
+
+ Box::new(
+ api_impl.auth_oidc(
+ param_oidc_params,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ if !unused_elements.is_empty() {
+ response.headers_mut().insert(
+ HeaderName::from_static("warning"),
+ HeaderValue::from_str(format!("Ignoring unknown fields in body: {:?}", unused_elements).as_str())
+ .expect("Unable to create Warning header value"));
+ }
+
+ match result {
+ Ok(rsp) => match rsp {
+ AuthOidcResponse::Found
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for AUTH_OIDC_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ AuthOidcResponse::Created
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(201).expect("Unable to turn 201 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for AUTH_OIDC_CREATED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ AuthOidcResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for AUTH_OIDC_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ AuthOidcResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for AUTH_OIDC_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ AuthOidcResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for AUTH_OIDC_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ AuthOidcResponse::Conflict
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(409).expect("Unable to turn 409 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for AUTH_OIDC_CONFLICT"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ AuthOidcResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for AUTH_OIDC_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ },
+ Err(e) => Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't read body parameter oidc_params: {}", e)))
+ .expect("Unable to create Bad Request response due to unable to read body parameter oidc_params"))),
+ }
+ })
+ ) as Self::Future
+ }
+
+ // CreateAuthToken - POST /auth/token/{editor_id}
+ &hyper::Method::POST if path.matched(paths::ID_AUTH_TOKEN_EDITOR_ID) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_AUTH_TOKEN_EDITOR_ID
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE AUTH_TOKEN_EDITOR_ID in set but failed match against \"{}\"", path, paths::REGEX_AUTH_TOKEN_EDITOR_ID.as_str())
+ );
+
+ let param_editor_id = match percent_encoding::percent_decode(path_params["editor_id"].as_bytes()).decode_utf8() {
+ Ok(param_editor_id) => match param_editor_id.parse::<String>() {
+ Ok(param_editor_id) => param_editor_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter editor_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editor_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_duration_seconds = query_params
+ .iter()
+ .filter(|e| e.0 == "duration_seconds")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_duration_seconds = param_duration_seconds
+ .and_then(|param_duration_seconds| param_duration_seconds.parse().ok());
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.create_auth_token(
+ param_editor_id,
+ param_duration_seconds,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ CreateAuthTokenResponse::Success
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_AUTH_TOKEN_SUCCESS"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateAuthTokenResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_AUTH_TOKEN_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateAuthTokenResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_AUTH_TOKEN_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateAuthTokenResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_AUTH_TOKEN_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateAuthTokenResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_AUTH_TOKEN_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // CreateContainer - POST /editgroup/{editgroup_id}/container
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CONTAINER) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_EDITGROUP_EDITGROUP_ID_CONTAINER
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_CONTAINER in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_CONTAINER.as_str())
+ );
+
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
+ Ok(param_editgroup_id) => param_editgroup_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // 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.
+ Box::new(body.concat2()
+ .then(move |result| -> Self::Future {
+ match result {
+ Ok(body) => {
+ let mut unused_elements = Vec::new();
+ let param_entity: Option<models::ContainerEntity> = if !body.is_empty() {
+ let deserializer = &mut serde_json::Deserializer::from_slice(&*body);
+ match serde_ignored::deserialize(deserializer, |path| {
+ warn!("Ignoring unknown field in body: {}", path);
+ unused_elements.push(path.to_string());
+ }) {
+ Ok(param_entity) => param_entity,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse body parameter entity - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid body parameter entity due to schema"))),
+ }
+ } else {
+ None
+ };
+ let param_entity = match param_entity {
+ Some(param_entity) => param_entity,
+ None => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from("Missing required body parameter entity"))
+ .expect("Unable to create Bad Request response for missing body parameter entity"))),
+ };
+
+ Box::new(
+ api_impl.create_container(
+ param_editgroup_id,
+ param_entity,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ if !unused_elements.is_empty() {
+ response.headers_mut().insert(
+ HeaderName::from_static("warning"),
+ HeaderValue::from_str(format!("Ignoring unknown fields in body: {:?}", unused_elements).as_str())
+ .expect("Unable to create Warning header value"));
+ }
+
+ match result {
+ Ok(rsp) => match rsp {
+ CreateContainerResponse::CreatedEntity
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(201).expect("Unable to turn 201 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_CONTAINER_CREATED_ENTITY"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateContainerResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_CONTAINER_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateContainerResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_CONTAINER_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateContainerResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_CONTAINER_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateContainerResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_CONTAINER_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateContainerResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_CONTAINER_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ },
+ Err(e) => Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't read body parameter entity: {}", e)))
+ .expect("Unable to create Bad Request response due to unable to read body parameter entity"))),
+ }
+ })
+ ) as Self::Future
+ }
+
+ // CreateContainerAutoBatch - POST /editgroup/auto/container/batch
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_AUTO_CONTAINER_BATCH) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // 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.
+ Box::new(body.concat2()
+ .then(move |result| -> Self::Future {
+ match result {
+ Ok(body) => {
+ let mut unused_elements = Vec::new();
+ let param_auto_batch: Option<models::ContainerAutoBatch> = if !body.is_empty() {
+ let deserializer = &mut serde_json::Deserializer::from_slice(&*body);
+ match serde_ignored::deserialize(deserializer, |path| {
+ warn!("Ignoring unknown field in body: {}", path);
+ unused_elements.push(path.to_string());
+ }) {
+ Ok(param_auto_batch) => param_auto_batch,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse body parameter auto_batch - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid body parameter auto_batch due to schema"))),
+ }
+ } else {
+ None
+ };
+ let param_auto_batch = match param_auto_batch {
+ Some(param_auto_batch) => param_auto_batch,
+ None => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from("Missing required body parameter auto_batch"))
+ .expect("Unable to create Bad Request response for missing body parameter auto_batch"))),
+ };
+
+ Box::new(
+ api_impl.create_container_auto_batch(
+ param_auto_batch,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ if !unused_elements.is_empty() {
+ response.headers_mut().insert(
+ HeaderName::from_static("warning"),
+ HeaderValue::from_str(format!("Ignoring unknown fields in body: {:?}", unused_elements).as_str())
+ .expect("Unable to create Warning header value"));
+ }
+
+ match result {
+ Ok(rsp) => match rsp {
+ CreateContainerAutoBatchResponse::CreatedEditgroup
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(201).expect("Unable to turn 201 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_CONTAINER_AUTO_BATCH_CREATED_EDITGROUP"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateContainerAutoBatchResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_CONTAINER_AUTO_BATCH_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateContainerAutoBatchResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_CONTAINER_AUTO_BATCH_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateContainerAutoBatchResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_CONTAINER_AUTO_BATCH_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateContainerAutoBatchResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_CONTAINER_AUTO_BATCH_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateContainerAutoBatchResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_CONTAINER_AUTO_BATCH_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ },
+ Err(e) => Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't read body parameter auto_batch: {}", e)))
+ .expect("Unable to create Bad Request response due to unable to read body parameter auto_batch"))),
+ }
+ })
+ ) as Self::Future
+ }
+
+ // CreateCreator - POST /editgroup/{editgroup_id}/creator
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CREATOR) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_EDITGROUP_EDITGROUP_ID_CREATOR
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_CREATOR in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_CREATOR.as_str())
+ );
+
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
+ Ok(param_editgroup_id) => param_editgroup_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // 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.
+ Box::new(body.concat2()
+ .then(move |result| -> Self::Future {
+ match result {
+ Ok(body) => {
+ let mut unused_elements = Vec::new();
+ let param_entity: Option<models::CreatorEntity> = if !body.is_empty() {
+ let deserializer = &mut serde_json::Deserializer::from_slice(&*body);
+ match serde_ignored::deserialize(deserializer, |path| {
+ warn!("Ignoring unknown field in body: {}", path);
+ unused_elements.push(path.to_string());
+ }) {
+ Ok(param_entity) => param_entity,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse body parameter entity - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid body parameter entity due to schema"))),
+ }
+ } else {
+ None
+ };
+ let param_entity = match param_entity {
+ Some(param_entity) => param_entity,
+ None => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from("Missing required body parameter entity"))
+ .expect("Unable to create Bad Request response for missing body parameter entity"))),
+ };
+
+ Box::new(
+ api_impl.create_creator(
+ param_editgroup_id,
+ param_entity,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ if !unused_elements.is_empty() {
+ response.headers_mut().insert(
+ HeaderName::from_static("warning"),
+ HeaderValue::from_str(format!("Ignoring unknown fields in body: {:?}", unused_elements).as_str())
+ .expect("Unable to create Warning header value"));
+ }
+
+ match result {
+ Ok(rsp) => match rsp {
+ CreateCreatorResponse::CreatedEntity
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(201).expect("Unable to turn 201 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_CREATOR_CREATED_ENTITY"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateCreatorResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_CREATOR_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateCreatorResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_CREATOR_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateCreatorResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_CREATOR_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateCreatorResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_CREATOR_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateCreatorResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_CREATOR_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ },
+ Err(e) => Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't read body parameter entity: {}", e)))
+ .expect("Unable to create Bad Request response due to unable to read body parameter entity"))),
+ }
+ })
+ ) as Self::Future
+ }
+
+ // CreateCreatorAutoBatch - POST /editgroup/auto/creator/batch
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_AUTO_CREATOR_BATCH) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // 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.
+ Box::new(body.concat2()
+ .then(move |result| -> Self::Future {
+ match result {
+ Ok(body) => {
+ let mut unused_elements = Vec::new();
+ let param_auto_batch: Option<models::CreatorAutoBatch> = if !body.is_empty() {
+ let deserializer = &mut serde_json::Deserializer::from_slice(&*body);
+ match serde_ignored::deserialize(deserializer, |path| {
+ warn!("Ignoring unknown field in body: {}", path);
+ unused_elements.push(path.to_string());
+ }) {
+ Ok(param_auto_batch) => param_auto_batch,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse body parameter auto_batch - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid body parameter auto_batch due to schema"))),
+ }
+ } else {
+ None
+ };
+ let param_auto_batch = match param_auto_batch {
+ Some(param_auto_batch) => param_auto_batch,
+ None => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from("Missing required body parameter auto_batch"))
+ .expect("Unable to create Bad Request response for missing body parameter auto_batch"))),
+ };
+
+ Box::new(
+ api_impl.create_creator_auto_batch(
+ param_auto_batch,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ if !unused_elements.is_empty() {
+ response.headers_mut().insert(
+ HeaderName::from_static("warning"),
+ HeaderValue::from_str(format!("Ignoring unknown fields in body: {:?}", unused_elements).as_str())
+ .expect("Unable to create Warning header value"));
+ }
+
+ match result {
+ Ok(rsp) => match rsp {
+ CreateCreatorAutoBatchResponse::CreatedEditgroup
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(201).expect("Unable to turn 201 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_CREATOR_AUTO_BATCH_CREATED_EDITGROUP"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateCreatorAutoBatchResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_CREATOR_AUTO_BATCH_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateCreatorAutoBatchResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_CREATOR_AUTO_BATCH_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateCreatorAutoBatchResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_CREATOR_AUTO_BATCH_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateCreatorAutoBatchResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_CREATOR_AUTO_BATCH_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateCreatorAutoBatchResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_CREATOR_AUTO_BATCH_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ },
+ Err(e) => Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't read body parameter auto_batch: {}", e)))
+ .expect("Unable to create Bad Request response due to unable to read body parameter auto_batch"))),
+ }
+ })
+ ) as Self::Future
+ }
+
+ // CreateEditgroup - POST /editgroup
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // 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.
+ Box::new(body.concat2()
+ .then(move |result| -> Self::Future {
+ match result {
+ Ok(body) => {
+ let mut unused_elements = Vec::new();
+ let param_editgroup: Option<models::Editgroup> = if !body.is_empty() {
+ let deserializer = &mut serde_json::Deserializer::from_slice(&*body);
+ match serde_ignored::deserialize(deserializer, |path| {
+ warn!("Ignoring unknown field in body: {}", path);
+ unused_elements.push(path.to_string());
+ }) {
+ Ok(param_editgroup) => param_editgroup,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse body parameter editgroup - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid body parameter editgroup due to schema"))),
+ }
+ } else {
+ None
+ };
+ let param_editgroup = match param_editgroup {
+ Some(param_editgroup) => param_editgroup,
+ None => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from("Missing required body parameter editgroup"))
+ .expect("Unable to create Bad Request response for missing body parameter editgroup"))),
+ };
+
+ Box::new(
+ api_impl.create_editgroup(
+ param_editgroup,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ if !unused_elements.is_empty() {
+ response.headers_mut().insert(
+ HeaderName::from_static("warning"),
+ HeaderValue::from_str(format!("Ignoring unknown fields in body: {:?}", unused_elements).as_str())
+ .expect("Unable to create Warning header value"));
+ }
+
+ match result {
+ Ok(rsp) => match rsp {
+ CreateEditgroupResponse::SuccessfullyCreated
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(201).expect("Unable to turn 201 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_EDITGROUP_SUCCESSFULLY_CREATED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateEditgroupResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_EDITGROUP_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateEditgroupResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_EDITGROUP_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateEditgroupResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_EDITGROUP_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateEditgroupResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_EDITGROUP_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateEditgroupResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_EDITGROUP_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ },
+ Err(e) => Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't read body parameter editgroup: {}", e)))
+ .expect("Unable to create Bad Request response due to unable to read body parameter editgroup"))),
+ }
+ })
+ ) as Self::Future
+ }
+
+ // CreateEditgroupAnnotation - POST /editgroup/{editgroup_id}/annotation
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_ANNOTATION) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_EDITGROUP_EDITGROUP_ID_ANNOTATION
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_ANNOTATION in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_ANNOTATION.as_str())
+ );
+
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
+ Ok(param_editgroup_id) => param_editgroup_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // 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.
+ Box::new(body.concat2()
+ .then(move |result| -> Self::Future {
+ match result {
+ Ok(body) => {
+ let mut unused_elements = Vec::new();
+ let param_annotation: Option<models::EditgroupAnnotation> = if !body.is_empty() {
+ let deserializer = &mut serde_json::Deserializer::from_slice(&*body);
+ match serde_ignored::deserialize(deserializer, |path| {
+ warn!("Ignoring unknown field in body: {}", path);
+ unused_elements.push(path.to_string());
+ }) {
+ Ok(param_annotation) => param_annotation,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse body parameter annotation - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid body parameter annotation due to schema"))),
+ }
+ } else {
+ None
+ };
+ let param_annotation = match param_annotation {
+ Some(param_annotation) => param_annotation,
+ None => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from("Missing required body parameter annotation"))
+ .expect("Unable to create Bad Request response for missing body parameter annotation"))),
+ };
+
+ Box::new(
+ api_impl.create_editgroup_annotation(
+ param_editgroup_id,
+ param_annotation,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ if !unused_elements.is_empty() {
+ response.headers_mut().insert(
+ HeaderName::from_static("warning"),
+ HeaderValue::from_str(format!("Ignoring unknown fields in body: {:?}", unused_elements).as_str())
+ .expect("Unable to create Warning header value"));
+ }
+
+ match result {
+ Ok(rsp) => match rsp {
+ CreateEditgroupAnnotationResponse::Created
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(201).expect("Unable to turn 201 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_EDITGROUP_ANNOTATION_CREATED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateEditgroupAnnotationResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_EDITGROUP_ANNOTATION_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateEditgroupAnnotationResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_EDITGROUP_ANNOTATION_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateEditgroupAnnotationResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_EDITGROUP_ANNOTATION_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateEditgroupAnnotationResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_EDITGROUP_ANNOTATION_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateEditgroupAnnotationResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_EDITGROUP_ANNOTATION_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ },
+ Err(e) => Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't read body parameter annotation: {}", e)))
+ .expect("Unable to create Bad Request response due to unable to read body parameter annotation"))),
+ }
+ })
+ ) as Self::Future
+ }
+
+ // CreateFile - POST /editgroup/{editgroup_id}/file
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILE) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_EDITGROUP_EDITGROUP_ID_FILE
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_FILE in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_FILE.as_str())
+ );
+
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
+ Ok(param_editgroup_id) => param_editgroup_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // 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.
+ Box::new(body.concat2()
+ .then(move |result| -> Self::Future {
+ match result {
+ Ok(body) => {
+ let mut unused_elements = Vec::new();
+ let param_entity: Option<models::FileEntity> = if !body.is_empty() {
+ let deserializer = &mut serde_json::Deserializer::from_slice(&*body);
+ match serde_ignored::deserialize(deserializer, |path| {
+ warn!("Ignoring unknown field in body: {}", path);
+ unused_elements.push(path.to_string());
+ }) {
+ Ok(param_entity) => param_entity,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse body parameter entity - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid body parameter entity due to schema"))),
+ }
+ } else {
+ None
+ };
+ let param_entity = match param_entity {
+ Some(param_entity) => param_entity,
+ None => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from("Missing required body parameter entity"))
+ .expect("Unable to create Bad Request response for missing body parameter entity"))),
+ };
+
+ Box::new(
+ api_impl.create_file(
+ param_editgroup_id,
+ param_entity,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ if !unused_elements.is_empty() {
+ response.headers_mut().insert(
+ HeaderName::from_static("warning"),
+ HeaderValue::from_str(format!("Ignoring unknown fields in body: {:?}", unused_elements).as_str())
+ .expect("Unable to create Warning header value"));
+ }
+
+ match result {
+ Ok(rsp) => match rsp {
+ CreateFileResponse::CreatedEntity
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(201).expect("Unable to turn 201 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_FILE_CREATED_ENTITY"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateFileResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_FILE_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateFileResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_FILE_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateFileResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_FILE_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateFileResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_FILE_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateFileResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_FILE_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ },
+ Err(e) => Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't read body parameter entity: {}", e)))
+ .expect("Unable to create Bad Request response due to unable to read body parameter entity"))),
+ }
+ })
+ ) as Self::Future
+ }
+
+ // CreateFileAutoBatch - POST /editgroup/auto/file/batch
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_AUTO_FILE_BATCH) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // 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.
+ Box::new(body.concat2()
+ .then(move |result| -> Self::Future {
+ match result {
+ Ok(body) => {
+ let mut unused_elements = Vec::new();
+ let param_auto_batch: Option<models::FileAutoBatch> = if !body.is_empty() {
+ let deserializer = &mut serde_json::Deserializer::from_slice(&*body);
+ match serde_ignored::deserialize(deserializer, |path| {
+ warn!("Ignoring unknown field in body: {}", path);
+ unused_elements.push(path.to_string());
+ }) {
+ Ok(param_auto_batch) => param_auto_batch,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse body parameter auto_batch - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid body parameter auto_batch due to schema"))),
+ }
+ } else {
+ None
+ };
+ let param_auto_batch = match param_auto_batch {
+ Some(param_auto_batch) => param_auto_batch,
+ None => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from("Missing required body parameter auto_batch"))
+ .expect("Unable to create Bad Request response for missing body parameter auto_batch"))),
+ };
+
+ Box::new(
+ api_impl.create_file_auto_batch(
+ param_auto_batch,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ if !unused_elements.is_empty() {
+ response.headers_mut().insert(
+ HeaderName::from_static("warning"),
+ HeaderValue::from_str(format!("Ignoring unknown fields in body: {:?}", unused_elements).as_str())
+ .expect("Unable to create Warning header value"));
+ }
+
+ match result {
+ Ok(rsp) => match rsp {
+ CreateFileAutoBatchResponse::CreatedEditgroup
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(201).expect("Unable to turn 201 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_FILE_AUTO_BATCH_CREATED_EDITGROUP"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateFileAutoBatchResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_FILE_AUTO_BATCH_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateFileAutoBatchResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_FILE_AUTO_BATCH_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateFileAutoBatchResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_FILE_AUTO_BATCH_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateFileAutoBatchResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_FILE_AUTO_BATCH_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateFileAutoBatchResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_FILE_AUTO_BATCH_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ },
+ Err(e) => Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't read body parameter auto_batch: {}", e)))
+ .expect("Unable to create Bad Request response due to unable to read body parameter auto_batch"))),
+ }
+ })
+ ) as Self::Future
+ }
+
+ // CreateFileset - POST /editgroup/{editgroup_id}/fileset
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILESET) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_EDITGROUP_EDITGROUP_ID_FILESET
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_FILESET in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_FILESET.as_str())
+ );
+
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
+ Ok(param_editgroup_id) => param_editgroup_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // 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.
+ Box::new(body.concat2()
+ .then(move |result| -> Self::Future {
+ match result {
+ Ok(body) => {
+ let mut unused_elements = Vec::new();
+ let param_entity: Option<models::FilesetEntity> = if !body.is_empty() {
+ let deserializer = &mut serde_json::Deserializer::from_slice(&*body);
+ match serde_ignored::deserialize(deserializer, |path| {
+ warn!("Ignoring unknown field in body: {}", path);
+ unused_elements.push(path.to_string());
+ }) {
+ Ok(param_entity) => param_entity,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse body parameter entity - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid body parameter entity due to schema"))),
+ }
+ } else {
+ None
+ };
+ let param_entity = match param_entity {
+ Some(param_entity) => param_entity,
+ None => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from("Missing required body parameter entity"))
+ .expect("Unable to create Bad Request response for missing body parameter entity"))),
+ };
+
+ Box::new(
+ api_impl.create_fileset(
+ param_editgroup_id,
+ param_entity,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ if !unused_elements.is_empty() {
+ response.headers_mut().insert(
+ HeaderName::from_static("warning"),
+ HeaderValue::from_str(format!("Ignoring unknown fields in body: {:?}", unused_elements).as_str())
+ .expect("Unable to create Warning header value"));
+ }
+
+ match result {
+ Ok(rsp) => match rsp {
+ CreateFilesetResponse::CreatedEntity
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(201).expect("Unable to turn 201 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_FILESET_CREATED_ENTITY"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateFilesetResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_FILESET_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateFilesetResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_FILESET_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateFilesetResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_FILESET_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateFilesetResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_FILESET_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateFilesetResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_FILESET_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ },
+ Err(e) => Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't read body parameter entity: {}", e)))
+ .expect("Unable to create Bad Request response due to unable to read body parameter entity"))),
+ }
+ })
+ ) as Self::Future
+ }
+
+ // CreateFilesetAutoBatch - POST /editgroup/auto/fileset/batch
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_AUTO_FILESET_BATCH) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // 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.
+ Box::new(body.concat2()
+ .then(move |result| -> Self::Future {
+ match result {
+ Ok(body) => {
+ let mut unused_elements = Vec::new();
+ let param_auto_batch: Option<models::FilesetAutoBatch> = if !body.is_empty() {
+ let deserializer = &mut serde_json::Deserializer::from_slice(&*body);
+ match serde_ignored::deserialize(deserializer, |path| {
+ warn!("Ignoring unknown field in body: {}", path);
+ unused_elements.push(path.to_string());
+ }) {
+ Ok(param_auto_batch) => param_auto_batch,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse body parameter auto_batch - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid body parameter auto_batch due to schema"))),
+ }
+ } else {
+ None
+ };
+ let param_auto_batch = match param_auto_batch {
+ Some(param_auto_batch) => param_auto_batch,
+ None => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from("Missing required body parameter auto_batch"))
+ .expect("Unable to create Bad Request response for missing body parameter auto_batch"))),
+ };
+
+ Box::new(
+ api_impl.create_fileset_auto_batch(
+ param_auto_batch,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ if !unused_elements.is_empty() {
+ response.headers_mut().insert(
+ HeaderName::from_static("warning"),
+ HeaderValue::from_str(format!("Ignoring unknown fields in body: {:?}", unused_elements).as_str())
+ .expect("Unable to create Warning header value"));
+ }
+
+ match result {
+ Ok(rsp) => match rsp {
+ CreateFilesetAutoBatchResponse::CreatedEditgroup
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(201).expect("Unable to turn 201 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_FILESET_AUTO_BATCH_CREATED_EDITGROUP"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateFilesetAutoBatchResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_FILESET_AUTO_BATCH_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateFilesetAutoBatchResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_FILESET_AUTO_BATCH_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateFilesetAutoBatchResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_FILESET_AUTO_BATCH_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateFilesetAutoBatchResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_FILESET_AUTO_BATCH_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateFilesetAutoBatchResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_FILESET_AUTO_BATCH_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ },
+ Err(e) => Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't read body parameter auto_batch: {}", e)))
+ .expect("Unable to create Bad Request response due to unable to read body parameter auto_batch"))),
+ }
+ })
+ ) as Self::Future
+ }
+
+ // CreateRelease - POST /editgroup/{editgroup_id}/release
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_RELEASE) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_EDITGROUP_EDITGROUP_ID_RELEASE
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_RELEASE in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_RELEASE.as_str())
+ );
+
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
+ Ok(param_editgroup_id) => param_editgroup_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // 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.
+ Box::new(body.concat2()
+ .then(move |result| -> Self::Future {
+ match result {
+ Ok(body) => {
+ let mut unused_elements = Vec::new();
+ let param_entity: Option<models::ReleaseEntity> = if !body.is_empty() {
+ let deserializer = &mut serde_json::Deserializer::from_slice(&*body);
+ match serde_ignored::deserialize(deserializer, |path| {
+ warn!("Ignoring unknown field in body: {}", path);
+ unused_elements.push(path.to_string());
+ }) {
+ Ok(param_entity) => param_entity,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse body parameter entity - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid body parameter entity due to schema"))),
+ }
+ } else {
+ None
+ };
+ let param_entity = match param_entity {
+ Some(param_entity) => param_entity,
+ None => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from("Missing required body parameter entity"))
+ .expect("Unable to create Bad Request response for missing body parameter entity"))),
+ };
+
+ Box::new(
+ api_impl.create_release(
+ param_editgroup_id,
+ param_entity,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ if !unused_elements.is_empty() {
+ response.headers_mut().insert(
+ HeaderName::from_static("warning"),
+ HeaderValue::from_str(format!("Ignoring unknown fields in body: {:?}", unused_elements).as_str())
+ .expect("Unable to create Warning header value"));
+ }
+
+ match result {
+ Ok(rsp) => match rsp {
+ CreateReleaseResponse::CreatedEntity
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(201).expect("Unable to turn 201 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_RELEASE_CREATED_ENTITY"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateReleaseResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_RELEASE_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateReleaseResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_RELEASE_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateReleaseResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_RELEASE_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateReleaseResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_RELEASE_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateReleaseResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_RELEASE_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ },
+ Err(e) => Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't read body parameter entity: {}", e)))
+ .expect("Unable to create Bad Request response due to unable to read body parameter entity"))),
+ }
+ })
+ ) as Self::Future
+ }
+
+ // CreateReleaseAutoBatch - POST /editgroup/auto/release/batch
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_AUTO_RELEASE_BATCH) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // 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.
+ Box::new(body.concat2()
+ .then(move |result| -> Self::Future {
+ match result {
+ Ok(body) => {
+ let mut unused_elements = Vec::new();
+ let param_auto_batch: Option<models::ReleaseAutoBatch> = if !body.is_empty() {
+ let deserializer = &mut serde_json::Deserializer::from_slice(&*body);
+ match serde_ignored::deserialize(deserializer, |path| {
+ warn!("Ignoring unknown field in body: {}", path);
+ unused_elements.push(path.to_string());
+ }) {
+ Ok(param_auto_batch) => param_auto_batch,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse body parameter auto_batch - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid body parameter auto_batch due to schema"))),
+ }
+ } else {
+ None
+ };
+ let param_auto_batch = match param_auto_batch {
+ Some(param_auto_batch) => param_auto_batch,
+ None => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from("Missing required body parameter auto_batch"))
+ .expect("Unable to create Bad Request response for missing body parameter auto_batch"))),
+ };
+
+ Box::new(
+ api_impl.create_release_auto_batch(
+ param_auto_batch,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ if !unused_elements.is_empty() {
+ response.headers_mut().insert(
+ HeaderName::from_static("warning"),
+ HeaderValue::from_str(format!("Ignoring unknown fields in body: {:?}", unused_elements).as_str())
+ .expect("Unable to create Warning header value"));
+ }
+
+ match result {
+ Ok(rsp) => match rsp {
+ CreateReleaseAutoBatchResponse::CreatedEditgroup
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(201).expect("Unable to turn 201 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_RELEASE_AUTO_BATCH_CREATED_EDITGROUP"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateReleaseAutoBatchResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_RELEASE_AUTO_BATCH_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateReleaseAutoBatchResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_RELEASE_AUTO_BATCH_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateReleaseAutoBatchResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_RELEASE_AUTO_BATCH_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateReleaseAutoBatchResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_RELEASE_AUTO_BATCH_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateReleaseAutoBatchResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_RELEASE_AUTO_BATCH_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ },
+ Err(e) => Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't read body parameter auto_batch: {}", e)))
+ .expect("Unable to create Bad Request response due to unable to read body parameter auto_batch"))),
+ }
+ })
+ ) as Self::Future
+ }
+
+ // CreateWebcapture - POST /editgroup/{editgroup_id}/webcapture
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WEBCAPTURE) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_EDITGROUP_EDITGROUP_ID_WEBCAPTURE
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_WEBCAPTURE in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_WEBCAPTURE.as_str())
+ );
+
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
+ Ok(param_editgroup_id) => param_editgroup_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // 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.
+ Box::new(body.concat2()
+ .then(move |result| -> Self::Future {
+ match result {
+ Ok(body) => {
+ let mut unused_elements = Vec::new();
+ let param_entity: Option<models::WebcaptureEntity> = if !body.is_empty() {
+ let deserializer = &mut serde_json::Deserializer::from_slice(&*body);
+ match serde_ignored::deserialize(deserializer, |path| {
+ warn!("Ignoring unknown field in body: {}", path);
+ unused_elements.push(path.to_string());
+ }) {
+ Ok(param_entity) => param_entity,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse body parameter entity - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid body parameter entity due to schema"))),
+ }
+ } else {
+ None
+ };
+ let param_entity = match param_entity {
+ Some(param_entity) => param_entity,
+ None => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from("Missing required body parameter entity"))
+ .expect("Unable to create Bad Request response for missing body parameter entity"))),
+ };
+
+ Box::new(
+ api_impl.create_webcapture(
+ param_editgroup_id,
+ param_entity,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ if !unused_elements.is_empty() {
+ response.headers_mut().insert(
+ HeaderName::from_static("warning"),
+ HeaderValue::from_str(format!("Ignoring unknown fields in body: {:?}", unused_elements).as_str())
+ .expect("Unable to create Warning header value"));
+ }
+
+ match result {
+ Ok(rsp) => match rsp {
+ CreateWebcaptureResponse::CreatedEntity
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(201).expect("Unable to turn 201 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_WEBCAPTURE_CREATED_ENTITY"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateWebcaptureResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_WEBCAPTURE_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateWebcaptureResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_WEBCAPTURE_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateWebcaptureResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_WEBCAPTURE_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateWebcaptureResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_WEBCAPTURE_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateWebcaptureResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_WEBCAPTURE_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ },
+ Err(e) => Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't read body parameter entity: {}", e)))
+ .expect("Unable to create Bad Request response due to unable to read body parameter entity"))),
+ }
+ })
+ ) as Self::Future
+ }
+
+ // CreateWebcaptureAutoBatch - POST /editgroup/auto/webcapture/batch
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_AUTO_WEBCAPTURE_BATCH) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // 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.
+ Box::new(body.concat2()
+ .then(move |result| -> Self::Future {
+ match result {
+ Ok(body) => {
+ let mut unused_elements = Vec::new();
+ let param_auto_batch: Option<models::WebcaptureAutoBatch> = if !body.is_empty() {
+ let deserializer = &mut serde_json::Deserializer::from_slice(&*body);
+ match serde_ignored::deserialize(deserializer, |path| {
+ warn!("Ignoring unknown field in body: {}", path);
+ unused_elements.push(path.to_string());
+ }) {
+ Ok(param_auto_batch) => param_auto_batch,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse body parameter auto_batch - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid body parameter auto_batch due to schema"))),
+ }
+ } else {
+ None
+ };
+ let param_auto_batch = match param_auto_batch {
+ Some(param_auto_batch) => param_auto_batch,
+ None => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from("Missing required body parameter auto_batch"))
+ .expect("Unable to create Bad Request response for missing body parameter auto_batch"))),
+ };
+
+ Box::new(
+ api_impl.create_webcapture_auto_batch(
+ param_auto_batch,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ if !unused_elements.is_empty() {
+ response.headers_mut().insert(
+ HeaderName::from_static("warning"),
+ HeaderValue::from_str(format!("Ignoring unknown fields in body: {:?}", unused_elements).as_str())
+ .expect("Unable to create Warning header value"));
+ }
+
+ match result {
+ Ok(rsp) => match rsp {
+ CreateWebcaptureAutoBatchResponse::CreatedEditgroup
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(201).expect("Unable to turn 201 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_WEBCAPTURE_AUTO_BATCH_CREATED_EDITGROUP"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateWebcaptureAutoBatchResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_WEBCAPTURE_AUTO_BATCH_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateWebcaptureAutoBatchResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_WEBCAPTURE_AUTO_BATCH_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateWebcaptureAutoBatchResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_WEBCAPTURE_AUTO_BATCH_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateWebcaptureAutoBatchResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_WEBCAPTURE_AUTO_BATCH_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateWebcaptureAutoBatchResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_WEBCAPTURE_AUTO_BATCH_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ },
+ Err(e) => Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't read body parameter auto_batch: {}", e)))
+ .expect("Unable to create Bad Request response due to unable to read body parameter auto_batch"))),
+ }
+ })
+ ) as Self::Future
+ }
+
+ // CreateWork - POST /editgroup/{editgroup_id}/work
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WORK) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_EDITGROUP_EDITGROUP_ID_WORK
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_WORK in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_WORK.as_str())
+ );
+
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
+ Ok(param_editgroup_id) => param_editgroup_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // 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.
+ Box::new(body.concat2()
+ .then(move |result| -> Self::Future {
+ match result {
+ Ok(body) => {
+ let mut unused_elements = Vec::new();
+ let param_entity: Option<models::WorkEntity> = if !body.is_empty() {
+ let deserializer = &mut serde_json::Deserializer::from_slice(&*body);
+ match serde_ignored::deserialize(deserializer, |path| {
+ warn!("Ignoring unknown field in body: {}", path);
+ unused_elements.push(path.to_string());
+ }) {
+ Ok(param_entity) => param_entity,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse body parameter entity - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid body parameter entity due to schema"))),
+ }
+ } else {
+ None
+ };
+ let param_entity = match param_entity {
+ Some(param_entity) => param_entity,
+ None => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from("Missing required body parameter entity"))
+ .expect("Unable to create Bad Request response for missing body parameter entity"))),
+ };
+
+ Box::new(
+ api_impl.create_work(
+ param_editgroup_id,
+ param_entity,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ if !unused_elements.is_empty() {
+ response.headers_mut().insert(
+ HeaderName::from_static("warning"),
+ HeaderValue::from_str(format!("Ignoring unknown fields in body: {:?}", unused_elements).as_str())
+ .expect("Unable to create Warning header value"));
+ }
+
+ match result {
+ Ok(rsp) => match rsp {
+ CreateWorkResponse::CreatedEntity
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(201).expect("Unable to turn 201 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_WORK_CREATED_ENTITY"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateWorkResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_WORK_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateWorkResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_WORK_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateWorkResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_WORK_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateWorkResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_WORK_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateWorkResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_WORK_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ },
+ Err(e) => Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't read body parameter entity: {}", e)))
+ .expect("Unable to create Bad Request response due to unable to read body parameter entity"))),
+ }
+ })
+ ) as Self::Future
+ }
+
+ // CreateWorkAutoBatch - POST /editgroup/auto/work/batch
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_AUTO_WORK_BATCH) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // 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.
+ Box::new(body.concat2()
+ .then(move |result| -> Self::Future {
+ match result {
+ Ok(body) => {
+ let mut unused_elements = Vec::new();
+ let param_auto_batch: Option<models::WorkAutoBatch> = if !body.is_empty() {
+ let deserializer = &mut serde_json::Deserializer::from_slice(&*body);
+ match serde_ignored::deserialize(deserializer, |path| {
+ warn!("Ignoring unknown field in body: {}", path);
+ unused_elements.push(path.to_string());
+ }) {
+ Ok(param_auto_batch) => param_auto_batch,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse body parameter auto_batch - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid body parameter auto_batch due to schema"))),
+ }
+ } else {
+ None
+ };
+ let param_auto_batch = match param_auto_batch {
+ Some(param_auto_batch) => param_auto_batch,
+ None => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from("Missing required body parameter auto_batch"))
+ .expect("Unable to create Bad Request response for missing body parameter auto_batch"))),
+ };
+
+ Box::new(
+ api_impl.create_work_auto_batch(
+ param_auto_batch,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ if !unused_elements.is_empty() {
+ response.headers_mut().insert(
+ HeaderName::from_static("warning"),
+ HeaderValue::from_str(format!("Ignoring unknown fields in body: {:?}", unused_elements).as_str())
+ .expect("Unable to create Warning header value"));
+ }
+
+ match result {
+ Ok(rsp) => match rsp {
+ CreateWorkAutoBatchResponse::CreatedEditgroup
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(201).expect("Unable to turn 201 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_WORK_AUTO_BATCH_CREATED_EDITGROUP"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateWorkAutoBatchResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_WORK_AUTO_BATCH_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateWorkAutoBatchResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_WORK_AUTO_BATCH_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateWorkAutoBatchResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_WORK_AUTO_BATCH_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateWorkAutoBatchResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_WORK_AUTO_BATCH_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ CreateWorkAutoBatchResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for CREATE_WORK_AUTO_BATCH_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ },
+ Err(e) => Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't read body parameter auto_batch: {}", e)))
+ .expect("Unable to create Bad Request response due to unable to read body parameter auto_batch"))),
+ }
+ })
+ ) as Self::Future
+ }
+
+ // DeleteContainer - DELETE /editgroup/{editgroup_id}/container/{ident}
+ &hyper::Method::DELETE
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CONTAINER_IDENT) =>
+ {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_EDITGROUP_EDITGROUP_ID_CONTAINER_IDENT
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_CONTAINER_IDENT in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_CONTAINER_IDENT.as_str())
+ );
+
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
+ Ok(param_editgroup_id) => param_editgroup_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(param_ident) => match param_ident.parse::<String>() {
+ Ok(param_ident) => param_ident,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.delete_container(
+ param_editgroup_id,
+ param_ident,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ DeleteContainerResponse::DeletedEntity
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_CONTAINER_DELETED_ENTITY"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteContainerResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_CONTAINER_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteContainerResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_CONTAINER_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteContainerResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_CONTAINER_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteContainerResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_CONTAINER_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteContainerResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_CONTAINER_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // DeleteContainerEdit - DELETE /editgroup/{editgroup_id}/container/edit/{edit_id}
+ &hyper::Method::DELETE
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CONTAINER_EDIT_EDIT_ID) =>
+ {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_EDITGROUP_EDITGROUP_ID_CONTAINER_EDIT_EDIT_ID
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_CONTAINER_EDIT_EDIT_ID in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_CONTAINER_EDIT_EDIT_ID.as_str())
+ );
+
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
+ Ok(param_editgroup_id) => param_editgroup_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
+ Ok(param_edit_id) => match param_edit_id.parse::<String>() {
+ Ok(param_edit_id) => param_edit_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter edit_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["edit_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.delete_container_edit(
+ param_editgroup_id,
+ param_edit_id,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ DeleteContainerEditResponse::DeletedEdit
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_CONTAINER_EDIT_DELETED_EDIT"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteContainerEditResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_CONTAINER_EDIT_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteContainerEditResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_CONTAINER_EDIT_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteContainerEditResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_CONTAINER_EDIT_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteContainerEditResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_CONTAINER_EDIT_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteContainerEditResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_CONTAINER_EDIT_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // DeleteCreator - DELETE /editgroup/{editgroup_id}/creator/{ident}
+ &hyper::Method::DELETE
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CREATOR_IDENT) =>
+ {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_EDITGROUP_EDITGROUP_ID_CREATOR_IDENT
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_CREATOR_IDENT in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_CREATOR_IDENT.as_str())
+ );
+
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
+ Ok(param_editgroup_id) => param_editgroup_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(param_ident) => match param_ident.parse::<String>() {
+ Ok(param_ident) => param_ident,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.delete_creator(
+ param_editgroup_id,
+ param_ident,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ DeleteCreatorResponse::DeletedEntity
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_CREATOR_DELETED_ENTITY"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteCreatorResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_CREATOR_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteCreatorResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_CREATOR_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteCreatorResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_CREATOR_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteCreatorResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_CREATOR_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteCreatorResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_CREATOR_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // DeleteCreatorEdit - DELETE /editgroup/{editgroup_id}/creator/edit/{edit_id}
+ &hyper::Method::DELETE
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CREATOR_EDIT_EDIT_ID) =>
+ {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_EDITGROUP_EDITGROUP_ID_CREATOR_EDIT_EDIT_ID
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_CREATOR_EDIT_EDIT_ID in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_CREATOR_EDIT_EDIT_ID.as_str())
+ );
+
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
+ Ok(param_editgroup_id) => param_editgroup_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
+ Ok(param_edit_id) => match param_edit_id.parse::<String>() {
+ Ok(param_edit_id) => param_edit_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter edit_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["edit_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.delete_creator_edit(
+ param_editgroup_id,
+ param_edit_id,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ DeleteCreatorEditResponse::DeletedEdit
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_CREATOR_EDIT_DELETED_EDIT"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteCreatorEditResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_CREATOR_EDIT_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteCreatorEditResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_CREATOR_EDIT_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteCreatorEditResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_CREATOR_EDIT_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteCreatorEditResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_CREATOR_EDIT_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteCreatorEditResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_CREATOR_EDIT_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // DeleteFile - DELETE /editgroup/{editgroup_id}/file/{ident}
+ &hyper::Method::DELETE if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILE_IDENT) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_EDITGROUP_EDITGROUP_ID_FILE_IDENT
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_FILE_IDENT in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_FILE_IDENT.as_str())
+ );
+
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
+ Ok(param_editgroup_id) => param_editgroup_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(param_ident) => match param_ident.parse::<String>() {
+ Ok(param_ident) => param_ident,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.delete_file(
+ param_editgroup_id,
+ param_ident,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ DeleteFileResponse::DeletedEntity
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_FILE_DELETED_ENTITY"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteFileResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_FILE_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteFileResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_FILE_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteFileResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_FILE_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteFileResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_FILE_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteFileResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_FILE_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // DeleteFileEdit - DELETE /editgroup/{editgroup_id}/file/edit/{edit_id}
+ &hyper::Method::DELETE
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILE_EDIT_EDIT_ID) =>
+ {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_EDITGROUP_EDITGROUP_ID_FILE_EDIT_EDIT_ID
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_FILE_EDIT_EDIT_ID in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_FILE_EDIT_EDIT_ID.as_str())
+ );
+
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
+ Ok(param_editgroup_id) => param_editgroup_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
+ Ok(param_edit_id) => match param_edit_id.parse::<String>() {
+ Ok(param_edit_id) => param_edit_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter edit_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["edit_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.delete_file_edit(
+ param_editgroup_id,
+ param_edit_id,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ DeleteFileEditResponse::DeletedEdit
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_FILE_EDIT_DELETED_EDIT"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteFileEditResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_FILE_EDIT_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteFileEditResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_FILE_EDIT_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteFileEditResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_FILE_EDIT_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteFileEditResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_FILE_EDIT_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteFileEditResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_FILE_EDIT_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // DeleteFileset - DELETE /editgroup/{editgroup_id}/fileset/{ident}
+ &hyper::Method::DELETE
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILESET_IDENT) =>
+ {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_EDITGROUP_EDITGROUP_ID_FILESET_IDENT
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_FILESET_IDENT in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_FILESET_IDENT.as_str())
+ );
+
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
+ Ok(param_editgroup_id) => param_editgroup_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(param_ident) => match param_ident.parse::<String>() {
+ Ok(param_ident) => param_ident,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.delete_fileset(
+ param_editgroup_id,
+ param_ident,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ DeleteFilesetResponse::DeletedEntity
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_FILESET_DELETED_ENTITY"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteFilesetResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_FILESET_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteFilesetResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_FILESET_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteFilesetResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_FILESET_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteFilesetResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_FILESET_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteFilesetResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_FILESET_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // DeleteFilesetEdit - DELETE /editgroup/{editgroup_id}/fileset/edit/{edit_id}
+ &hyper::Method::DELETE
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILESET_EDIT_EDIT_ID) =>
+ {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_EDITGROUP_EDITGROUP_ID_FILESET_EDIT_EDIT_ID
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_FILESET_EDIT_EDIT_ID in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_FILESET_EDIT_EDIT_ID.as_str())
+ );
+
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
+ Ok(param_editgroup_id) => param_editgroup_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
+ Ok(param_edit_id) => match param_edit_id.parse::<String>() {
+ Ok(param_edit_id) => param_edit_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter edit_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["edit_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.delete_fileset_edit(
+ param_editgroup_id,
+ param_edit_id,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ DeleteFilesetEditResponse::DeletedEdit
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_FILESET_EDIT_DELETED_EDIT"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteFilesetEditResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_FILESET_EDIT_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteFilesetEditResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_FILESET_EDIT_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteFilesetEditResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_FILESET_EDIT_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteFilesetEditResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_FILESET_EDIT_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteFilesetEditResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_FILESET_EDIT_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // DeleteRelease - DELETE /editgroup/{editgroup_id}/release/{ident}
+ &hyper::Method::DELETE
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_RELEASE_IDENT) =>
+ {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_EDITGROUP_EDITGROUP_ID_RELEASE_IDENT
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_RELEASE_IDENT in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_RELEASE_IDENT.as_str())
+ );
+
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
+ Ok(param_editgroup_id) => param_editgroup_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(param_ident) => match param_ident.parse::<String>() {
+ Ok(param_ident) => param_ident,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.delete_release(
+ param_editgroup_id,
+ param_ident,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ DeleteReleaseResponse::DeletedEntity
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_RELEASE_DELETED_ENTITY"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteReleaseResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_RELEASE_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteReleaseResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_RELEASE_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteReleaseResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_RELEASE_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteReleaseResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_RELEASE_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteReleaseResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_RELEASE_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // DeleteReleaseEdit - DELETE /editgroup/{editgroup_id}/release/edit/{edit_id}
+ &hyper::Method::DELETE
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_RELEASE_EDIT_EDIT_ID) =>
+ {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_EDITGROUP_EDITGROUP_ID_RELEASE_EDIT_EDIT_ID
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_RELEASE_EDIT_EDIT_ID in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_RELEASE_EDIT_EDIT_ID.as_str())
+ );
+
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
+ Ok(param_editgroup_id) => param_editgroup_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
+ Ok(param_edit_id) => match param_edit_id.parse::<String>() {
+ Ok(param_edit_id) => param_edit_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter edit_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["edit_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.delete_release_edit(
+ param_editgroup_id,
+ param_edit_id,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ DeleteReleaseEditResponse::DeletedEdit
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_RELEASE_EDIT_DELETED_EDIT"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteReleaseEditResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_RELEASE_EDIT_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteReleaseEditResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_RELEASE_EDIT_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteReleaseEditResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_RELEASE_EDIT_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteReleaseEditResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_RELEASE_EDIT_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteReleaseEditResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_RELEASE_EDIT_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // DeleteWebcapture - DELETE /editgroup/{editgroup_id}/webcapture/{ident}
+ &hyper::Method::DELETE
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WEBCAPTURE_IDENT) =>
+ {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_EDITGROUP_EDITGROUP_ID_WEBCAPTURE_IDENT
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_WEBCAPTURE_IDENT in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_WEBCAPTURE_IDENT.as_str())
+ );
+
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
+ Ok(param_editgroup_id) => param_editgroup_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(param_ident) => match param_ident.parse::<String>() {
+ Ok(param_ident) => param_ident,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.delete_webcapture(
+ param_editgroup_id,
+ param_ident,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ DeleteWebcaptureResponse::DeletedEntity
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_WEBCAPTURE_DELETED_ENTITY"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteWebcaptureResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_WEBCAPTURE_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteWebcaptureResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_WEBCAPTURE_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteWebcaptureResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_WEBCAPTURE_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteWebcaptureResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_WEBCAPTURE_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteWebcaptureResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_WEBCAPTURE_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // DeleteWebcaptureEdit - DELETE /editgroup/{editgroup_id}/webcapture/edit/{edit_id}
+ &hyper::Method::DELETE
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WEBCAPTURE_EDIT_EDIT_ID) =>
+ {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_EDITGROUP_EDITGROUP_ID_WEBCAPTURE_EDIT_EDIT_ID
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_WEBCAPTURE_EDIT_EDIT_ID in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_WEBCAPTURE_EDIT_EDIT_ID.as_str())
+ );
+
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
+ Ok(param_editgroup_id) => param_editgroup_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
+ Ok(param_edit_id) => match param_edit_id.parse::<String>() {
+ Ok(param_edit_id) => param_edit_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter edit_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["edit_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.delete_webcapture_edit(
+ param_editgroup_id,
+ param_edit_id,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ DeleteWebcaptureEditResponse::DeletedEdit
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_WEBCAPTURE_EDIT_DELETED_EDIT"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteWebcaptureEditResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_WEBCAPTURE_EDIT_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteWebcaptureEditResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_WEBCAPTURE_EDIT_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteWebcaptureEditResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_WEBCAPTURE_EDIT_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteWebcaptureEditResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_WEBCAPTURE_EDIT_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteWebcaptureEditResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_WEBCAPTURE_EDIT_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // DeleteWork - DELETE /editgroup/{editgroup_id}/work/{ident}
+ &hyper::Method::DELETE if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WORK_IDENT) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_EDITGROUP_EDITGROUP_ID_WORK_IDENT
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_WORK_IDENT in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_WORK_IDENT.as_str())
+ );
+
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
+ Ok(param_editgroup_id) => param_editgroup_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(param_ident) => match param_ident.parse::<String>() {
+ Ok(param_ident) => param_ident,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.delete_work(
+ param_editgroup_id,
+ param_ident,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ DeleteWorkResponse::DeletedEntity
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_WORK_DELETED_ENTITY"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteWorkResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_WORK_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteWorkResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_WORK_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteWorkResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_WORK_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteWorkResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_WORK_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteWorkResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_WORK_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // DeleteWorkEdit - DELETE /editgroup/{editgroup_id}/work/edit/{edit_id}
+ &hyper::Method::DELETE
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WORK_EDIT_EDIT_ID) =>
+ {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_EDITGROUP_EDITGROUP_ID_WORK_EDIT_EDIT_ID
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_WORK_EDIT_EDIT_ID in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_WORK_EDIT_EDIT_ID.as_str())
+ );
+
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
+ Ok(param_editgroup_id) => param_editgroup_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
+ Ok(param_edit_id) => match param_edit_id.parse::<String>() {
+ Ok(param_edit_id) => param_edit_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter edit_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["edit_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.delete_work_edit(
+ param_editgroup_id,
+ param_edit_id,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ DeleteWorkEditResponse::DeletedEdit
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_WORK_EDIT_DELETED_EDIT"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteWorkEditResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_WORK_EDIT_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteWorkEditResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_WORK_EDIT_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteWorkEditResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_WORK_EDIT_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteWorkEditResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_WORK_EDIT_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ DeleteWorkEditResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for DELETE_WORK_EDIT_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetChangelog - GET /changelog
+ &hyper::Method::GET if path.matched(paths::ID_CHANGELOG) => {
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_limit = query_params
+ .iter()
+ .filter(|e| e.0 == "limit")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_limit = param_limit.and_then(|param_limit| param_limit.parse().ok());
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_changelog(
+ param_limit,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetChangelogResponse::Success
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CHANGELOG_SUCCESS"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetChangelogResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CHANGELOG_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetChangelogResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CHANGELOG_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetChangelogEntry - GET /changelog/{index}
+ &hyper::Method::GET if path.matched(paths::ID_CHANGELOG_INDEX) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_CHANGELOG_INDEX
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE CHANGELOG_INDEX in set but failed match against \"{}\"", path, paths::REGEX_CHANGELOG_INDEX.as_str())
+ );
+
+ let param_index = match percent_encoding::percent_decode(path_params["index"].as_bytes()).decode_utf8() {
+ Ok(param_index) => match param_index.parse::<i64>() {
+ Ok(param_index) => param_index,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter index: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["index"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_changelog_entry(
+ param_index,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetChangelogEntryResponse::FoundChangelogEntry
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CHANGELOG_ENTRY_FOUND_CHANGELOG_ENTRY"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetChangelogEntryResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CHANGELOG_ENTRY_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetChangelogEntryResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CHANGELOG_ENTRY_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetChangelogEntryResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CHANGELOG_ENTRY_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetContainer - GET /container/{ident}
+ &hyper::Method::GET if path.matched(paths::ID_CONTAINER_IDENT) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_CONTAINER_IDENT
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE CONTAINER_IDENT in set but failed match against \"{}\"", path, paths::REGEX_CONTAINER_IDENT.as_str())
+ );
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(param_ident) => match param_ident.parse::<String>() {
+ Ok(param_ident) => param_ident,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_expand = query_params
+ .iter()
+ .filter(|e| e.0 == "expand")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_expand = param_expand.and_then(|param_expand| param_expand.parse().ok());
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_container(
+ param_ident,
+ param_expand,
+ param_hide,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetContainerResponse::FoundEntity
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CONTAINER_FOUND_ENTITY"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetContainerResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CONTAINER_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetContainerResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CONTAINER_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetContainerResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CONTAINER_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetContainerEdit - GET /container/edit/{edit_id}
+ &hyper::Method::GET if path.matched(paths::ID_CONTAINER_EDIT_EDIT_ID) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_CONTAINER_EDIT_EDIT_ID
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE CONTAINER_EDIT_EDIT_ID in set but failed match against \"{}\"", path, paths::REGEX_CONTAINER_EDIT_EDIT_ID.as_str())
+ );
+
+ let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
+ Ok(param_edit_id) => match param_edit_id.parse::<String>() {
+ Ok(param_edit_id) => param_edit_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter edit_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["edit_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_container_edit(
+ param_edit_id,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetContainerEditResponse::FoundEdit
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CONTAINER_EDIT_FOUND_EDIT"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetContainerEditResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CONTAINER_EDIT_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetContainerEditResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CONTAINER_EDIT_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetContainerEditResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CONTAINER_EDIT_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetContainerHistory - GET /container/{ident}/history
+ &hyper::Method::GET if path.matched(paths::ID_CONTAINER_IDENT_HISTORY) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_CONTAINER_IDENT_HISTORY
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE CONTAINER_IDENT_HISTORY in set but failed match against \"{}\"", path, paths::REGEX_CONTAINER_IDENT_HISTORY.as_str())
+ );
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(param_ident) => match param_ident.parse::<String>() {
+ Ok(param_ident) => param_ident,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_limit = query_params
+ .iter()
+ .filter(|e| e.0 == "limit")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_limit = param_limit.and_then(|param_limit| param_limit.parse().ok());
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_container_history(
+ param_ident,
+ param_limit,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetContainerHistoryResponse::FoundEntityHistory
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CONTAINER_HISTORY_FOUND_ENTITY_HISTORY"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetContainerHistoryResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CONTAINER_HISTORY_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetContainerHistoryResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CONTAINER_HISTORY_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetContainerHistoryResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CONTAINER_HISTORY_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetContainerRedirects - GET /container/{ident}/redirects
+ &hyper::Method::GET if path.matched(paths::ID_CONTAINER_IDENT_REDIRECTS) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_CONTAINER_IDENT_REDIRECTS
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE CONTAINER_IDENT_REDIRECTS in set but failed match against \"{}\"", path, paths::REGEX_CONTAINER_IDENT_REDIRECTS.as_str())
+ );
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(param_ident) => match param_ident.parse::<String>() {
+ Ok(param_ident) => param_ident,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_container_redirects(
+ param_ident,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetContainerRedirectsResponse::FoundEntityRedirects
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CONTAINER_REDIRECTS_FOUND_ENTITY_REDIRECTS"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetContainerRedirectsResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CONTAINER_REDIRECTS_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetContainerRedirectsResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CONTAINER_REDIRECTS_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetContainerRedirectsResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CONTAINER_REDIRECTS_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetContainerRevision - GET /container/rev/{rev_id}
+ &hyper::Method::GET if path.matched(paths::ID_CONTAINER_REV_REV_ID) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_CONTAINER_REV_REV_ID
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE CONTAINER_REV_REV_ID in set but failed match against \"{}\"", path, paths::REGEX_CONTAINER_REV_REV_ID.as_str())
+ );
+
+ let param_rev_id = match percent_encoding::percent_decode(path_params["rev_id"].as_bytes()).decode_utf8() {
+ Ok(param_rev_id) => match param_rev_id.parse::<String>() {
+ Ok(param_rev_id) => param_rev_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter rev_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["rev_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_expand = query_params
+ .iter()
+ .filter(|e| e.0 == "expand")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_expand = param_expand.and_then(|param_expand| param_expand.parse().ok());
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_container_revision(
+ param_rev_id,
+ param_expand,
+ param_hide,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetContainerRevisionResponse::FoundEntityRevision
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CONTAINER_REVISION_FOUND_ENTITY_REVISION"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetContainerRevisionResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CONTAINER_REVISION_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetContainerRevisionResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CONTAINER_REVISION_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetContainerRevisionResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CONTAINER_REVISION_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetCreator - GET /creator/{ident}
+ &hyper::Method::GET if path.matched(paths::ID_CREATOR_IDENT) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_CREATOR_IDENT
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE CREATOR_IDENT in set but failed match against \"{}\"", path, paths::REGEX_CREATOR_IDENT.as_str())
+ );
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(param_ident) => match param_ident.parse::<String>() {
+ Ok(param_ident) => param_ident,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_expand = query_params
+ .iter()
+ .filter(|e| e.0 == "expand")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_expand = param_expand.and_then(|param_expand| param_expand.parse().ok());
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_creator(
+ param_ident,
+ param_expand,
+ param_hide,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetCreatorResponse::FoundEntity
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CREATOR_FOUND_ENTITY"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetCreatorResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CREATOR_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetCreatorResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CREATOR_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetCreatorResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CREATOR_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetCreatorEdit - GET /creator/edit/{edit_id}
+ &hyper::Method::GET if path.matched(paths::ID_CREATOR_EDIT_EDIT_ID) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_CREATOR_EDIT_EDIT_ID
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE CREATOR_EDIT_EDIT_ID in set but failed match against \"{}\"", path, paths::REGEX_CREATOR_EDIT_EDIT_ID.as_str())
+ );
+
+ let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
+ Ok(param_edit_id) => match param_edit_id.parse::<String>() {
+ Ok(param_edit_id) => param_edit_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter edit_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["edit_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_creator_edit(
+ param_edit_id,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetCreatorEditResponse::FoundEdit
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CREATOR_EDIT_FOUND_EDIT"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetCreatorEditResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CREATOR_EDIT_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetCreatorEditResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CREATOR_EDIT_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetCreatorEditResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CREATOR_EDIT_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetCreatorHistory - GET /creator/{ident}/history
+ &hyper::Method::GET if path.matched(paths::ID_CREATOR_IDENT_HISTORY) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_CREATOR_IDENT_HISTORY
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE CREATOR_IDENT_HISTORY in set but failed match against \"{}\"", path, paths::REGEX_CREATOR_IDENT_HISTORY.as_str())
+ );
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(param_ident) => match param_ident.parse::<String>() {
+ Ok(param_ident) => param_ident,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_limit = query_params
+ .iter()
+ .filter(|e| e.0 == "limit")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_limit = param_limit.and_then(|param_limit| param_limit.parse().ok());
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_creator_history(
+ param_ident,
+ param_limit,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetCreatorHistoryResponse::FoundEntityHistory
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CREATOR_HISTORY_FOUND_ENTITY_HISTORY"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetCreatorHistoryResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CREATOR_HISTORY_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetCreatorHistoryResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CREATOR_HISTORY_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetCreatorHistoryResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CREATOR_HISTORY_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetCreatorRedirects - GET /creator/{ident}/redirects
+ &hyper::Method::GET if path.matched(paths::ID_CREATOR_IDENT_REDIRECTS) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_CREATOR_IDENT_REDIRECTS
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE CREATOR_IDENT_REDIRECTS in set but failed match against \"{}\"", path, paths::REGEX_CREATOR_IDENT_REDIRECTS.as_str())
+ );
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(param_ident) => match param_ident.parse::<String>() {
+ Ok(param_ident) => param_ident,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_creator_redirects(
+ param_ident,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetCreatorRedirectsResponse::FoundEntityRedirects
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CREATOR_REDIRECTS_FOUND_ENTITY_REDIRECTS"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetCreatorRedirectsResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CREATOR_REDIRECTS_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetCreatorRedirectsResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CREATOR_REDIRECTS_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetCreatorRedirectsResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CREATOR_REDIRECTS_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetCreatorReleases - GET /creator/{ident}/releases
+ &hyper::Method::GET if path.matched(paths::ID_CREATOR_IDENT_RELEASES) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_CREATOR_IDENT_RELEASES
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE CREATOR_IDENT_RELEASES in set but failed match against \"{}\"", path, paths::REGEX_CREATOR_IDENT_RELEASES.as_str())
+ );
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(param_ident) => match param_ident.parse::<String>() {
+ Ok(param_ident) => param_ident,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_creator_releases(
+ param_ident,
+ param_hide,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetCreatorReleasesResponse::Found
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CREATOR_RELEASES_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetCreatorReleasesResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CREATOR_RELEASES_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetCreatorReleasesResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CREATOR_RELEASES_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetCreatorReleasesResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CREATOR_RELEASES_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetCreatorRevision - GET /creator/rev/{rev_id}
+ &hyper::Method::GET if path.matched(paths::ID_CREATOR_REV_REV_ID) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_CREATOR_REV_REV_ID
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE CREATOR_REV_REV_ID in set but failed match against \"{}\"", path, paths::REGEX_CREATOR_REV_REV_ID.as_str())
+ );
+
+ let param_rev_id = match percent_encoding::percent_decode(path_params["rev_id"].as_bytes()).decode_utf8() {
+ Ok(param_rev_id) => match param_rev_id.parse::<String>() {
+ Ok(param_rev_id) => param_rev_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter rev_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["rev_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_expand = query_params
+ .iter()
+ .filter(|e| e.0 == "expand")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_expand = param_expand.and_then(|param_expand| param_expand.parse().ok());
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_creator_revision(
+ param_rev_id,
+ param_expand,
+ param_hide,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetCreatorRevisionResponse::FoundEntityRevision
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CREATOR_REVISION_FOUND_ENTITY_REVISION"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetCreatorRevisionResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CREATOR_REVISION_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetCreatorRevisionResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CREATOR_REVISION_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetCreatorRevisionResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_CREATOR_REVISION_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetEditgroup - GET /editgroup/{editgroup_id}
+ &hyper::Method::GET if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_EDITGROUP_EDITGROUP_ID
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID.as_str())
+ );
+
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
+ Ok(param_editgroup_id) => param_editgroup_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_editgroup(
+ param_editgroup_id,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetEditgroupResponse::Found
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_EDITGROUP_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetEditgroupResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_EDITGROUP_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetEditgroupResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_EDITGROUP_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetEditgroupResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_EDITGROUP_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetEditgroupAnnotations - GET /editgroup/{editgroup_id}/annotations
+ &hyper::Method::GET if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_ANNOTATIONS) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_EDITGROUP_EDITGROUP_ID_ANNOTATIONS
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_ANNOTATIONS in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_ANNOTATIONS.as_str())
+ );
+
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
+ Ok(param_editgroup_id) => param_editgroup_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_expand = query_params
+ .iter()
+ .filter(|e| e.0 == "expand")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_expand = param_expand.and_then(|param_expand| param_expand.parse().ok());
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_editgroup_annotations(
+ param_editgroup_id,
+ param_expand,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetEditgroupAnnotationsResponse::Success
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_EDITGROUP_ANNOTATIONS_SUCCESS"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetEditgroupAnnotationsResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_EDITGROUP_ANNOTATIONS_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetEditgroupAnnotationsResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_EDITGROUP_ANNOTATIONS_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetEditgroupAnnotationsResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_EDITGROUP_ANNOTATIONS_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetEditgroupAnnotationsResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_EDITGROUP_ANNOTATIONS_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetEditgroupAnnotationsResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_EDITGROUP_ANNOTATIONS_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetEditgroupsReviewable - GET /editgroup/reviewable
+ &hyper::Method::GET if path.matched(paths::ID_EDITGROUP_REVIEWABLE) => {
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_expand = query_params
+ .iter()
+ .filter(|e| e.0 == "expand")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_expand = param_expand.and_then(|param_expand| param_expand.parse().ok());
+ let param_limit = query_params
+ .iter()
+ .filter(|e| e.0 == "limit")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_limit = param_limit.and_then(|param_limit| param_limit.parse().ok());
+ let param_before = query_params
+ .iter()
+ .filter(|e| e.0 == "before")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_before = param_before.and_then(|param_before| param_before.parse().ok());
+ let param_since = query_params
+ .iter()
+ .filter(|e| e.0 == "since")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_since = param_since.and_then(|param_since| param_since.parse().ok());
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_editgroups_reviewable(
+ param_expand,
+ param_limit,
+ param_before,
+ param_since,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetEditgroupsReviewableResponse::Found
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_EDITGROUPS_REVIEWABLE_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetEditgroupsReviewableResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_EDITGROUPS_REVIEWABLE_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetEditgroupsReviewableResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_EDITGROUPS_REVIEWABLE_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetEditgroupsReviewableResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_EDITGROUPS_REVIEWABLE_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetEditor - GET /editor/{editor_id}
+ &hyper::Method::GET if path.matched(paths::ID_EDITOR_EDITOR_ID) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_EDITOR_EDITOR_ID
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE EDITOR_EDITOR_ID in set but failed match against \"{}\"", path, paths::REGEX_EDITOR_EDITOR_ID.as_str())
+ );
+
+ let param_editor_id = match percent_encoding::percent_decode(path_params["editor_id"].as_bytes()).decode_utf8() {
+ Ok(param_editor_id) => match param_editor_id.parse::<String>() {
+ Ok(param_editor_id) => param_editor_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter editor_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editor_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_editor(
+ param_editor_id,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetEditorResponse::Found
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_EDITOR_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetEditorResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_EDITOR_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetEditorResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_EDITOR_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetEditorResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_EDITOR_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetEditorAnnotations - GET /editor/{editor_id}/annotations
+ &hyper::Method::GET if path.matched(paths::ID_EDITOR_EDITOR_ID_ANNOTATIONS) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_EDITOR_EDITOR_ID_ANNOTATIONS
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE EDITOR_EDITOR_ID_ANNOTATIONS in set but failed match against \"{}\"", path, paths::REGEX_EDITOR_EDITOR_ID_ANNOTATIONS.as_str())
+ );
+
+ let param_editor_id = match percent_encoding::percent_decode(path_params["editor_id"].as_bytes()).decode_utf8() {
+ Ok(param_editor_id) => match param_editor_id.parse::<String>() {
+ Ok(param_editor_id) => param_editor_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter editor_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editor_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_limit = query_params
+ .iter()
+ .filter(|e| e.0 == "limit")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_limit = param_limit.and_then(|param_limit| param_limit.parse().ok());
+ let param_before = query_params
+ .iter()
+ .filter(|e| e.0 == "before")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_before = param_before.and_then(|param_before| param_before.parse().ok());
+ let param_since = query_params
+ .iter()
+ .filter(|e| e.0 == "since")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_since = param_since.and_then(|param_since| param_since.parse().ok());
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_editor_annotations(
+ param_editor_id,
+ param_limit,
+ param_before,
+ param_since,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetEditorAnnotationsResponse::Success
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_EDITOR_ANNOTATIONS_SUCCESS"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetEditorAnnotationsResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_EDITOR_ANNOTATIONS_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetEditorAnnotationsResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_EDITOR_ANNOTATIONS_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetEditorAnnotationsResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_EDITOR_ANNOTATIONS_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetEditorAnnotationsResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_EDITOR_ANNOTATIONS_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetEditorAnnotationsResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_EDITOR_ANNOTATIONS_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetEditorEditgroups - GET /editor/{editor_id}/editgroups
+ &hyper::Method::GET if path.matched(paths::ID_EDITOR_EDITOR_ID_EDITGROUPS) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_EDITOR_EDITOR_ID_EDITGROUPS
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE EDITOR_EDITOR_ID_EDITGROUPS in set but failed match against \"{}\"", path, paths::REGEX_EDITOR_EDITOR_ID_EDITGROUPS.as_str())
+ );
+
+ let param_editor_id = match percent_encoding::percent_decode(path_params["editor_id"].as_bytes()).decode_utf8() {
+ Ok(param_editor_id) => match param_editor_id.parse::<String>() {
+ Ok(param_editor_id) => param_editor_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter editor_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editor_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_limit = query_params
+ .iter()
+ .filter(|e| e.0 == "limit")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_limit = param_limit.and_then(|param_limit| param_limit.parse().ok());
+ let param_before = query_params
+ .iter()
+ .filter(|e| e.0 == "before")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_before = param_before.and_then(|param_before| param_before.parse().ok());
+ let param_since = query_params
+ .iter()
+ .filter(|e| e.0 == "since")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_since = param_since.and_then(|param_since| param_since.parse().ok());
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_editor_editgroups(
+ param_editor_id,
+ param_limit,
+ param_before,
+ param_since,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetEditorEditgroupsResponse::Found
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_EDITOR_EDITGROUPS_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetEditorEditgroupsResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_EDITOR_EDITGROUPS_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetEditorEditgroupsResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_EDITOR_EDITGROUPS_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetEditorEditgroupsResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_EDITOR_EDITGROUPS_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetFile - GET /file/{ident}
+ &hyper::Method::GET if path.matched(paths::ID_FILE_IDENT) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params = paths::REGEX_FILE_IDENT.captures(&path).unwrap_or_else(|| {
+ panic!(
+ "Path {} matched RE FILE_IDENT in set but failed match against \"{}\"",
+ path,
+ paths::REGEX_FILE_IDENT.as_str()
+ )
+ });
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(param_ident) => match param_ident.parse::<String>() {
+ Ok(param_ident) => param_ident,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_expand = query_params
+ .iter()
+ .filter(|e| e.0 == "expand")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_expand = param_expand.and_then(|param_expand| param_expand.parse().ok());
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_file(
+ param_ident,
+ param_expand,
+ param_hide,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetFileResponse::FoundEntity
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_FILE_FOUND_ENTITY"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetFileResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_FILE_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetFileResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_FILE_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetFileResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_FILE_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetFileEdit - GET /file/edit/{edit_id}
+ &hyper::Method::GET if path.matched(paths::ID_FILE_EDIT_EDIT_ID) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_FILE_EDIT_EDIT_ID
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE FILE_EDIT_EDIT_ID in set but failed match against \"{}\"", path, paths::REGEX_FILE_EDIT_EDIT_ID.as_str())
+ );
+
+ let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
+ Ok(param_edit_id) => match param_edit_id.parse::<String>() {
+ Ok(param_edit_id) => param_edit_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter edit_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["edit_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_file_edit(
+ param_edit_id,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetFileEditResponse::FoundEdit
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_FILE_EDIT_FOUND_EDIT"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetFileEditResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_FILE_EDIT_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetFileEditResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_FILE_EDIT_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetFileEditResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_FILE_EDIT_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetFileHistory - GET /file/{ident}/history
+ &hyper::Method::GET if path.matched(paths::ID_FILE_IDENT_HISTORY) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_FILE_IDENT_HISTORY
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE FILE_IDENT_HISTORY in set but failed match against \"{}\"", path, paths::REGEX_FILE_IDENT_HISTORY.as_str())
+ );
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(param_ident) => match param_ident.parse::<String>() {
+ Ok(param_ident) => param_ident,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_limit = query_params
+ .iter()
+ .filter(|e| e.0 == "limit")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_limit = param_limit.and_then(|param_limit| param_limit.parse().ok());
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_file_history(
+ param_ident,
+ param_limit,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetFileHistoryResponse::FoundEntityHistory
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_FILE_HISTORY_FOUND_ENTITY_HISTORY"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetFileHistoryResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_FILE_HISTORY_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetFileHistoryResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_FILE_HISTORY_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetFileHistoryResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_FILE_HISTORY_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetFileRedirects - GET /file/{ident}/redirects
+ &hyper::Method::GET if path.matched(paths::ID_FILE_IDENT_REDIRECTS) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_FILE_IDENT_REDIRECTS
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE FILE_IDENT_REDIRECTS in set but failed match against \"{}\"", path, paths::REGEX_FILE_IDENT_REDIRECTS.as_str())
+ );
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(param_ident) => match param_ident.parse::<String>() {
+ Ok(param_ident) => param_ident,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_file_redirects(
+ param_ident,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetFileRedirectsResponse::FoundEntityRedirects
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_FILE_REDIRECTS_FOUND_ENTITY_REDIRECTS"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetFileRedirectsResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_FILE_REDIRECTS_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetFileRedirectsResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_FILE_REDIRECTS_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetFileRedirectsResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_FILE_REDIRECTS_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetFileRevision - GET /file/rev/{rev_id}
+ &hyper::Method::GET if path.matched(paths::ID_FILE_REV_REV_ID) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_FILE_REV_REV_ID
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE FILE_REV_REV_ID in set but failed match against \"{}\"", path, paths::REGEX_FILE_REV_REV_ID.as_str())
+ );
+
+ let param_rev_id = match percent_encoding::percent_decode(path_params["rev_id"].as_bytes()).decode_utf8() {
+ Ok(param_rev_id) => match param_rev_id.parse::<String>() {
+ Ok(param_rev_id) => param_rev_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter rev_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["rev_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_expand = query_params
+ .iter()
+ .filter(|e| e.0 == "expand")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_expand = param_expand.and_then(|param_expand| param_expand.parse().ok());
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_file_revision(
+ param_rev_id,
+ param_expand,
+ param_hide,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetFileRevisionResponse::FoundEntityRevision
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_FILE_REVISION_FOUND_ENTITY_REVISION"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetFileRevisionResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_FILE_REVISION_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetFileRevisionResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_FILE_REVISION_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetFileRevisionResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_FILE_REVISION_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetFileset - GET /fileset/{ident}
+ &hyper::Method::GET if path.matched(paths::ID_FILESET_IDENT) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_FILESET_IDENT
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE FILESET_IDENT in set but failed match against \"{}\"", path, paths::REGEX_FILESET_IDENT.as_str())
+ );
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(param_ident) => match param_ident.parse::<String>() {
+ Ok(param_ident) => param_ident,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_expand = query_params
+ .iter()
+ .filter(|e| e.0 == "expand")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_expand = param_expand.and_then(|param_expand| param_expand.parse().ok());
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_fileset(
+ param_ident,
+ param_expand,
+ param_hide,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetFilesetResponse::FoundEntity
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_FILESET_FOUND_ENTITY"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetFilesetResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_FILESET_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetFilesetResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_FILESET_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetFilesetResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_FILESET_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetFilesetEdit - GET /fileset/edit/{edit_id}
+ &hyper::Method::GET if path.matched(paths::ID_FILESET_EDIT_EDIT_ID) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_FILESET_EDIT_EDIT_ID
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE FILESET_EDIT_EDIT_ID in set but failed match against \"{}\"", path, paths::REGEX_FILESET_EDIT_EDIT_ID.as_str())
+ );
+
+ let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
+ Ok(param_edit_id) => match param_edit_id.parse::<String>() {
+ Ok(param_edit_id) => param_edit_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter edit_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["edit_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_fileset_edit(
+ param_edit_id,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetFilesetEditResponse::FoundEdit
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_FILESET_EDIT_FOUND_EDIT"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetFilesetEditResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_FILESET_EDIT_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetFilesetEditResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_FILESET_EDIT_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetFilesetEditResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_FILESET_EDIT_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetFilesetHistory - GET /fileset/{ident}/history
+ &hyper::Method::GET if path.matched(paths::ID_FILESET_IDENT_HISTORY) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_FILESET_IDENT_HISTORY
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE FILESET_IDENT_HISTORY in set but failed match against \"{}\"", path, paths::REGEX_FILESET_IDENT_HISTORY.as_str())
+ );
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(param_ident) => match param_ident.parse::<String>() {
+ Ok(param_ident) => param_ident,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_limit = query_params
+ .iter()
+ .filter(|e| e.0 == "limit")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_limit = param_limit.and_then(|param_limit| param_limit.parse().ok());
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_fileset_history(
+ param_ident,
+ param_limit,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetFilesetHistoryResponse::FoundEntityHistory
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_FILESET_HISTORY_FOUND_ENTITY_HISTORY"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetFilesetHistoryResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_FILESET_HISTORY_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetFilesetHistoryResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_FILESET_HISTORY_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetFilesetHistoryResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_FILESET_HISTORY_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetFilesetRedirects - GET /fileset/{ident}/redirects
+ &hyper::Method::GET if path.matched(paths::ID_FILESET_IDENT_REDIRECTS) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_FILESET_IDENT_REDIRECTS
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE FILESET_IDENT_REDIRECTS in set but failed match against \"{}\"", path, paths::REGEX_FILESET_IDENT_REDIRECTS.as_str())
+ );
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(param_ident) => match param_ident.parse::<String>() {
+ Ok(param_ident) => param_ident,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_fileset_redirects(
+ param_ident,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetFilesetRedirectsResponse::FoundEntityRedirects
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_FILESET_REDIRECTS_FOUND_ENTITY_REDIRECTS"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetFilesetRedirectsResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_FILESET_REDIRECTS_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetFilesetRedirectsResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_FILESET_REDIRECTS_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetFilesetRedirectsResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_FILESET_REDIRECTS_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetFilesetRevision - GET /fileset/rev/{rev_id}
+ &hyper::Method::GET if path.matched(paths::ID_FILESET_REV_REV_ID) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_FILESET_REV_REV_ID
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE FILESET_REV_REV_ID in set but failed match against \"{}\"", path, paths::REGEX_FILESET_REV_REV_ID.as_str())
+ );
+
+ let param_rev_id = match percent_encoding::percent_decode(path_params["rev_id"].as_bytes()).decode_utf8() {
+ Ok(param_rev_id) => match param_rev_id.parse::<String>() {
+ Ok(param_rev_id) => param_rev_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter rev_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["rev_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_expand = query_params
+ .iter()
+ .filter(|e| e.0 == "expand")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_expand = param_expand.and_then(|param_expand| param_expand.parse().ok());
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_fileset_revision(
+ param_rev_id,
+ param_expand,
+ param_hide,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetFilesetRevisionResponse::FoundEntityRevision
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_FILESET_REVISION_FOUND_ENTITY_REVISION"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetFilesetRevisionResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_FILESET_REVISION_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetFilesetRevisionResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_FILESET_REVISION_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetFilesetRevisionResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_FILESET_REVISION_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetRelease - GET /release/{ident}
+ &hyper::Method::GET if path.matched(paths::ID_RELEASE_IDENT) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_RELEASE_IDENT
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE RELEASE_IDENT in set but failed match against \"{}\"", path, paths::REGEX_RELEASE_IDENT.as_str())
+ );
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(param_ident) => match param_ident.parse::<String>() {
+ Ok(param_ident) => param_ident,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_expand = query_params
+ .iter()
+ .filter(|e| e.0 == "expand")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_expand = param_expand.and_then(|param_expand| param_expand.parse().ok());
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_release(
+ param_ident,
+ param_expand,
+ param_hide,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetReleaseResponse::FoundEntity
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_RELEASE_FOUND_ENTITY"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetReleaseResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_RELEASE_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetReleaseResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_RELEASE_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetReleaseResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_RELEASE_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetReleaseEdit - GET /release/edit/{edit_id}
+ &hyper::Method::GET if path.matched(paths::ID_RELEASE_EDIT_EDIT_ID) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_RELEASE_EDIT_EDIT_ID
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE RELEASE_EDIT_EDIT_ID in set but failed match against \"{}\"", path, paths::REGEX_RELEASE_EDIT_EDIT_ID.as_str())
+ );
+
+ let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
+ Ok(param_edit_id) => match param_edit_id.parse::<String>() {
+ Ok(param_edit_id) => param_edit_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter edit_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["edit_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_release_edit(
+ param_edit_id,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetReleaseEditResponse::FoundEdit
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_RELEASE_EDIT_FOUND_EDIT"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetReleaseEditResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_RELEASE_EDIT_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetReleaseEditResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_RELEASE_EDIT_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetReleaseEditResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_RELEASE_EDIT_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetReleaseFiles - GET /release/{ident}/files
+ &hyper::Method::GET if path.matched(paths::ID_RELEASE_IDENT_FILES) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_RELEASE_IDENT_FILES
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE RELEASE_IDENT_FILES in set but failed match against \"{}\"", path, paths::REGEX_RELEASE_IDENT_FILES.as_str())
+ );
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(param_ident) => match param_ident.parse::<String>() {
+ Ok(param_ident) => param_ident,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_release_files(
+ param_ident,
+ param_hide,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetReleaseFilesResponse::Found
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_RELEASE_FILES_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetReleaseFilesResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_RELEASE_FILES_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetReleaseFilesResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_RELEASE_FILES_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetReleaseFilesResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_RELEASE_FILES_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetReleaseFilesets - GET /release/{ident}/filesets
+ &hyper::Method::GET if path.matched(paths::ID_RELEASE_IDENT_FILESETS) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_RELEASE_IDENT_FILESETS
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE RELEASE_IDENT_FILESETS in set but failed match against \"{}\"", path, paths::REGEX_RELEASE_IDENT_FILESETS.as_str())
+ );
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(param_ident) => match param_ident.parse::<String>() {
+ Ok(param_ident) => param_ident,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_release_filesets(
+ param_ident,
+ param_hide,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetReleaseFilesetsResponse::Found
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_RELEASE_FILESETS_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetReleaseFilesetsResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_RELEASE_FILESETS_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetReleaseFilesetsResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_RELEASE_FILESETS_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetReleaseFilesetsResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_RELEASE_FILESETS_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetReleaseHistory - GET /release/{ident}/history
+ &hyper::Method::GET if path.matched(paths::ID_RELEASE_IDENT_HISTORY) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_RELEASE_IDENT_HISTORY
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE RELEASE_IDENT_HISTORY in set but failed match against \"{}\"", path, paths::REGEX_RELEASE_IDENT_HISTORY.as_str())
+ );
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(param_ident) => match param_ident.parse::<String>() {
+ Ok(param_ident) => param_ident,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_limit = query_params
+ .iter()
+ .filter(|e| e.0 == "limit")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_limit = param_limit.and_then(|param_limit| param_limit.parse().ok());
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_release_history(
+ param_ident,
+ param_limit,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetReleaseHistoryResponse::FoundEntityHistory
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_RELEASE_HISTORY_FOUND_ENTITY_HISTORY"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetReleaseHistoryResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_RELEASE_HISTORY_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetReleaseHistoryResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_RELEASE_HISTORY_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetReleaseHistoryResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_RELEASE_HISTORY_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetReleaseRedirects - GET /release/{ident}/redirects
+ &hyper::Method::GET if path.matched(paths::ID_RELEASE_IDENT_REDIRECTS) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_RELEASE_IDENT_REDIRECTS
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE RELEASE_IDENT_REDIRECTS in set but failed match against \"{}\"", path, paths::REGEX_RELEASE_IDENT_REDIRECTS.as_str())
+ );
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(param_ident) => match param_ident.parse::<String>() {
+ Ok(param_ident) => param_ident,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_release_redirects(
+ param_ident,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetReleaseRedirectsResponse::FoundEntityRedirects
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_RELEASE_REDIRECTS_FOUND_ENTITY_REDIRECTS"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetReleaseRedirectsResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_RELEASE_REDIRECTS_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetReleaseRedirectsResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_RELEASE_REDIRECTS_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetReleaseRedirectsResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_RELEASE_REDIRECTS_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetReleaseRevision - GET /release/rev/{rev_id}
+ &hyper::Method::GET if path.matched(paths::ID_RELEASE_REV_REV_ID) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_RELEASE_REV_REV_ID
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE RELEASE_REV_REV_ID in set but failed match against \"{}\"", path, paths::REGEX_RELEASE_REV_REV_ID.as_str())
+ );
+
+ let param_rev_id = match percent_encoding::percent_decode(path_params["rev_id"].as_bytes()).decode_utf8() {
+ Ok(param_rev_id) => match param_rev_id.parse::<String>() {
+ Ok(param_rev_id) => param_rev_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter rev_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["rev_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_expand = query_params
+ .iter()
+ .filter(|e| e.0 == "expand")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_expand = param_expand.and_then(|param_expand| param_expand.parse().ok());
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_release_revision(
+ param_rev_id,
+ param_expand,
+ param_hide,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetReleaseRevisionResponse::FoundEntityRevision
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_RELEASE_REVISION_FOUND_ENTITY_REVISION"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetReleaseRevisionResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_RELEASE_REVISION_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetReleaseRevisionResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_RELEASE_REVISION_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetReleaseRevisionResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_RELEASE_REVISION_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetReleaseWebcaptures - GET /release/{ident}/webcaptures
+ &hyper::Method::GET if path.matched(paths::ID_RELEASE_IDENT_WEBCAPTURES) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_RELEASE_IDENT_WEBCAPTURES
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE RELEASE_IDENT_WEBCAPTURES in set but failed match against \"{}\"", path, paths::REGEX_RELEASE_IDENT_WEBCAPTURES.as_str())
+ );
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(param_ident) => match param_ident.parse::<String>() {
+ Ok(param_ident) => param_ident,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_release_webcaptures(
+ param_ident,
+ param_hide,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetReleaseWebcapturesResponse::Found
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_RELEASE_WEBCAPTURES_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetReleaseWebcapturesResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_RELEASE_WEBCAPTURES_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetReleaseWebcapturesResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_RELEASE_WEBCAPTURES_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetReleaseWebcapturesResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_RELEASE_WEBCAPTURES_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetWebcapture - GET /webcapture/{ident}
+ &hyper::Method::GET if path.matched(paths::ID_WEBCAPTURE_IDENT) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_WEBCAPTURE_IDENT
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE WEBCAPTURE_IDENT in set but failed match against \"{}\"", path, paths::REGEX_WEBCAPTURE_IDENT.as_str())
+ );
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(param_ident) => match param_ident.parse::<String>() {
+ Ok(param_ident) => param_ident,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_expand = query_params
+ .iter()
+ .filter(|e| e.0 == "expand")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_expand = param_expand.and_then(|param_expand| param_expand.parse().ok());
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_webcapture(
+ param_ident,
+ param_expand,
+ param_hide,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetWebcaptureResponse::FoundEntity
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WEBCAPTURE_FOUND_ENTITY"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetWebcaptureResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WEBCAPTURE_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetWebcaptureResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WEBCAPTURE_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetWebcaptureResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WEBCAPTURE_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetWebcaptureEdit - GET /webcapture/edit/{edit_id}
+ &hyper::Method::GET if path.matched(paths::ID_WEBCAPTURE_EDIT_EDIT_ID) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_WEBCAPTURE_EDIT_EDIT_ID
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE WEBCAPTURE_EDIT_EDIT_ID in set but failed match against \"{}\"", path, paths::REGEX_WEBCAPTURE_EDIT_EDIT_ID.as_str())
+ );
+
+ let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
+ Ok(param_edit_id) => match param_edit_id.parse::<String>() {
+ Ok(param_edit_id) => param_edit_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter edit_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["edit_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_webcapture_edit(
+ param_edit_id,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetWebcaptureEditResponse::FoundEdit
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WEBCAPTURE_EDIT_FOUND_EDIT"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetWebcaptureEditResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WEBCAPTURE_EDIT_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetWebcaptureEditResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WEBCAPTURE_EDIT_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetWebcaptureEditResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WEBCAPTURE_EDIT_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetWebcaptureHistory - GET /webcapture/{ident}/history
+ &hyper::Method::GET if path.matched(paths::ID_WEBCAPTURE_IDENT_HISTORY) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_WEBCAPTURE_IDENT_HISTORY
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE WEBCAPTURE_IDENT_HISTORY in set but failed match against \"{}\"", path, paths::REGEX_WEBCAPTURE_IDENT_HISTORY.as_str())
+ );
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(param_ident) => match param_ident.parse::<String>() {
+ Ok(param_ident) => param_ident,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_limit = query_params
+ .iter()
+ .filter(|e| e.0 == "limit")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_limit = param_limit.and_then(|param_limit| param_limit.parse().ok());
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_webcapture_history(
+ param_ident,
+ param_limit,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetWebcaptureHistoryResponse::FoundEntityHistory
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WEBCAPTURE_HISTORY_FOUND_ENTITY_HISTORY"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetWebcaptureHistoryResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WEBCAPTURE_HISTORY_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetWebcaptureHistoryResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WEBCAPTURE_HISTORY_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetWebcaptureHistoryResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WEBCAPTURE_HISTORY_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetWebcaptureRedirects - GET /webcapture/{ident}/redirects
+ &hyper::Method::GET if path.matched(paths::ID_WEBCAPTURE_IDENT_REDIRECTS) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_WEBCAPTURE_IDENT_REDIRECTS
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE WEBCAPTURE_IDENT_REDIRECTS in set but failed match against \"{}\"", path, paths::REGEX_WEBCAPTURE_IDENT_REDIRECTS.as_str())
+ );
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(param_ident) => match param_ident.parse::<String>() {
+ Ok(param_ident) => param_ident,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_webcapture_redirects(
+ param_ident,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetWebcaptureRedirectsResponse::FoundEntityRedirects
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WEBCAPTURE_REDIRECTS_FOUND_ENTITY_REDIRECTS"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetWebcaptureRedirectsResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WEBCAPTURE_REDIRECTS_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetWebcaptureRedirectsResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WEBCAPTURE_REDIRECTS_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetWebcaptureRedirectsResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WEBCAPTURE_REDIRECTS_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetWebcaptureRevision - GET /webcapture/rev/{rev_id}
+ &hyper::Method::GET if path.matched(paths::ID_WEBCAPTURE_REV_REV_ID) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_WEBCAPTURE_REV_REV_ID
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE WEBCAPTURE_REV_REV_ID in set but failed match against \"{}\"", path, paths::REGEX_WEBCAPTURE_REV_REV_ID.as_str())
+ );
+
+ let param_rev_id = match percent_encoding::percent_decode(path_params["rev_id"].as_bytes()).decode_utf8() {
+ Ok(param_rev_id) => match param_rev_id.parse::<String>() {
+ Ok(param_rev_id) => param_rev_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter rev_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["rev_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_expand = query_params
+ .iter()
+ .filter(|e| e.0 == "expand")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_expand = param_expand.and_then(|param_expand| param_expand.parse().ok());
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_webcapture_revision(
+ param_rev_id,
+ param_expand,
+ param_hide,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetWebcaptureRevisionResponse::FoundEntityRevision
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WEBCAPTURE_REVISION_FOUND_ENTITY_REVISION"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetWebcaptureRevisionResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WEBCAPTURE_REVISION_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetWebcaptureRevisionResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WEBCAPTURE_REVISION_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetWebcaptureRevisionResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WEBCAPTURE_REVISION_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetWork - GET /work/{ident}
+ &hyper::Method::GET if path.matched(paths::ID_WORK_IDENT) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params = paths::REGEX_WORK_IDENT.captures(&path).unwrap_or_else(|| {
+ panic!(
+ "Path {} matched RE WORK_IDENT in set but failed match against \"{}\"",
+ path,
+ paths::REGEX_WORK_IDENT.as_str()
+ )
+ });
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(param_ident) => match param_ident.parse::<String>() {
+ Ok(param_ident) => param_ident,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_expand = query_params
+ .iter()
+ .filter(|e| e.0 == "expand")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_expand = param_expand.and_then(|param_expand| param_expand.parse().ok());
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_work(
+ param_ident,
+ param_expand,
+ param_hide,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetWorkResponse::FoundEntity
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WORK_FOUND_ENTITY"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetWorkResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WORK_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetWorkResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WORK_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetWorkResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WORK_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetWorkEdit - GET /work/edit/{edit_id}
+ &hyper::Method::GET if path.matched(paths::ID_WORK_EDIT_EDIT_ID) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_WORK_EDIT_EDIT_ID
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE WORK_EDIT_EDIT_ID in set but failed match against \"{}\"", path, paths::REGEX_WORK_EDIT_EDIT_ID.as_str())
+ );
+
+ let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
+ Ok(param_edit_id) => match param_edit_id.parse::<String>() {
+ Ok(param_edit_id) => param_edit_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter edit_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["edit_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_work_edit(
+ param_edit_id,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetWorkEditResponse::FoundEdit
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WORK_EDIT_FOUND_EDIT"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetWorkEditResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WORK_EDIT_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetWorkEditResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WORK_EDIT_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetWorkEditResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WORK_EDIT_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetWorkHistory - GET /work/{ident}/history
+ &hyper::Method::GET if path.matched(paths::ID_WORK_IDENT_HISTORY) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_WORK_IDENT_HISTORY
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE WORK_IDENT_HISTORY in set but failed match against \"{}\"", path, paths::REGEX_WORK_IDENT_HISTORY.as_str())
+ );
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(param_ident) => match param_ident.parse::<String>() {
+ Ok(param_ident) => param_ident,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_limit = query_params
+ .iter()
+ .filter(|e| e.0 == "limit")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_limit = param_limit.and_then(|param_limit| param_limit.parse().ok());
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_work_history(
+ param_ident,
+ param_limit,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetWorkHistoryResponse::FoundEntityHistory
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WORK_HISTORY_FOUND_ENTITY_HISTORY"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetWorkHistoryResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WORK_HISTORY_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetWorkHistoryResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WORK_HISTORY_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetWorkHistoryResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WORK_HISTORY_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetWorkRedirects - GET /work/{ident}/redirects
+ &hyper::Method::GET if path.matched(paths::ID_WORK_IDENT_REDIRECTS) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_WORK_IDENT_REDIRECTS
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE WORK_IDENT_REDIRECTS in set but failed match against \"{}\"", path, paths::REGEX_WORK_IDENT_REDIRECTS.as_str())
+ );
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(param_ident) => match param_ident.parse::<String>() {
+ Ok(param_ident) => param_ident,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_work_redirects(
+ param_ident,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetWorkRedirectsResponse::FoundEntityRedirects
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WORK_REDIRECTS_FOUND_ENTITY_REDIRECTS"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetWorkRedirectsResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WORK_REDIRECTS_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetWorkRedirectsResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WORK_REDIRECTS_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetWorkRedirectsResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WORK_REDIRECTS_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetWorkReleases - GET /work/{ident}/releases
+ &hyper::Method::GET if path.matched(paths::ID_WORK_IDENT_RELEASES) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_WORK_IDENT_RELEASES
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE WORK_IDENT_RELEASES in set but failed match against \"{}\"", path, paths::REGEX_WORK_IDENT_RELEASES.as_str())
+ );
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(param_ident) => match param_ident.parse::<String>() {
+ Ok(param_ident) => param_ident,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_work_releases(
+ param_ident,
+ param_hide,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetWorkReleasesResponse::Found
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WORK_RELEASES_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetWorkReleasesResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WORK_RELEASES_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetWorkReleasesResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WORK_RELEASES_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetWorkReleasesResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WORK_RELEASES_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // GetWorkRevision - GET /work/rev/{rev_id}
+ &hyper::Method::GET if path.matched(paths::ID_WORK_REV_REV_ID) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_WORK_REV_REV_ID
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE WORK_REV_REV_ID in set but failed match against \"{}\"", path, paths::REGEX_WORK_REV_REV_ID.as_str())
+ );
+
+ let param_rev_id = match percent_encoding::percent_decode(path_params["rev_id"].as_bytes()).decode_utf8() {
+ Ok(param_rev_id) => match param_rev_id.parse::<String>() {
+ Ok(param_rev_id) => param_rev_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter rev_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["rev_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_expand = query_params
+ .iter()
+ .filter(|e| e.0 == "expand")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_expand = param_expand.and_then(|param_expand| param_expand.parse().ok());
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.get_work_revision(
+ param_rev_id,
+ param_expand,
+ param_hide,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetWorkRevisionResponse::FoundEntityRevision
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WORK_REVISION_FOUND_ENTITY_REVISION"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetWorkRevisionResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WORK_REVISION_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetWorkRevisionResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WORK_REVISION_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ GetWorkRevisionResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for GET_WORK_REVISION_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // LookupContainer - GET /container/lookup
+ &hyper::Method::GET if path.matched(paths::ID_CONTAINER_LOOKUP) => {
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_issnl = query_params
+ .iter()
+ .filter(|e| e.0 == "issnl")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_issnl = param_issnl.and_then(|param_issnl| param_issnl.parse().ok());
+ let param_wikidata_qid = query_params
+ .iter()
+ .filter(|e| e.0 == "wikidata_qid")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_wikidata_qid = param_wikidata_qid
+ .and_then(|param_wikidata_qid| param_wikidata_qid.parse().ok());
+ let param_expand = query_params
+ .iter()
+ .filter(|e| e.0 == "expand")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_expand = param_expand.and_then(|param_expand| param_expand.parse().ok());
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.lookup_container(
+ param_issnl,
+ param_wikidata_qid,
+ param_expand,
+ param_hide,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ LookupContainerResponse::FoundEntity
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for LOOKUP_CONTAINER_FOUND_ENTITY"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ LookupContainerResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for LOOKUP_CONTAINER_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ LookupContainerResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for LOOKUP_CONTAINER_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ LookupContainerResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for LOOKUP_CONTAINER_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // LookupCreator - GET /creator/lookup
+ &hyper::Method::GET if path.matched(paths::ID_CREATOR_LOOKUP) => {
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_orcid = query_params
+ .iter()
+ .filter(|e| e.0 == "orcid")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_orcid = param_orcid.and_then(|param_orcid| param_orcid.parse().ok());
+ let param_wikidata_qid = query_params
+ .iter()
+ .filter(|e| e.0 == "wikidata_qid")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_wikidata_qid = param_wikidata_qid
+ .and_then(|param_wikidata_qid| param_wikidata_qid.parse().ok());
+ let param_expand = query_params
+ .iter()
+ .filter(|e| e.0 == "expand")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_expand = param_expand.and_then(|param_expand| param_expand.parse().ok());
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.lookup_creator(
+ param_orcid,
+ param_wikidata_qid,
+ param_expand,
+ param_hide,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ LookupCreatorResponse::FoundEntity
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for LOOKUP_CREATOR_FOUND_ENTITY"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ LookupCreatorResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for LOOKUP_CREATOR_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ LookupCreatorResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for LOOKUP_CREATOR_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ LookupCreatorResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for LOOKUP_CREATOR_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // LookupFile - GET /file/lookup
+ &hyper::Method::GET if path.matched(paths::ID_FILE_LOOKUP) => {
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_md5 = query_params
+ .iter()
+ .filter(|e| e.0 == "md5")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_md5 = param_md5.and_then(|param_md5| param_md5.parse().ok());
+ let param_sha1 = query_params
+ .iter()
+ .filter(|e| e.0 == "sha1")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_sha1 = param_sha1.and_then(|param_sha1| param_sha1.parse().ok());
+ let param_sha256 = query_params
+ .iter()
+ .filter(|e| e.0 == "sha256")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_sha256 = param_sha256.and_then(|param_sha256| param_sha256.parse().ok());
+ let param_expand = query_params
+ .iter()
+ .filter(|e| e.0 == "expand")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_expand = param_expand.and_then(|param_expand| param_expand.parse().ok());
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.lookup_file(
+ param_md5,
+ param_sha1,
+ param_sha256,
+ param_expand,
+ param_hide,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ LookupFileResponse::FoundEntity
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for LOOKUP_FILE_FOUND_ENTITY"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ LookupFileResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for LOOKUP_FILE_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ LookupFileResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for LOOKUP_FILE_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ LookupFileResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for LOOKUP_FILE_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // LookupRelease - GET /release/lookup
+ &hyper::Method::GET if path.matched(paths::ID_RELEASE_LOOKUP) => {
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_doi = query_params
+ .iter()
+ .filter(|e| e.0 == "doi")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_doi = param_doi.and_then(|param_doi| param_doi.parse().ok());
+ let param_wikidata_qid = query_params
+ .iter()
+ .filter(|e| e.0 == "wikidata_qid")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_wikidata_qid = param_wikidata_qid
+ .and_then(|param_wikidata_qid| param_wikidata_qid.parse().ok());
+ let param_isbn13 = query_params
+ .iter()
+ .filter(|e| e.0 == "isbn13")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_isbn13 = param_isbn13.and_then(|param_isbn13| param_isbn13.parse().ok());
+ let param_pmid = query_params
+ .iter()
+ .filter(|e| e.0 == "pmid")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_pmid = param_pmid.and_then(|param_pmid| param_pmid.parse().ok());
+ let param_pmcid = query_params
+ .iter()
+ .filter(|e| e.0 == "pmcid")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_pmcid = param_pmcid.and_then(|param_pmcid| param_pmcid.parse().ok());
+ let param_core = query_params
+ .iter()
+ .filter(|e| e.0 == "core")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_core = param_core.and_then(|param_core| param_core.parse().ok());
+ let param_arxiv = query_params
+ .iter()
+ .filter(|e| e.0 == "arxiv")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_arxiv = param_arxiv.and_then(|param_arxiv| param_arxiv.parse().ok());
+ let param_jstor = query_params
+ .iter()
+ .filter(|e| e.0 == "jstor")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_jstor = param_jstor.and_then(|param_jstor| param_jstor.parse().ok());
+ let param_ark = query_params
+ .iter()
+ .filter(|e| e.0 == "ark")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_ark = param_ark.and_then(|param_ark| param_ark.parse().ok());
+ let param_mag = query_params
+ .iter()
+ .filter(|e| e.0 == "mag")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_mag = param_mag.and_then(|param_mag| param_mag.parse().ok());
+ let param_expand = query_params
+ .iter()
+ .filter(|e| e.0 == "expand")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_expand = param_expand.and_then(|param_expand| param_expand.parse().ok());
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
+
+ Box::new({
+ {
+ {
+ Box::new(
+ api_impl.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
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ match result {
+ Ok(rsp) => match rsp {
+ LookupReleaseResponse::FoundEntity
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for LOOKUP_RELEASE_FOUND_ENTITY"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ LookupReleaseResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for LOOKUP_RELEASE_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ LookupReleaseResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for LOOKUP_RELEASE_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ LookupReleaseResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for LOOKUP_RELEASE_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ }
+ }
+ }) as Self::Future
+ }
+
+ // UpdateContainer - PUT /editgroup/{editgroup_id}/container/{ident}
+ &hyper::Method::PUT
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CONTAINER_IDENT) =>
+ {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_EDITGROUP_EDITGROUP_ID_CONTAINER_IDENT
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_CONTAINER_IDENT in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_CONTAINER_IDENT.as_str())
+ );
+
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
+ Ok(param_editgroup_id) => param_editgroup_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(param_ident) => match param_ident.parse::<String>() {
+ Ok(param_ident) => param_ident,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // 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.
+ Box::new(body.concat2()
+ .then(move |result| -> Self::Future {
+ match result {
+ Ok(body) => {
+ let mut unused_elements = Vec::new();
+ let param_entity: Option<models::ContainerEntity> = if !body.is_empty() {
+ let deserializer = &mut serde_json::Deserializer::from_slice(&*body);
+ match serde_ignored::deserialize(deserializer, |path| {
+ warn!("Ignoring unknown field in body: {}", path);
+ unused_elements.push(path.to_string());
+ }) {
+ Ok(param_entity) => param_entity,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse body parameter entity - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid body parameter entity due to schema"))),
+ }
+ } else {
+ None
+ };
+ let param_entity = match param_entity {
+ Some(param_entity) => param_entity,
+ None => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from("Missing required body parameter entity"))
+ .expect("Unable to create Bad Request response for missing body parameter entity"))),
+ };
+
+ Box::new(
+ api_impl.update_container(
+ param_editgroup_id,
+ param_ident,
+ param_entity,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ if !unused_elements.is_empty() {
+ response.headers_mut().insert(
+ HeaderName::from_static("warning"),
+ HeaderValue::from_str(format!("Ignoring unknown fields in body: {:?}", unused_elements).as_str())
+ .expect("Unable to create Warning header value"));
+ }
+
+ match result {
+ Ok(rsp) => match rsp {
+ UpdateContainerResponse::UpdatedEntity
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_CONTAINER_UPDATED_ENTITY"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateContainerResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_CONTAINER_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateContainerResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_CONTAINER_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateContainerResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_CONTAINER_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateContainerResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_CONTAINER_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateContainerResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_CONTAINER_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ },
+ Err(e) => Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't read body parameter entity: {}", e)))
+ .expect("Unable to create Bad Request response due to unable to read body parameter entity"))),
+ }
+ })
+ ) as Self::Future
+ }
+
+ // UpdateCreator - PUT /editgroup/{editgroup_id}/creator/{ident}
+ &hyper::Method::PUT if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CREATOR_IDENT) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_EDITGROUP_EDITGROUP_ID_CREATOR_IDENT
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_CREATOR_IDENT in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_CREATOR_IDENT.as_str())
+ );
+
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
+ Ok(param_editgroup_id) => param_editgroup_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(param_ident) => match param_ident.parse::<String>() {
+ Ok(param_ident) => param_ident,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // 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.
+ Box::new(body.concat2()
+ .then(move |result| -> Self::Future {
+ match result {
+ Ok(body) => {
+ let mut unused_elements = Vec::new();
+ let param_entity: Option<models::CreatorEntity> = if !body.is_empty() {
+ let deserializer = &mut serde_json::Deserializer::from_slice(&*body);
+ match serde_ignored::deserialize(deserializer, |path| {
+ warn!("Ignoring unknown field in body: {}", path);
+ unused_elements.push(path.to_string());
+ }) {
+ Ok(param_entity) => param_entity,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse body parameter entity - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid body parameter entity due to schema"))),
+ }
+ } else {
+ None
+ };
+ let param_entity = match param_entity {
+ Some(param_entity) => param_entity,
+ None => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from("Missing required body parameter entity"))
+ .expect("Unable to create Bad Request response for missing body parameter entity"))),
+ };
+
+ Box::new(
+ api_impl.update_creator(
+ param_editgroup_id,
+ param_ident,
+ param_entity,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ if !unused_elements.is_empty() {
+ response.headers_mut().insert(
+ HeaderName::from_static("warning"),
+ HeaderValue::from_str(format!("Ignoring unknown fields in body: {:?}", unused_elements).as_str())
+ .expect("Unable to create Warning header value"));
+ }
+
+ match result {
+ Ok(rsp) => match rsp {
+ UpdateCreatorResponse::UpdatedEntity
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_CREATOR_UPDATED_ENTITY"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateCreatorResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_CREATOR_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateCreatorResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_CREATOR_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateCreatorResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_CREATOR_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateCreatorResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_CREATOR_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateCreatorResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_CREATOR_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ },
+ Err(e) => Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't read body parameter entity: {}", e)))
+ .expect("Unable to create Bad Request response due to unable to read body parameter entity"))),
+ }
+ })
+ ) as Self::Future
+ }
+
+ // UpdateEditgroup - PUT /editgroup/{editgroup_id}
+ &hyper::Method::PUT if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_EDITGROUP_EDITGROUP_ID
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID.as_str())
+ );
+
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
+ Ok(param_editgroup_id) => param_editgroup_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_submit = query_params
+ .iter()
+ .filter(|e| e.0 == "submit")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_submit = param_submit.and_then(|param_submit| param_submit.parse().ok());
+
+ // Body parameters (note that non-required body parameters will ignore garbage
+ // values, rather than causing a 400 response). Produce warning header and logs for
+ // any unused fields.
+ Box::new(body.concat2()
+ .then(move |result| -> Self::Future {
+ match result {
+ Ok(body) => {
+ let mut unused_elements = Vec::new();
+ let param_editgroup: Option<models::Editgroup> = if !body.is_empty() {
+ let deserializer = &mut serde_json::Deserializer::from_slice(&*body);
+ match serde_ignored::deserialize(deserializer, |path| {
+ warn!("Ignoring unknown field in body: {}", path);
+ unused_elements.push(path.to_string());
+ }) {
+ Ok(param_editgroup) => param_editgroup,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse body parameter editgroup - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid body parameter editgroup due to schema"))),
+ }
+ } else {
+ None
+ };
+ let param_editgroup = match param_editgroup {
+ Some(param_editgroup) => param_editgroup,
+ None => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from("Missing required body parameter editgroup"))
+ .expect("Unable to create Bad Request response for missing body parameter editgroup"))),
+ };
+
+ Box::new(
+ api_impl.update_editgroup(
+ param_editgroup_id,
+ param_editgroup,
+ param_submit,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ if !unused_elements.is_empty() {
+ response.headers_mut().insert(
+ HeaderName::from_static("warning"),
+ HeaderValue::from_str(format!("Ignoring unknown fields in body: {:?}", unused_elements).as_str())
+ .expect("Unable to create Warning header value"));
+ }
+
+ match result {
+ Ok(rsp) => match rsp {
+ UpdateEditgroupResponse::UpdatedEditgroup
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_EDITGROUP_UPDATED_EDITGROUP"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateEditgroupResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_EDITGROUP_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateEditgroupResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_EDITGROUP_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateEditgroupResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_EDITGROUP_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateEditgroupResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_EDITGROUP_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateEditgroupResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_EDITGROUP_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ },
+ Err(e) => Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't read body parameter editgroup: {}", e)))
+ .expect("Unable to create Bad Request response due to unable to read body parameter editgroup"))),
+ }
+ })
+ ) as Self::Future
+ }
+
+ // UpdateEditor - PUT /editor/{editor_id}
+ &hyper::Method::PUT if path.matched(paths::ID_EDITOR_EDITOR_ID) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_EDITOR_EDITOR_ID
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE EDITOR_EDITOR_ID in set but failed match against \"{}\"", path, paths::REGEX_EDITOR_EDITOR_ID.as_str())
+ );
+
+ let param_editor_id = match percent_encoding::percent_decode(path_params["editor_id"].as_bytes()).decode_utf8() {
+ Ok(param_editor_id) => match param_editor_id.parse::<String>() {
+ Ok(param_editor_id) => param_editor_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter editor_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editor_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // 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.
+ Box::new(body.concat2()
+ .then(move |result| -> Self::Future {
+ match result {
+ Ok(body) => {
+ let mut unused_elements = Vec::new();
+ let param_editor: Option<models::Editor> = if !body.is_empty() {
+ let deserializer = &mut serde_json::Deserializer::from_slice(&*body);
+ match serde_ignored::deserialize(deserializer, |path| {
+ warn!("Ignoring unknown field in body: {}", path);
+ unused_elements.push(path.to_string());
+ }) {
+ Ok(param_editor) => param_editor,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse body parameter editor - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid body parameter editor due to schema"))),
+ }
+ } else {
+ None
+ };
+ let param_editor = match param_editor {
+ Some(param_editor) => param_editor,
+ None => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from("Missing required body parameter editor"))
+ .expect("Unable to create Bad Request response for missing body parameter editor"))),
+ };
+
+ Box::new(
+ api_impl.update_editor(
+ param_editor_id,
+ param_editor,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ if !unused_elements.is_empty() {
+ response.headers_mut().insert(
+ HeaderName::from_static("warning"),
+ HeaderValue::from_str(format!("Ignoring unknown fields in body: {:?}", unused_elements).as_str())
+ .expect("Unable to create Warning header value"));
+ }
+
+ match result {
+ Ok(rsp) => match rsp {
+ UpdateEditorResponse::UpdatedEditor
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_EDITOR_UPDATED_EDITOR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateEditorResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_EDITOR_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateEditorResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_EDITOR_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateEditorResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_EDITOR_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateEditorResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_EDITOR_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateEditorResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_EDITOR_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ },
+ Err(e) => Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't read body parameter editor: {}", e)))
+ .expect("Unable to create Bad Request response due to unable to read body parameter editor"))),
+ }
+ })
+ ) as Self::Future
+ }
+
+ // UpdateFile - PUT /editgroup/{editgroup_id}/file/{ident}
+ &hyper::Method::PUT if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILE_IDENT) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_EDITGROUP_EDITGROUP_ID_FILE_IDENT
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_FILE_IDENT in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_FILE_IDENT.as_str())
+ );
+
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
+ Ok(param_editgroup_id) => param_editgroup_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(param_ident) => match param_ident.parse::<String>() {
+ Ok(param_ident) => param_ident,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // 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.
+ Box::new(body.concat2()
+ .then(move |result| -> Self::Future {
+ match result {
+ Ok(body) => {
+ let mut unused_elements = Vec::new();
+ let param_entity: Option<models::FileEntity> = if !body.is_empty() {
+ let deserializer = &mut serde_json::Deserializer::from_slice(&*body);
+ match serde_ignored::deserialize(deserializer, |path| {
+ warn!("Ignoring unknown field in body: {}", path);
+ unused_elements.push(path.to_string());
+ }) {
+ Ok(param_entity) => param_entity,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse body parameter entity - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid body parameter entity due to schema"))),
+ }
+ } else {
+ None
+ };
+ let param_entity = match param_entity {
+ Some(param_entity) => param_entity,
+ None => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from("Missing required body parameter entity"))
+ .expect("Unable to create Bad Request response for missing body parameter entity"))),
+ };
+
+ Box::new(
+ api_impl.update_file(
+ param_editgroup_id,
+ param_ident,
+ param_entity,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ if !unused_elements.is_empty() {
+ response.headers_mut().insert(
+ HeaderName::from_static("warning"),
+ HeaderValue::from_str(format!("Ignoring unknown fields in body: {:?}", unused_elements).as_str())
+ .expect("Unable to create Warning header value"));
+ }
+
+ match result {
+ Ok(rsp) => match rsp {
+ UpdateFileResponse::UpdatedEntity
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_FILE_UPDATED_ENTITY"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateFileResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_FILE_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateFileResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_FILE_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateFileResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_FILE_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateFileResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_FILE_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateFileResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_FILE_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ },
+ Err(e) => Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't read body parameter entity: {}", e)))
+ .expect("Unable to create Bad Request response due to unable to read body parameter entity"))),
+ }
+ })
+ ) as Self::Future
+ }
+
+ // UpdateFileset - PUT /editgroup/{editgroup_id}/fileset/{ident}
+ &hyper::Method::PUT if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILESET_IDENT) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_EDITGROUP_EDITGROUP_ID_FILESET_IDENT
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_FILESET_IDENT in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_FILESET_IDENT.as_str())
+ );
+
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
+ Ok(param_editgroup_id) => param_editgroup_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(param_ident) => match param_ident.parse::<String>() {
+ Ok(param_ident) => param_ident,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // 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.
+ Box::new(body.concat2()
+ .then(move |result| -> Self::Future {
+ match result {
+ Ok(body) => {
+ let mut unused_elements = Vec::new();
+ let param_entity: Option<models::FilesetEntity> = if !body.is_empty() {
+ let deserializer = &mut serde_json::Deserializer::from_slice(&*body);
+ match serde_ignored::deserialize(deserializer, |path| {
+ warn!("Ignoring unknown field in body: {}", path);
+ unused_elements.push(path.to_string());
+ }) {
+ Ok(param_entity) => param_entity,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse body parameter entity - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid body parameter entity due to schema"))),
+ }
+ } else {
+ None
+ };
+ let param_entity = match param_entity {
+ Some(param_entity) => param_entity,
+ None => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from("Missing required body parameter entity"))
+ .expect("Unable to create Bad Request response for missing body parameter entity"))),
+ };
+
+ Box::new(
+ api_impl.update_fileset(
+ param_editgroup_id,
+ param_ident,
+ param_entity,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ if !unused_elements.is_empty() {
+ response.headers_mut().insert(
+ HeaderName::from_static("warning"),
+ HeaderValue::from_str(format!("Ignoring unknown fields in body: {:?}", unused_elements).as_str())
+ .expect("Unable to create Warning header value"));
+ }
+
+ match result {
+ Ok(rsp) => match rsp {
+ UpdateFilesetResponse::UpdatedEntity
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_FILESET_UPDATED_ENTITY"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateFilesetResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_FILESET_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateFilesetResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_FILESET_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateFilesetResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_FILESET_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateFilesetResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_FILESET_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateFilesetResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_FILESET_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ },
+ Err(e) => Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't read body parameter entity: {}", e)))
+ .expect("Unable to create Bad Request response due to unable to read body parameter entity"))),
+ }
+ })
+ ) as Self::Future
+ }
+
+ // UpdateRelease - PUT /editgroup/{editgroup_id}/release/{ident}
+ &hyper::Method::PUT if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_RELEASE_IDENT) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_EDITGROUP_EDITGROUP_ID_RELEASE_IDENT
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_RELEASE_IDENT in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_RELEASE_IDENT.as_str())
+ );
+
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
+ Ok(param_editgroup_id) => param_editgroup_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(param_ident) => match param_ident.parse::<String>() {
+ Ok(param_ident) => param_ident,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // 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.
+ Box::new(body.concat2()
+ .then(move |result| -> Self::Future {
+ match result {
+ Ok(body) => {
+ let mut unused_elements = Vec::new();
+ let param_entity: Option<models::ReleaseEntity> = if !body.is_empty() {
+ let deserializer = &mut serde_json::Deserializer::from_slice(&*body);
+ match serde_ignored::deserialize(deserializer, |path| {
+ warn!("Ignoring unknown field in body: {}", path);
+ unused_elements.push(path.to_string());
+ }) {
+ Ok(param_entity) => param_entity,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse body parameter entity - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid body parameter entity due to schema"))),
+ }
+ } else {
+ None
+ };
+ let param_entity = match param_entity {
+ Some(param_entity) => param_entity,
+ None => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from("Missing required body parameter entity"))
+ .expect("Unable to create Bad Request response for missing body parameter entity"))),
+ };
+
+ Box::new(
+ api_impl.update_release(
+ param_editgroup_id,
+ param_ident,
+ param_entity,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ if !unused_elements.is_empty() {
+ response.headers_mut().insert(
+ HeaderName::from_static("warning"),
+ HeaderValue::from_str(format!("Ignoring unknown fields in body: {:?}", unused_elements).as_str())
+ .expect("Unable to create Warning header value"));
+ }
+
+ match result {
+ Ok(rsp) => match rsp {
+ UpdateReleaseResponse::UpdatedEntity
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_RELEASE_UPDATED_ENTITY"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateReleaseResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_RELEASE_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateReleaseResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_RELEASE_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateReleaseResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_RELEASE_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateReleaseResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_RELEASE_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateReleaseResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_RELEASE_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ },
+ Err(e) => Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't read body parameter entity: {}", e)))
+ .expect("Unable to create Bad Request response due to unable to read body parameter entity"))),
+ }
+ })
+ ) as Self::Future
+ }
+
+ // UpdateWebcapture - PUT /editgroup/{editgroup_id}/webcapture/{ident}
+ &hyper::Method::PUT
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WEBCAPTURE_IDENT) =>
+ {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_EDITGROUP_EDITGROUP_ID_WEBCAPTURE_IDENT
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_WEBCAPTURE_IDENT in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_WEBCAPTURE_IDENT.as_str())
+ );
+
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
+ Ok(param_editgroup_id) => param_editgroup_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(param_ident) => match param_ident.parse::<String>() {
+ Ok(param_ident) => param_ident,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // 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.
+ Box::new(body.concat2()
+ .then(move |result| -> Self::Future {
+ match result {
+ Ok(body) => {
+ let mut unused_elements = Vec::new();
+ let param_entity: Option<models::WebcaptureEntity> = if !body.is_empty() {
+ let deserializer = &mut serde_json::Deserializer::from_slice(&*body);
+ match serde_ignored::deserialize(deserializer, |path| {
+ warn!("Ignoring unknown field in body: {}", path);
+ unused_elements.push(path.to_string());
+ }) {
+ Ok(param_entity) => param_entity,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse body parameter entity - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid body parameter entity due to schema"))),
+ }
+ } else {
+ None
+ };
+ let param_entity = match param_entity {
+ Some(param_entity) => param_entity,
+ None => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from("Missing required body parameter entity"))
+ .expect("Unable to create Bad Request response for missing body parameter entity"))),
+ };
+
+ Box::new(
+ api_impl.update_webcapture(
+ param_editgroup_id,
+ param_ident,
+ param_entity,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ if !unused_elements.is_empty() {
+ response.headers_mut().insert(
+ HeaderName::from_static("warning"),
+ HeaderValue::from_str(format!("Ignoring unknown fields in body: {:?}", unused_elements).as_str())
+ .expect("Unable to create Warning header value"));
+ }
+
+ match result {
+ Ok(rsp) => match rsp {
+ UpdateWebcaptureResponse::UpdatedEntity
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_WEBCAPTURE_UPDATED_ENTITY"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateWebcaptureResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_WEBCAPTURE_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateWebcaptureResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_WEBCAPTURE_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateWebcaptureResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_WEBCAPTURE_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateWebcaptureResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_WEBCAPTURE_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateWebcaptureResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_WEBCAPTURE_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ },
+ Err(e) => Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't read body parameter entity: {}", e)))
+ .expect("Unable to create Bad Request response due to unable to read body parameter entity"))),
+ }
+ })
+ ) as Self::Future
+ }
+
+ // UpdateWork - PUT /editgroup/{editgroup_id}/work/{ident}
+ &hyper::Method::PUT if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WORK_IDENT) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"),
+ ))
+ }
+ };
+ }
+
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_EDITGROUP_EDITGROUP_ID_WORK_IDENT
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_WORK_IDENT in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_WORK_IDENT.as_str())
+ );
+
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
+ Ok(param_editgroup_id) => param_editgroup_id,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(param_ident) => match param_ident.parse::<String>() {
+ Ok(param_ident) => param_ident,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
+ .expect("Unable to create Bad Request response for invalid path parameter"))),
+ },
+ Err(_) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
+ .expect("Unable to create Bad Request response for invalid percent decode")))
+ };
+
+ // 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.
+ Box::new(body.concat2()
+ .then(move |result| -> Self::Future {
+ match result {
+ Ok(body) => {
+ let mut unused_elements = Vec::new();
+ let param_entity: Option<models::WorkEntity> = if !body.is_empty() {
+ let deserializer = &mut serde_json::Deserializer::from_slice(&*body);
+ match serde_ignored::deserialize(deserializer, |path| {
+ warn!("Ignoring unknown field in body: {}", path);
+ unused_elements.push(path.to_string());
+ }) {
+ Ok(param_entity) => param_entity,
+ Err(e) => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse body parameter entity - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid body parameter entity due to schema"))),
+ }
+ } else {
+ None
+ };
+ let param_entity = match param_entity {
+ Some(param_entity) => param_entity,
+ None => return Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from("Missing required body parameter entity"))
+ .expect("Unable to create Bad Request response for missing body parameter entity"))),
+ };
+
+ Box::new(
+ api_impl.update_work(
+ param_editgroup_id,
+ param_ident,
+ param_entity,
+ &context
+ ).then(move |result| {
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
+ .expect("Unable to create X-Span-ID header value"));
+
+ if !unused_elements.is_empty() {
+ response.headers_mut().insert(
+ HeaderName::from_static("warning"),
+ HeaderValue::from_str(format!("Ignoring unknown fields in body: {:?}", unused_elements).as_str())
+ .expect("Unable to create Warning header value"));
+ }
+
+ match result {
+ Ok(rsp) => match rsp {
+ UpdateWorkResponse::UpdatedEntity
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_WORK_UPDATED_ENTITY"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateWorkResponse::BadRequest
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_WORK_BAD_REQUEST"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateWorkResponse::NotAuthorized
+ {
+ body,
+ www_authenticate
+ }
+ => {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ Ok(val) => val,
+ Err(e) => {
+ return future::ok(Response::builder()
+ .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
+ .expect("Unable to create Internal Server Error for invalid response header"))
+ }
+ };
+
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate
+ );
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_WORK_NOT_AUTHORIZED"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateWorkResponse::Forbidden
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_WORK_FORBIDDEN"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateWorkResponse::NotFound
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_WORK_NOT_FOUND"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ UpdateWorkResponse::GenericError
+ (body)
+ => {
+ *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
+ CONTENT_TYPE,
+ HeaderValue::from_str("application/json")
+ .expect("Unable to create Content-Type header for UPDATE_WORK_GENERIC_ERROR"));
+ let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ },
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
+ },
+ }
+
+ future::ok(response)
+ }
+ ))
+ },
+ Err(e) => Box::new(future::ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't read body parameter entity: {}", e)))
+ .expect("Unable to create Bad Request response due to unable to read body parameter entity"))),
+ }
+ })
+ ) as Self::Future
+ }
+
+ _ if path.matched(paths::ID_AUTH_CHECK) => method_not_allowed(),
+ _ if path.matched(paths::ID_AUTH_OIDC) => method_not_allowed(),
+ _ if path.matched(paths::ID_AUTH_TOKEN_EDITOR_ID) => method_not_allowed(),
+ _ if path.matched(paths::ID_CHANGELOG) => method_not_allowed(),
+ _ if path.matched(paths::ID_CHANGELOG_INDEX) => method_not_allowed(),
+ _ if path.matched(paths::ID_CONTAINER_EDIT_EDIT_ID) => method_not_allowed(),
+ _ if path.matched(paths::ID_CONTAINER_LOOKUP) => method_not_allowed(),
+ _ if path.matched(paths::ID_CONTAINER_REV_REV_ID) => method_not_allowed(),
+ _ if path.matched(paths::ID_CONTAINER_IDENT) => method_not_allowed(),
+ _ if path.matched(paths::ID_CONTAINER_IDENT_HISTORY) => method_not_allowed(),
+ _ if path.matched(paths::ID_CONTAINER_IDENT_REDIRECTS) => method_not_allowed(),
+ _ if path.matched(paths::ID_CREATOR_EDIT_EDIT_ID) => method_not_allowed(),
+ _ if path.matched(paths::ID_CREATOR_LOOKUP) => method_not_allowed(),
+ _ if path.matched(paths::ID_CREATOR_REV_REV_ID) => method_not_allowed(),
+ _ if path.matched(paths::ID_CREATOR_IDENT) => method_not_allowed(),
+ _ if path.matched(paths::ID_CREATOR_IDENT_HISTORY) => method_not_allowed(),
+ _ if path.matched(paths::ID_CREATOR_IDENT_REDIRECTS) => method_not_allowed(),
+ _ if path.matched(paths::ID_CREATOR_IDENT_RELEASES) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITGROUP) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITGROUP_AUTO_CONTAINER_BATCH) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITGROUP_AUTO_CREATOR_BATCH) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITGROUP_AUTO_FILE_BATCH) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITGROUP_AUTO_FILESET_BATCH) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITGROUP_AUTO_RELEASE_BATCH) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITGROUP_AUTO_WEBCAPTURE_BATCH) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITGROUP_AUTO_WORK_BATCH) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITGROUP_REVIEWABLE) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_ACCEPT) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_ANNOTATION) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_ANNOTATIONS) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CONTAINER) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CONTAINER_EDIT_EDIT_ID) => {
+ method_not_allowed()
+ }
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CONTAINER_IDENT) => {
+ method_not_allowed()
+ }
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CREATOR) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CREATOR_EDIT_EDIT_ID) => {
+ method_not_allowed()
+ }
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CREATOR_IDENT) => {
+ method_not_allowed()
+ }
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILE) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILE_EDIT_EDIT_ID) => {
+ method_not_allowed()
+ }
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILE_IDENT) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILESET) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILESET_EDIT_EDIT_ID) => {
+ method_not_allowed()
+ }
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILESET_IDENT) => {
+ method_not_allowed()
+ }
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_RELEASE) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_RELEASE_EDIT_EDIT_ID) => {
+ method_not_allowed()
+ }
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_RELEASE_IDENT) => {
+ method_not_allowed()
+ }
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WEBCAPTURE) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WEBCAPTURE_EDIT_EDIT_ID) => {
+ method_not_allowed()
+ }
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WEBCAPTURE_IDENT) => {
+ method_not_allowed()
+ }
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WORK) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WORK_EDIT_EDIT_ID) => {
+ method_not_allowed()
+ }
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WORK_IDENT) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITOR_EDITOR_ID) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITOR_EDITOR_ID_ANNOTATIONS) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITOR_EDITOR_ID_EDITGROUPS) => method_not_allowed(),
+ _ if path.matched(paths::ID_FILE_EDIT_EDIT_ID) => method_not_allowed(),
+ _ if path.matched(paths::ID_FILE_LOOKUP) => method_not_allowed(),
+ _ if path.matched(paths::ID_FILE_REV_REV_ID) => method_not_allowed(),
+ _ if path.matched(paths::ID_FILE_IDENT) => method_not_allowed(),
+ _ if path.matched(paths::ID_FILE_IDENT_HISTORY) => method_not_allowed(),
+ _ if path.matched(paths::ID_FILE_IDENT_REDIRECTS) => method_not_allowed(),
+ _ if path.matched(paths::ID_FILESET_EDIT_EDIT_ID) => method_not_allowed(),
+ _ if path.matched(paths::ID_FILESET_REV_REV_ID) => method_not_allowed(),
+ _ if path.matched(paths::ID_FILESET_IDENT) => method_not_allowed(),
+ _ if path.matched(paths::ID_FILESET_IDENT_HISTORY) => method_not_allowed(),
+ _ if path.matched(paths::ID_FILESET_IDENT_REDIRECTS) => method_not_allowed(),
+ _ if path.matched(paths::ID_RELEASE_EDIT_EDIT_ID) => method_not_allowed(),
+ _ if path.matched(paths::ID_RELEASE_LOOKUP) => method_not_allowed(),
+ _ if path.matched(paths::ID_RELEASE_REV_REV_ID) => method_not_allowed(),
+ _ if path.matched(paths::ID_RELEASE_IDENT) => method_not_allowed(),
+ _ if path.matched(paths::ID_RELEASE_IDENT_FILES) => method_not_allowed(),
+ _ if path.matched(paths::ID_RELEASE_IDENT_FILESETS) => method_not_allowed(),
+ _ if path.matched(paths::ID_RELEASE_IDENT_HISTORY) => method_not_allowed(),
+ _ if path.matched(paths::ID_RELEASE_IDENT_REDIRECTS) => method_not_allowed(),
+ _ if path.matched(paths::ID_RELEASE_IDENT_WEBCAPTURES) => method_not_allowed(),
+ _ if path.matched(paths::ID_WEBCAPTURE_EDIT_EDIT_ID) => method_not_allowed(),
+ _ if path.matched(paths::ID_WEBCAPTURE_REV_REV_ID) => method_not_allowed(),
+ _ if path.matched(paths::ID_WEBCAPTURE_IDENT) => method_not_allowed(),
+ _ if path.matched(paths::ID_WEBCAPTURE_IDENT_HISTORY) => method_not_allowed(),
+ _ if path.matched(paths::ID_WEBCAPTURE_IDENT_REDIRECTS) => method_not_allowed(),
+ _ if path.matched(paths::ID_WORK_EDIT_EDIT_ID) => method_not_allowed(),
+ _ if path.matched(paths::ID_WORK_REV_REV_ID) => method_not_allowed(),
+ _ if path.matched(paths::ID_WORK_IDENT) => method_not_allowed(),
+ _ if path.matched(paths::ID_WORK_IDENT_HISTORY) => method_not_allowed(),
+ _ if path.matched(paths::ID_WORK_IDENT_REDIRECTS) => method_not_allowed(),
+ _ if path.matched(paths::ID_WORK_IDENT_RELEASES) => method_not_allowed(),
+ _ => Box::new(future::ok(
+ Response::builder()
+ .status(StatusCode::NOT_FOUND)
+ .body(Body::empty())
+ .expect("Unable to create Not Found response"),
+ )) as Self::Future,
+ }
+ }
+}
+
+impl<T, C> Clone for Service<T, C>
+where
+ T: Clone,
+{
+ fn clone(&self) -> Self {
+ Service {
+ api_impl: self.api_impl.clone(),
+ marker: self.marker.clone(),
+ }
+ }
+}
+
+/// Request parser for `Api`.
+pub struct ApiRequestParser;
+impl<T> RequestParser<T> for ApiRequestParser {
+ fn parse_operation_id(request: &Request<T>) -> Result<&'static str, ()> {
+ let path = paths::GLOBAL_REGEX_SET.matches(request.uri().path());
+ match request.method() {
+ // AcceptEditgroup - POST /editgroup/{editgroup_id}/accept
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_ACCEPT) => {
+ Ok("AcceptEditgroup")
+ }
+ // AuthCheck - GET /auth/check
+ &hyper::Method::GET if path.matched(paths::ID_AUTH_CHECK) => Ok("AuthCheck"),
+ // AuthOidc - POST /auth/oidc
+ &hyper::Method::POST if path.matched(paths::ID_AUTH_OIDC) => Ok("AuthOidc"),
+ // CreateAuthToken - POST /auth/token/{editor_id}
+ &hyper::Method::POST if path.matched(paths::ID_AUTH_TOKEN_EDITOR_ID) => {
+ Ok("CreateAuthToken")
+ }
+ // CreateContainer - POST /editgroup/{editgroup_id}/container
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CONTAINER) => {
+ Ok("CreateContainer")
+ }
+ // CreateContainerAutoBatch - POST /editgroup/auto/container/batch
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_AUTO_CONTAINER_BATCH) => {
+ Ok("CreateContainerAutoBatch")
+ }
+ // CreateCreator - POST /editgroup/{editgroup_id}/creator
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CREATOR) => {
+ Ok("CreateCreator")
+ }
+ // CreateCreatorAutoBatch - POST /editgroup/auto/creator/batch
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_AUTO_CREATOR_BATCH) => {
+ Ok("CreateCreatorAutoBatch")
+ }
+ // CreateEditgroup - POST /editgroup
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP) => Ok("CreateEditgroup"),
+ // CreateEditgroupAnnotation - POST /editgroup/{editgroup_id}/annotation
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_ANNOTATION) => {
+ Ok("CreateEditgroupAnnotation")
+ }
+ // CreateFile - POST /editgroup/{editgroup_id}/file
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILE) => {
+ Ok("CreateFile")
+ }
+ // CreateFileAutoBatch - POST /editgroup/auto/file/batch
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_AUTO_FILE_BATCH) => {
+ Ok("CreateFileAutoBatch")
+ }
+ // CreateFileset - POST /editgroup/{editgroup_id}/fileset
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILESET) => {
+ Ok("CreateFileset")
+ }
+ // CreateFilesetAutoBatch - POST /editgroup/auto/fileset/batch
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_AUTO_FILESET_BATCH) => {
+ Ok("CreateFilesetAutoBatch")
+ }
+ // CreateRelease - POST /editgroup/{editgroup_id}/release
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_RELEASE) => {
+ Ok("CreateRelease")
+ }
+ // CreateReleaseAutoBatch - POST /editgroup/auto/release/batch
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_AUTO_RELEASE_BATCH) => {
+ Ok("CreateReleaseAutoBatch")
+ }
+ // CreateWebcapture - POST /editgroup/{editgroup_id}/webcapture
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WEBCAPTURE) => {
+ Ok("CreateWebcapture")
+ }
+ // CreateWebcaptureAutoBatch - POST /editgroup/auto/webcapture/batch
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_AUTO_WEBCAPTURE_BATCH) => {
+ Ok("CreateWebcaptureAutoBatch")
+ }
+ // CreateWork - POST /editgroup/{editgroup_id}/work
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WORK) => {
+ Ok("CreateWork")
+ }
+ // CreateWorkAutoBatch - POST /editgroup/auto/work/batch
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_AUTO_WORK_BATCH) => {
+ Ok("CreateWorkAutoBatch")
+ }
+ // DeleteContainer - DELETE /editgroup/{editgroup_id}/container/{ident}
+ &hyper::Method::DELETE
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CONTAINER_IDENT) =>
+ {
+ Ok("DeleteContainer")
+ }
+ // DeleteContainerEdit - DELETE /editgroup/{editgroup_id}/container/edit/{edit_id}
+ &hyper::Method::DELETE
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CONTAINER_EDIT_EDIT_ID) =>
+ {
+ Ok("DeleteContainerEdit")
+ }
+ // DeleteCreator - DELETE /editgroup/{editgroup_id}/creator/{ident}
+ &hyper::Method::DELETE
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CREATOR_IDENT) =>
+ {
+ Ok("DeleteCreator")
+ }
+ // DeleteCreatorEdit - DELETE /editgroup/{editgroup_id}/creator/edit/{edit_id}
+ &hyper::Method::DELETE
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CREATOR_EDIT_EDIT_ID) =>
+ {
+ Ok("DeleteCreatorEdit")
+ }
+ // DeleteFile - DELETE /editgroup/{editgroup_id}/file/{ident}
+ &hyper::Method::DELETE if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILE_IDENT) => {
+ Ok("DeleteFile")
+ }
+ // DeleteFileEdit - DELETE /editgroup/{editgroup_id}/file/edit/{edit_id}
+ &hyper::Method::DELETE
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILE_EDIT_EDIT_ID) =>
+ {
+ Ok("DeleteFileEdit")
+ }
+ // DeleteFileset - DELETE /editgroup/{editgroup_id}/fileset/{ident}
+ &hyper::Method::DELETE
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILESET_IDENT) =>
+ {
+ Ok("DeleteFileset")
+ }
+ // DeleteFilesetEdit - DELETE /editgroup/{editgroup_id}/fileset/edit/{edit_id}
+ &hyper::Method::DELETE
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILESET_EDIT_EDIT_ID) =>
+ {
+ Ok("DeleteFilesetEdit")
+ }
+ // DeleteRelease - DELETE /editgroup/{editgroup_id}/release/{ident}
+ &hyper::Method::DELETE
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_RELEASE_IDENT) =>
+ {
+ Ok("DeleteRelease")
+ }
+ // DeleteReleaseEdit - DELETE /editgroup/{editgroup_id}/release/edit/{edit_id}
+ &hyper::Method::DELETE
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_RELEASE_EDIT_EDIT_ID) =>
+ {
+ Ok("DeleteReleaseEdit")
+ }
+ // DeleteWebcapture - DELETE /editgroup/{editgroup_id}/webcapture/{ident}
+ &hyper::Method::DELETE
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WEBCAPTURE_IDENT) =>
+ {
+ Ok("DeleteWebcapture")
+ }
+ // DeleteWebcaptureEdit - DELETE /editgroup/{editgroup_id}/webcapture/edit/{edit_id}
+ &hyper::Method::DELETE
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WEBCAPTURE_EDIT_EDIT_ID) =>
+ {
+ Ok("DeleteWebcaptureEdit")
+ }
+ // DeleteWork - DELETE /editgroup/{editgroup_id}/work/{ident}
+ &hyper::Method::DELETE if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WORK_IDENT) => {
+ Ok("DeleteWork")
+ }
+ // DeleteWorkEdit - DELETE /editgroup/{editgroup_id}/work/edit/{edit_id}
+ &hyper::Method::DELETE
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WORK_EDIT_EDIT_ID) =>
+ {
+ Ok("DeleteWorkEdit")
+ }
+ // GetChangelog - GET /changelog
+ &hyper::Method::GET if path.matched(paths::ID_CHANGELOG) => Ok("GetChangelog"),
+ // GetChangelogEntry - GET /changelog/{index}
+ &hyper::Method::GET if path.matched(paths::ID_CHANGELOG_INDEX) => {
+ Ok("GetChangelogEntry")
+ }
+ // GetContainer - GET /container/{ident}
+ &hyper::Method::GET if path.matched(paths::ID_CONTAINER_IDENT) => Ok("GetContainer"),
+ // GetContainerEdit - GET /container/edit/{edit_id}
+ &hyper::Method::GET if path.matched(paths::ID_CONTAINER_EDIT_EDIT_ID) => {
+ Ok("GetContainerEdit")
+ }
+ // GetContainerHistory - GET /container/{ident}/history
+ &hyper::Method::GET if path.matched(paths::ID_CONTAINER_IDENT_HISTORY) => {
+ Ok("GetContainerHistory")
+ }
+ // GetContainerRedirects - GET /container/{ident}/redirects
+ &hyper::Method::GET if path.matched(paths::ID_CONTAINER_IDENT_REDIRECTS) => {
+ Ok("GetContainerRedirects")
+ }
+ // GetContainerRevision - GET /container/rev/{rev_id}
+ &hyper::Method::GET if path.matched(paths::ID_CONTAINER_REV_REV_ID) => {
+ Ok("GetContainerRevision")
+ }
+ // GetCreator - GET /creator/{ident}
+ &hyper::Method::GET if path.matched(paths::ID_CREATOR_IDENT) => Ok("GetCreator"),
+ // GetCreatorEdit - GET /creator/edit/{edit_id}
+ &hyper::Method::GET if path.matched(paths::ID_CREATOR_EDIT_EDIT_ID) => {
+ Ok("GetCreatorEdit")
+ }
+ // GetCreatorHistory - GET /creator/{ident}/history
+ &hyper::Method::GET if path.matched(paths::ID_CREATOR_IDENT_HISTORY) => {
+ Ok("GetCreatorHistory")
+ }
+ // GetCreatorRedirects - GET /creator/{ident}/redirects
+ &hyper::Method::GET if path.matched(paths::ID_CREATOR_IDENT_REDIRECTS) => {
+ Ok("GetCreatorRedirects")
+ }
+ // GetCreatorReleases - GET /creator/{ident}/releases
+ &hyper::Method::GET if path.matched(paths::ID_CREATOR_IDENT_RELEASES) => {
+ Ok("GetCreatorReleases")
+ }
+ // GetCreatorRevision - GET /creator/rev/{rev_id}
+ &hyper::Method::GET if path.matched(paths::ID_CREATOR_REV_REV_ID) => {
+ Ok("GetCreatorRevision")
+ }
+ // GetEditgroup - GET /editgroup/{editgroup_id}
+ &hyper::Method::GET if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID) => {
+ Ok("GetEditgroup")
+ }
+ // GetEditgroupAnnotations - GET /editgroup/{editgroup_id}/annotations
+ &hyper::Method::GET if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_ANNOTATIONS) => {
+ Ok("GetEditgroupAnnotations")
+ }
+ // GetEditgroupsReviewable - GET /editgroup/reviewable
+ &hyper::Method::GET if path.matched(paths::ID_EDITGROUP_REVIEWABLE) => {
+ Ok("GetEditgroupsReviewable")
+ }
+ // GetEditor - GET /editor/{editor_id}
+ &hyper::Method::GET if path.matched(paths::ID_EDITOR_EDITOR_ID) => Ok("GetEditor"),
+ // GetEditorAnnotations - GET /editor/{editor_id}/annotations
+ &hyper::Method::GET if path.matched(paths::ID_EDITOR_EDITOR_ID_ANNOTATIONS) => {
+ Ok("GetEditorAnnotations")
+ }
+ // GetEditorEditgroups - GET /editor/{editor_id}/editgroups
+ &hyper::Method::GET if path.matched(paths::ID_EDITOR_EDITOR_ID_EDITGROUPS) => {
+ Ok("GetEditorEditgroups")
+ }
+ // GetFile - GET /file/{ident}
+ &hyper::Method::GET if path.matched(paths::ID_FILE_IDENT) => Ok("GetFile"),
+ // GetFileEdit - GET /file/edit/{edit_id}
+ &hyper::Method::GET if path.matched(paths::ID_FILE_EDIT_EDIT_ID) => Ok("GetFileEdit"),
+ // GetFileHistory - GET /file/{ident}/history
+ &hyper::Method::GET if path.matched(paths::ID_FILE_IDENT_HISTORY) => {
+ Ok("GetFileHistory")
+ }
+ // GetFileRedirects - GET /file/{ident}/redirects
+ &hyper::Method::GET if path.matched(paths::ID_FILE_IDENT_REDIRECTS) => {
+ Ok("GetFileRedirects")
+ }
+ // GetFileRevision - GET /file/rev/{rev_id}
+ &hyper::Method::GET if path.matched(paths::ID_FILE_REV_REV_ID) => Ok("GetFileRevision"),
+ // GetFileset - GET /fileset/{ident}
+ &hyper::Method::GET if path.matched(paths::ID_FILESET_IDENT) => Ok("GetFileset"),
+ // GetFilesetEdit - GET /fileset/edit/{edit_id}
+ &hyper::Method::GET if path.matched(paths::ID_FILESET_EDIT_EDIT_ID) => {
+ Ok("GetFilesetEdit")
+ }
+ // GetFilesetHistory - GET /fileset/{ident}/history
+ &hyper::Method::GET if path.matched(paths::ID_FILESET_IDENT_HISTORY) => {
+ Ok("GetFilesetHistory")
+ }
+ // GetFilesetRedirects - GET /fileset/{ident}/redirects
+ &hyper::Method::GET if path.matched(paths::ID_FILESET_IDENT_REDIRECTS) => {
+ Ok("GetFilesetRedirects")
+ }
+ // GetFilesetRevision - GET /fileset/rev/{rev_id}
+ &hyper::Method::GET if path.matched(paths::ID_FILESET_REV_REV_ID) => {
+ Ok("GetFilesetRevision")
+ }
+ // GetRelease - GET /release/{ident}
+ &hyper::Method::GET if path.matched(paths::ID_RELEASE_IDENT) => Ok("GetRelease"),
+ // GetReleaseEdit - GET /release/edit/{edit_id}
+ &hyper::Method::GET if path.matched(paths::ID_RELEASE_EDIT_EDIT_ID) => {
+ Ok("GetReleaseEdit")
+ }
+ // GetReleaseFiles - GET /release/{ident}/files
+ &hyper::Method::GET if path.matched(paths::ID_RELEASE_IDENT_FILES) => {
+ Ok("GetReleaseFiles")
+ }
+ // GetReleaseFilesets - GET /release/{ident}/filesets
+ &hyper::Method::GET if path.matched(paths::ID_RELEASE_IDENT_FILESETS) => {
+ Ok("GetReleaseFilesets")
+ }
+ // GetReleaseHistory - GET /release/{ident}/history
+ &hyper::Method::GET if path.matched(paths::ID_RELEASE_IDENT_HISTORY) => {
+ Ok("GetReleaseHistory")
+ }
+ // GetReleaseRedirects - GET /release/{ident}/redirects
+ &hyper::Method::GET if path.matched(paths::ID_RELEASE_IDENT_REDIRECTS) => {
+ Ok("GetReleaseRedirects")
+ }
+ // GetReleaseRevision - GET /release/rev/{rev_id}
+ &hyper::Method::GET if path.matched(paths::ID_RELEASE_REV_REV_ID) => {
+ Ok("GetReleaseRevision")
+ }
+ // GetReleaseWebcaptures - GET /release/{ident}/webcaptures
+ &hyper::Method::GET if path.matched(paths::ID_RELEASE_IDENT_WEBCAPTURES) => {
+ Ok("GetReleaseWebcaptures")
+ }
+ // GetWebcapture - GET /webcapture/{ident}
+ &hyper::Method::GET if path.matched(paths::ID_WEBCAPTURE_IDENT) => Ok("GetWebcapture"),
+ // GetWebcaptureEdit - GET /webcapture/edit/{edit_id}
+ &hyper::Method::GET if path.matched(paths::ID_WEBCAPTURE_EDIT_EDIT_ID) => {
+ Ok("GetWebcaptureEdit")
+ }
+ // GetWebcaptureHistory - GET /webcapture/{ident}/history
+ &hyper::Method::GET if path.matched(paths::ID_WEBCAPTURE_IDENT_HISTORY) => {
+ Ok("GetWebcaptureHistory")
+ }
+ // GetWebcaptureRedirects - GET /webcapture/{ident}/redirects
+ &hyper::Method::GET if path.matched(paths::ID_WEBCAPTURE_IDENT_REDIRECTS) => {
+ Ok("GetWebcaptureRedirects")
+ }
+ // GetWebcaptureRevision - GET /webcapture/rev/{rev_id}
+ &hyper::Method::GET if path.matched(paths::ID_WEBCAPTURE_REV_REV_ID) => {
+ Ok("GetWebcaptureRevision")
+ }
+ // GetWork - GET /work/{ident}
+ &hyper::Method::GET if path.matched(paths::ID_WORK_IDENT) => Ok("GetWork"),
+ // GetWorkEdit - GET /work/edit/{edit_id}
+ &hyper::Method::GET if path.matched(paths::ID_WORK_EDIT_EDIT_ID) => Ok("GetWorkEdit"),
+ // GetWorkHistory - GET /work/{ident}/history
+ &hyper::Method::GET if path.matched(paths::ID_WORK_IDENT_HISTORY) => {
+ Ok("GetWorkHistory")
+ }
+ // GetWorkRedirects - GET /work/{ident}/redirects
+ &hyper::Method::GET if path.matched(paths::ID_WORK_IDENT_REDIRECTS) => {
+ Ok("GetWorkRedirects")
+ }
+ // GetWorkReleases - GET /work/{ident}/releases
+ &hyper::Method::GET if path.matched(paths::ID_WORK_IDENT_RELEASES) => {
+ Ok("GetWorkReleases")
+ }
+ // GetWorkRevision - GET /work/rev/{rev_id}
+ &hyper::Method::GET if path.matched(paths::ID_WORK_REV_REV_ID) => Ok("GetWorkRevision"),
+ // LookupContainer - GET /container/lookup
+ &hyper::Method::GET if path.matched(paths::ID_CONTAINER_LOOKUP) => {
+ Ok("LookupContainer")
+ }
+ // LookupCreator - GET /creator/lookup
+ &hyper::Method::GET if path.matched(paths::ID_CREATOR_LOOKUP) => Ok("LookupCreator"),
+ // LookupFile - GET /file/lookup
+ &hyper::Method::GET if path.matched(paths::ID_FILE_LOOKUP) => Ok("LookupFile"),
+ // LookupRelease - GET /release/lookup
+ &hyper::Method::GET if path.matched(paths::ID_RELEASE_LOOKUP) => Ok("LookupRelease"),
+ // UpdateContainer - PUT /editgroup/{editgroup_id}/container/{ident}
+ &hyper::Method::PUT
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CONTAINER_IDENT) =>
+ {
+ Ok("UpdateContainer")
+ }
+ // UpdateCreator - PUT /editgroup/{editgroup_id}/creator/{ident}
+ &hyper::Method::PUT if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CREATOR_IDENT) => {
+ Ok("UpdateCreator")
+ }
+ // UpdateEditgroup - PUT /editgroup/{editgroup_id}
+ &hyper::Method::PUT if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID) => {
+ Ok("UpdateEditgroup")
+ }
+ // UpdateEditor - PUT /editor/{editor_id}
+ &hyper::Method::PUT if path.matched(paths::ID_EDITOR_EDITOR_ID) => Ok("UpdateEditor"),
+ // UpdateFile - PUT /editgroup/{editgroup_id}/file/{ident}
+ &hyper::Method::PUT if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILE_IDENT) => {
+ Ok("UpdateFile")
+ }
+ // UpdateFileset - PUT /editgroup/{editgroup_id}/fileset/{ident}
+ &hyper::Method::PUT if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILESET_IDENT) => {
+ Ok("UpdateFileset")
+ }
+ // UpdateRelease - PUT /editgroup/{editgroup_id}/release/{ident}
+ &hyper::Method::PUT if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_RELEASE_IDENT) => {
+ Ok("UpdateRelease")
+ }
+ // UpdateWebcapture - PUT /editgroup/{editgroup_id}/webcapture/{ident}
+ &hyper::Method::PUT
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WEBCAPTURE_IDENT) =>
+ {
+ Ok("UpdateWebcapture")
+ }
+ // UpdateWork - PUT /editgroup/{editgroup_id}/work/{ident}
+ &hyper::Method::PUT if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WORK_IDENT) => {
+ Ok("UpdateWork")
+ }
+ _ => Err(()),
+ }
+ }
+}