summaryrefslogtreecommitdiffstats
path: root/fatcat-openapi/src/client/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'fatcat-openapi/src/client/mod.rs')
-rw-r--r--fatcat-openapi/src/client/mod.rs16107
1 files changed, 16107 insertions, 0 deletions
diff --git a/fatcat-openapi/src/client/mod.rs b/fatcat-openapi/src/client/mod.rs
new file mode 100644
index 0000000..bb1cee8
--- /dev/null
+++ b/fatcat-openapi/src/client/mod.rs
@@ -0,0 +1,16107 @@
+use async_trait::async_trait;
+use futures::{
+ future, future::BoxFuture, future::FutureExt, future::TryFutureExt, stream, stream::StreamExt,
+ Stream,
+};
+use hyper::header::{HeaderName, HeaderValue, CONTENT_TYPE};
+use hyper::{service::Service, Body, Request, Response, Uri};
+use percent_encoding::{utf8_percent_encode, AsciiSet};
+use std::borrow::Cow;
+use std::convert::TryInto;
+use std::error::Error;
+use std::fmt;
+use std::future::Future;
+use std::io::{ErrorKind, Read};
+use std::marker::PhantomData;
+use std::path::Path;
+use std::str;
+use std::str::FromStr;
+use std::string::ToString;
+use std::sync::{Arc, Mutex};
+use std::task::{Context, Poll};
+use swagger::{ApiError, AuthData, BodyExt, Connector, DropContextService, Has, XSpanIdString};
+use url::form_urlencoded;
+
+use crate::header;
+use crate::models;
+
+/// https://url.spec.whatwg.org/#fragment-percent-encode-set
+#[allow(dead_code)]
+const FRAGMENT_ENCODE_SET: &AsciiSet = &percent_encoding::CONTROLS
+ .add(b' ')
+ .add(b'"')
+ .add(b'<')
+ .add(b'>')
+ .add(b'`');
+
+/// 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.
+#[allow(dead_code)]
+const ID_ENCODE_SET: &AsciiSet = &FRAGMENT_ENCODE_SET.add(b'|');
+
+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: impl TryInto<Uri, Error = hyper::http::uri::InvalidUri>,
+ correct_scheme: Option<&'static str>,
+) -> Result<String, ClientInitError> {
+ // First convert to Uri, since a base path is a subset of Uri.
+ let uri = input.try_into()?;
+
+ let scheme = uri.scheme_str().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_u16()
+ .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<S, C>
+where
+ S: Service<(Request<Body>, C), Response = Response<Body>> + Clone + Sync + Send + 'static,
+ S::Future: Send + 'static,
+ S::Error: Into<crate::ServiceError> + fmt::Display,
+ C: Clone + Send + Sync + 'static,
+{
+ /// Inner service
+ client_service: S,
+
+ /// Base path of the API
+ base_path: String,
+
+ /// Marker
+ marker: PhantomData<fn(C)>,
+}
+
+impl<S, C> fmt::Debug for Client<S, C>
+where
+ S: Service<(Request<Body>, C), Response = Response<Body>> + Clone + Sync + Send + 'static,
+ S::Future: Send + 'static,
+ S::Error: Into<crate::ServiceError> + fmt::Display,
+ C: Clone + Send + Sync + 'static,
+{
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ write!(f, "Client {{ base_path: {} }}", self.base_path)
+ }
+}
+
+impl<S, C> Clone for Client<S, C>
+where
+ S: Service<(Request<Body>, C), Response = Response<Body>> + Clone + Sync + Send + 'static,
+ S::Future: Send + 'static,
+ S::Error: Into<crate::ServiceError> + fmt::Display,
+ C: Clone + Send + Sync + 'static,
+{
+ fn clone(&self) -> Self {
+ Self {
+ client_service: self.client_service.clone(),
+ base_path: self.base_path.clone(),
+ marker: PhantomData,
+ }
+ }
+}
+
+impl<Connector, C> Client<DropContextService<hyper::client::Client<Connector, Body>, C>, C>
+where
+ Connector: hyper::client::connect::Connect + Clone + Send + Sync + 'static,
+ C: Clone + Send + Sync + 'static,
+{
+ /// 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. "http://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(
+ base_path: &str,
+ protocol: Option<&'static str>,
+ connector: Connector,
+ ) -> Result<Self, ClientInitError> {
+ let client_service = hyper::client::Client::builder().build(connector);
+ let client_service = DropContextService::new(client_service);
+
+ Ok(Self {
+ client_service,
+ base_path: into_base_path(base_path, protocol)?,
+ marker: PhantomData,
+ })
+ }
+}
+
+#[derive(Debug, Clone)]
+pub enum HyperClient {
+ Http(hyper::client::Client<hyper::client::HttpConnector, Body>),
+ Https(hyper::client::Client<HttpsConnector, Body>),
+}
+
+impl Service<Request<Body>> for HyperClient {
+ type Response = Response<Body>;
+ type Error = hyper::Error;
+ type Future = hyper::client::ResponseFuture;
+
+ fn poll_ready(&mut self, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
+ match self {
+ HyperClient::Http(client) => client.poll_ready(cx),
+ HyperClient::Https(client) => client.poll_ready(cx),
+ }
+ }
+
+ fn call(&mut self, req: Request<Body>) -> Self::Future {
+ match self {
+ HyperClient::Http(client) => client.call(req),
+ HyperClient::Https(client) => client.call(req),
+ }
+ }
+}
+
+impl<C> Client<DropContextService<HyperClient, C>, C>
+where
+ C: Clone + Send + Sync + 'static,
+{
+ /// Create an HTTP client.
+ ///
+ /// # Arguments
+ /// * `base_path` - base path of the client API, i.e. "http://www.my-api-implementation.com"
+ pub fn try_new(base_path: &str) -> Result<Self, ClientInitError> {
+ let uri = Uri::from_str(base_path)?;
+
+ let scheme = uri.scheme_str().ok_or(ClientInitError::InvalidScheme)?;
+ let scheme = scheme.to_ascii_lowercase();
+
+ let connector = Connector::builder();
+
+ let client_service = match scheme.as_str() {
+ "http" => HyperClient::Http(hyper::client::Client::builder().build(connector.build())),
+ "https" => {
+ let connector = connector
+ .https()
+ .build()
+ .map_err(|e| ClientInitError::SslError(e))?;
+ HyperClient::Https(hyper::client::Client::builder().build(connector))
+ }
+ _ => {
+ return Err(ClientInitError::InvalidScheme);
+ }
+ };
+
+ let client_service = DropContextService::new(client_service);
+
+ Ok(Self {
+ client_service,
+ base_path: into_base_path(base_path, None)?,
+ marker: PhantomData,
+ })
+ }
+}
+
+impl<C> Client<DropContextService<hyper::client::Client<hyper::client::HttpConnector, Body>, C>, C>
+where
+ C: Clone + Send + Sync + 'static,
+{
+ /// Create an HTTP client.
+ ///
+ /// # Arguments
+ /// * `base_path` - base path of the client API, i.e. "http://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)
+ }
+}
+
+#[cfg(any(target_os = "macos", target_os = "windows", target_os = "ios"))]
+type HttpsConnector = hyper_tls::HttpsConnector<hyper::client::HttpConnector>;
+
+#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
+type HttpsConnector = hyper_openssl::HttpsConnector<hyper::client::HttpConnector>;
+
+impl<C> Client<DropContextService<hyper::client::Client<HttpsConnector, Body>, C>, C>
+where
+ C: Clone + Send + Sync + 'static,
+{
+ /// Create a client with a TLS connection to the server
+ ///
+ /// # Arguments
+ /// * `base_path` - base path of the client API, i.e. "https://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. "https://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. "https://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<S, C> Client<S, C>
+where
+ S: Service<(Request<Body>, C), Response = Response<Body>> + Clone + Sync + Send + 'static,
+ S::Future: Send + 'static,
+ S::Error: Into<crate::ServiceError> + fmt::Display,
+ C: Clone + Send + Sync + 'static,
+{
+ /// Constructor for creating a `Client` by passing in a pre-made `hyper::service::Service` /
+ /// `tower::Service`
+ ///
+ /// This allows adding custom wrappers around the underlying transport, for example for logging.
+ pub fn try_new_with_client_service(
+ client_service: S,
+ base_path: &str,
+ ) -> Result<Self, ClientInitError> {
+ Ok(Self {
+ client_service,
+ base_path: into_base_path(base_path, None)?,
+ marker: PhantomData,
+ })
+ }
+}
+
+/// 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 for ClientInitError {
+ fn description(&self) -> &str {
+ "Failed to produce a hyper client."
+ }
+}
+
+#[async_trait]
+impl<S, C> Api<C> for Client<S, C>
+where
+ S: Service<(Request<Body>, C), Response = Response<Body>> + Clone + Sync + Send + 'static,
+ S::Future: Send + 'static,
+ S::Error: Into<crate::ServiceError> + fmt::Display,
+ C: Has<XSpanIdString> + Has<Option<AuthData>> + Clone + Send + Sync + 'static,
+{
+ fn poll_ready(&self, cx: &mut Context) -> Poll<Result<(), crate::ServiceError>> {
+ match self.client_service.clone().poll_ready(cx) {
+ Poll::Ready(Err(e)) => Poll::Ready(Err(e.into())),
+ Poll::Ready(Ok(o)) => Poll::Ready(Ok(o)),
+ Poll::Pending => Poll::Pending,
+ }
+ }
+
+ async fn accept_editgroup(
+ &self,
+ param_editgroup_id: String,
+ context: &C,
+ ) -> Result<AcceptEditgroupResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("POST")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::Success>(body)?;
+ Ok(AcceptEditgroupResponse::MergedSuccessfully(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(AcceptEditgroupResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(AcceptEditgroupResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(AcceptEditgroupResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(AcceptEditgroupResponse::NotFound(body))
+ }
+ 409 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(AcceptEditgroupResponse::EditConflict(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(AcceptEditgroupResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn auth_check(
+ &self,
+ param_role: Option<String>,
+ context: &C,
+ ) -> Result<AuthCheckResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ let mut uri = format!("{}/v0/auth/check", self.base_path);
+
+ // Query parameters
+ let query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_role) = param_role {
+ query_string.append_pair("role", &param_role.to_string());
+ }
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::Success>(body)?;
+ Ok(AuthCheckResponse::Success(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(AuthCheckResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(AuthCheckResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(AuthCheckResponse::Forbidden(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(AuthCheckResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn auth_oidc(
+ &self,
+ param_auth_oidc: models::AuthOidc,
+ context: &C,
+ ) -> Result<AuthOidcResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ let mut uri = format!("{}/v0/auth/oidc", self.base_path);
+
+ // Query parameters
+ let query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("POST")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let body =
+ serde_json::to_string(&param_auth_oidc).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 Err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ )))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::AuthOidcResult>(body)?;
+ Ok(AuthOidcResponse::Found(body))
+ }
+ 201 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::AuthOidcResult>(body)?;
+ Ok(AuthOidcResponse::Created(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(AuthOidcResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(AuthOidcResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(AuthOidcResponse::Forbidden(body))
+ }
+ 409 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(AuthOidcResponse::Conflict(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(AuthOidcResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn create_auth_token(
+ &self,
+ param_editor_id: String,
+ param_duration_seconds: Option<i32>,
+ context: &C,
+ ) -> Result<CreateAuthTokenResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = 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());
+ }
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("POST")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::AuthTokenResult>(body)?;
+ Ok(CreateAuthTokenResponse::Success(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateAuthTokenResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateAuthTokenResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateAuthTokenResponse::Forbidden(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateAuthTokenResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn create_container(
+ &self,
+ param_editgroup_id: String,
+ param_container_entity: models::ContainerEntity,
+ context: &C,
+ ) -> Result<CreateContainerResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("POST")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let body = serde_json::to_string(&param_container_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 Err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ )))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 201 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::EntityEdit>(body)?;
+ Ok(CreateContainerResponse::CreatedEntity(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateContainerResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateContainerResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateContainerResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateContainerResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateContainerResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn create_container_auto_batch(
+ &self,
+ param_container_auto_batch: models::ContainerAutoBatch,
+ context: &C,
+ ) -> Result<CreateContainerAutoBatchResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ let mut uri = format!("{}/v0/editgroup/auto/container/batch", self.base_path);
+
+ // Query parameters
+ let query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("POST")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let body = serde_json::to_string(&param_container_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 Err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ )))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 201 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::Editgroup>(body)?;
+ Ok(CreateContainerAutoBatchResponse::CreatedEditgroup(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateContainerAutoBatchResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateContainerAutoBatchResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateContainerAutoBatchResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateContainerAutoBatchResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateContainerAutoBatchResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn create_creator(
+ &self,
+ param_editgroup_id: String,
+ param_creator_entity: models::CreatorEntity,
+ context: &C,
+ ) -> Result<CreateCreatorResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("POST")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let body =
+ serde_json::to_string(&param_creator_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 Err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ )))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 201 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::EntityEdit>(body)?;
+ Ok(CreateCreatorResponse::CreatedEntity(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateCreatorResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateCreatorResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateCreatorResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateCreatorResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateCreatorResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn create_creator_auto_batch(
+ &self,
+ param_creator_auto_batch: models::CreatorAutoBatch,
+ context: &C,
+ ) -> Result<CreateCreatorAutoBatchResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ let mut uri = format!("{}/v0/editgroup/auto/creator/batch", self.base_path);
+
+ // Query parameters
+ let query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("POST")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let body = serde_json::to_string(&param_creator_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 Err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ )))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 201 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::Editgroup>(body)?;
+ Ok(CreateCreatorAutoBatchResponse::CreatedEditgroup(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateCreatorAutoBatchResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateCreatorAutoBatchResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateCreatorAutoBatchResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateCreatorAutoBatchResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateCreatorAutoBatchResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn create_editgroup(
+ &self,
+ param_editgroup: models::Editgroup,
+ context: &C,
+ ) -> Result<CreateEditgroupResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ let mut uri = format!("{}/v0/editgroup", self.base_path);
+
+ // Query parameters
+ let query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("POST")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return 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 Err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ )))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 201 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::Editgroup>(body)?;
+ Ok(CreateEditgroupResponse::SuccessfullyCreated(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateEditgroupResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateEditgroupResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateEditgroupResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateEditgroupResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateEditgroupResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn create_editgroup_annotation(
+ &self,
+ param_editgroup_id: String,
+ param_editgroup_annotation: models::EditgroupAnnotation,
+ context: &C,
+ ) -> Result<CreateEditgroupAnnotationResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("POST")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let body = serde_json::to_string(&param_editgroup_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 Err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ )))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 201 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::EditgroupAnnotation>(body)?;
+ Ok(CreateEditgroupAnnotationResponse::Created(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateEditgroupAnnotationResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateEditgroupAnnotationResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateEditgroupAnnotationResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateEditgroupAnnotationResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateEditgroupAnnotationResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn create_file(
+ &self,
+ param_editgroup_id: String,
+ param_file_entity: models::FileEntity,
+ context: &C,
+ ) -> Result<CreateFileResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("POST")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let body =
+ serde_json::to_string(&param_file_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 Err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ )))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 201 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::EntityEdit>(body)?;
+ Ok(CreateFileResponse::CreatedEntity(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateFileResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateFileResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateFileResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateFileResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateFileResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn create_file_auto_batch(
+ &self,
+ param_file_auto_batch: models::FileAutoBatch,
+ context: &C,
+ ) -> Result<CreateFileAutoBatchResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ let mut uri = format!("{}/v0/editgroup/auto/file/batch", self.base_path);
+
+ // Query parameters
+ let query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("POST")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let body =
+ serde_json::to_string(&param_file_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 Err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ )))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 201 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::Editgroup>(body)?;
+ Ok(CreateFileAutoBatchResponse::CreatedEditgroup(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateFileAutoBatchResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateFileAutoBatchResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateFileAutoBatchResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateFileAutoBatchResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateFileAutoBatchResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn create_fileset(
+ &self,
+ param_editgroup_id: String,
+ param_fileset_entity: models::FilesetEntity,
+ context: &C,
+ ) -> Result<CreateFilesetResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("POST")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let body =
+ serde_json::to_string(&param_fileset_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 Err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ )))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 201 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::EntityEdit>(body)?;
+ Ok(CreateFilesetResponse::CreatedEntity(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateFilesetResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateFilesetResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateFilesetResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateFilesetResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateFilesetResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn create_fileset_auto_batch(
+ &self,
+ param_fileset_auto_batch: models::FilesetAutoBatch,
+ context: &C,
+ ) -> Result<CreateFilesetAutoBatchResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ let mut uri = format!("{}/v0/editgroup/auto/fileset/batch", self.base_path);
+
+ // Query parameters
+ let query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("POST")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let body = serde_json::to_string(&param_fileset_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 Err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ )))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 201 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::Editgroup>(body)?;
+ Ok(CreateFilesetAutoBatchResponse::CreatedEditgroup(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateFilesetAutoBatchResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateFilesetAutoBatchResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateFilesetAutoBatchResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateFilesetAutoBatchResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateFilesetAutoBatchResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn create_release(
+ &self,
+ param_editgroup_id: String,
+ param_release_entity: models::ReleaseEntity,
+ context: &C,
+ ) -> Result<CreateReleaseResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("POST")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let body =
+ serde_json::to_string(&param_release_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 Err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ )))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 201 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::EntityEdit>(body)?;
+ Ok(CreateReleaseResponse::CreatedEntity(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateReleaseResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateReleaseResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateReleaseResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateReleaseResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateReleaseResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn create_release_auto_batch(
+ &self,
+ param_release_auto_batch: models::ReleaseAutoBatch,
+ context: &C,
+ ) -> Result<CreateReleaseAutoBatchResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ let mut uri = format!("{}/v0/editgroup/auto/release/batch", self.base_path);
+
+ // Query parameters
+ let query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("POST")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let body = serde_json::to_string(&param_release_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 Err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ )))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 201 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::Editgroup>(body)?;
+ Ok(CreateReleaseAutoBatchResponse::CreatedEditgroup(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateReleaseAutoBatchResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateReleaseAutoBatchResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateReleaseAutoBatchResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateReleaseAutoBatchResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateReleaseAutoBatchResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn create_webcapture(
+ &self,
+ param_editgroup_id: String,
+ param_webcapture_entity: models::WebcaptureEntity,
+ context: &C,
+ ) -> Result<CreateWebcaptureResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("POST")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let body = serde_json::to_string(&param_webcapture_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 Err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ )))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 201 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::EntityEdit>(body)?;
+ Ok(CreateWebcaptureResponse::CreatedEntity(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateWebcaptureResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateWebcaptureResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateWebcaptureResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateWebcaptureResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateWebcaptureResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn create_webcapture_auto_batch(
+ &self,
+ param_webcapture_auto_batch: models::WebcaptureAutoBatch,
+ context: &C,
+ ) -> Result<CreateWebcaptureAutoBatchResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ let mut uri = format!("{}/v0/editgroup/auto/webcapture/batch", self.base_path);
+
+ // Query parameters
+ let query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("POST")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let body = serde_json::to_string(&param_webcapture_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 Err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ )))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 201 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::Editgroup>(body)?;
+ Ok(CreateWebcaptureAutoBatchResponse::CreatedEditgroup(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateWebcaptureAutoBatchResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateWebcaptureAutoBatchResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateWebcaptureAutoBatchResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateWebcaptureAutoBatchResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateWebcaptureAutoBatchResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn create_work(
+ &self,
+ param_editgroup_id: String,
+ param_work_entity: models::WorkEntity,
+ context: &C,
+ ) -> Result<CreateWorkResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("POST")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let body =
+ serde_json::to_string(&param_work_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 Err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ )))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 201 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::EntityEdit>(body)?;
+ Ok(CreateWorkResponse::CreatedEntity(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateWorkResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateWorkResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateWorkResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateWorkResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateWorkResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn create_work_auto_batch(
+ &self,
+ param_work_auto_batch: models::WorkAutoBatch,
+ context: &C,
+ ) -> Result<CreateWorkAutoBatchResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ let mut uri = format!("{}/v0/editgroup/auto/work/batch", self.base_path);
+
+ // Query parameters
+ let query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("POST")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let body =
+ serde_json::to_string(&param_work_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 Err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ )))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 201 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::Editgroup>(body)?;
+ Ok(CreateWorkAutoBatchResponse::CreatedEditgroup(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateWorkAutoBatchResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateWorkAutoBatchResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateWorkAutoBatchResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateWorkAutoBatchResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(CreateWorkAutoBatchResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn delete_container(
+ &self,
+ param_editgroup_id: String,
+ param_ident: String,
+ context: &C,
+ ) -> Result<DeleteContainerResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("DELETE")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::EntityEdit>(body)?;
+ Ok(DeleteContainerResponse::DeletedEntity(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteContainerResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteContainerResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteContainerResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteContainerResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteContainerResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn delete_container_edit(
+ &self,
+ param_editgroup_id: String,
+ param_edit_id: String,
+ context: &C,
+ ) -> Result<DeleteContainerEditResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("DELETE")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::Success>(body)?;
+ Ok(DeleteContainerEditResponse::DeletedEdit(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteContainerEditResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteContainerEditResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteContainerEditResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteContainerEditResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteContainerEditResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn delete_creator(
+ &self,
+ param_editgroup_id: String,
+ param_ident: String,
+ context: &C,
+ ) -> Result<DeleteCreatorResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("DELETE")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::EntityEdit>(body)?;
+ Ok(DeleteCreatorResponse::DeletedEntity(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteCreatorResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteCreatorResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteCreatorResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteCreatorResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteCreatorResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn delete_creator_edit(
+ &self,
+ param_editgroup_id: String,
+ param_edit_id: String,
+ context: &C,
+ ) -> Result<DeleteCreatorEditResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("DELETE")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::Success>(body)?;
+ Ok(DeleteCreatorEditResponse::DeletedEdit(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteCreatorEditResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteCreatorEditResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteCreatorEditResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteCreatorEditResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteCreatorEditResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn delete_file(
+ &self,
+ param_editgroup_id: String,
+ param_ident: String,
+ context: &C,
+ ) -> Result<DeleteFileResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("DELETE")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::EntityEdit>(body)?;
+ Ok(DeleteFileResponse::DeletedEntity(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteFileResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteFileResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteFileResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteFileResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteFileResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn delete_file_edit(
+ &self,
+ param_editgroup_id: String,
+ param_edit_id: String,
+ context: &C,
+ ) -> Result<DeleteFileEditResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("DELETE")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::Success>(body)?;
+ Ok(DeleteFileEditResponse::DeletedEdit(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteFileEditResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteFileEditResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteFileEditResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteFileEditResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteFileEditResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn delete_fileset(
+ &self,
+ param_editgroup_id: String,
+ param_ident: String,
+ context: &C,
+ ) -> Result<DeleteFilesetResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("DELETE")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::EntityEdit>(body)?;
+ Ok(DeleteFilesetResponse::DeletedEntity(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteFilesetResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteFilesetResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteFilesetResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteFilesetResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteFilesetResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn delete_fileset_edit(
+ &self,
+ param_editgroup_id: String,
+ param_edit_id: String,
+ context: &C,
+ ) -> Result<DeleteFilesetEditResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("DELETE")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::Success>(body)?;
+ Ok(DeleteFilesetEditResponse::DeletedEdit(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteFilesetEditResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteFilesetEditResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteFilesetEditResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteFilesetEditResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteFilesetEditResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn delete_release(
+ &self,
+ param_editgroup_id: String,
+ param_ident: String,
+ context: &C,
+ ) -> Result<DeleteReleaseResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("DELETE")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::EntityEdit>(body)?;
+ Ok(DeleteReleaseResponse::DeletedEntity(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteReleaseResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteReleaseResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteReleaseResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteReleaseResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteReleaseResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn delete_release_edit(
+ &self,
+ param_editgroup_id: String,
+ param_edit_id: String,
+ context: &C,
+ ) -> Result<DeleteReleaseEditResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("DELETE")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::Success>(body)?;
+ Ok(DeleteReleaseEditResponse::DeletedEdit(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteReleaseEditResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteReleaseEditResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteReleaseEditResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteReleaseEditResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteReleaseEditResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn delete_webcapture(
+ &self,
+ param_editgroup_id: String,
+ param_ident: String,
+ context: &C,
+ ) -> Result<DeleteWebcaptureResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("DELETE")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::EntityEdit>(body)?;
+ Ok(DeleteWebcaptureResponse::DeletedEntity(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteWebcaptureResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteWebcaptureResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteWebcaptureResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteWebcaptureResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteWebcaptureResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn delete_webcapture_edit(
+ &self,
+ param_editgroup_id: String,
+ param_edit_id: String,
+ context: &C,
+ ) -> Result<DeleteWebcaptureEditResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("DELETE")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::Success>(body)?;
+ Ok(DeleteWebcaptureEditResponse::DeletedEdit(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteWebcaptureEditResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteWebcaptureEditResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteWebcaptureEditResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteWebcaptureEditResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteWebcaptureEditResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn delete_work(
+ &self,
+ param_editgroup_id: String,
+ param_ident: String,
+ context: &C,
+ ) -> Result<DeleteWorkResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("DELETE")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::EntityEdit>(body)?;
+ Ok(DeleteWorkResponse::DeletedEntity(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteWorkResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteWorkResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteWorkResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteWorkResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteWorkResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn delete_work_edit(
+ &self,
+ param_editgroup_id: String,
+ param_edit_id: String,
+ context: &C,
+ ) -> Result<DeleteWorkEditResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("DELETE")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::Success>(body)?;
+ Ok(DeleteWorkEditResponse::DeletedEdit(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteWorkEditResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteWorkEditResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteWorkEditResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteWorkEditResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(DeleteWorkEditResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_changelog(
+ &self,
+ param_limit: Option<i64>,
+ context: &C,
+ ) -> Result<GetChangelogResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ let mut uri = format!("{}/v0/changelog", self.base_path);
+
+ // Query parameters
+ let query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_limit) = param_limit {
+ query_string.append_pair("limit", &param_limit.to_string());
+ }
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<Vec<models::ChangelogEntry>>(body)?;
+ Ok(GetChangelogResponse::Success(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetChangelogResponse::BadRequest(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetChangelogResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_changelog_entry(
+ &self,
+ param_index: i64,
+ context: &C,
+ ) -> Result<GetChangelogEntryResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ let mut uri = format!(
+ "{}/v0/changelog/{index}",
+ self.base_path,
+ index = utf8_percent_encode(&param_index.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ChangelogEntry>(body)?;
+ Ok(GetChangelogEntryResponse::FoundChangelogEntry(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetChangelogEntryResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetChangelogEntryResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetChangelogEntryResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_container(
+ &self,
+ param_ident: String,
+ param_expand: Option<String>,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Result<GetContainerResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ let mut uri = format!(
+ "{}/v0/container/{ident}",
+ self.base_path,
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let query_string = {
+ let mut query_string = 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());
+ }
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ContainerEntity>(body)?;
+ Ok(GetContainerResponse::FoundEntity(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetContainerResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetContainerResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetContainerResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_container_edit(
+ &self,
+ param_edit_id: String,
+ context: &C,
+ ) -> Result<GetContainerEditResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::EntityEdit>(body)?;
+ Ok(GetContainerEditResponse::FoundEdit(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetContainerEditResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetContainerEditResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetContainerEditResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_container_history(
+ &self,
+ param_ident: String,
+ param_limit: Option<i64>,
+ context: &C,
+ ) -> Result<GetContainerHistoryResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_limit) = param_limit {
+ query_string.append_pair("limit", &param_limit.to_string());
+ }
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<Vec<models::EntityHistoryEntry>>(body)?;
+ Ok(GetContainerHistoryResponse::FoundEntityHistory(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetContainerHistoryResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetContainerHistoryResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetContainerHistoryResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_container_redirects(
+ &self,
+ param_ident: String,
+ context: &C,
+ ) -> Result<GetContainerRedirectsResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<Vec<String>>(body)?;
+ Ok(GetContainerRedirectsResponse::FoundEntityRedirects(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetContainerRedirectsResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetContainerRedirectsResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetContainerRedirectsResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_container_revision(
+ &self,
+ param_rev_id: String,
+ param_expand: Option<String>,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Result<GetContainerRevisionResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = 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());
+ }
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ContainerEntity>(body)?;
+ Ok(GetContainerRevisionResponse::FoundEntityRevision(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetContainerRevisionResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetContainerRevisionResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetContainerRevisionResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_creator(
+ &self,
+ param_ident: String,
+ param_expand: Option<String>,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Result<GetCreatorResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ let mut uri = format!(
+ "{}/v0/creator/{ident}",
+ self.base_path,
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let query_string = {
+ let mut query_string = 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());
+ }
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::CreatorEntity>(body)?;
+ Ok(GetCreatorResponse::FoundEntity(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetCreatorResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetCreatorResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetCreatorResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_creator_edit(
+ &self,
+ param_edit_id: String,
+ context: &C,
+ ) -> Result<GetCreatorEditResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::EntityEdit>(body)?;
+ Ok(GetCreatorEditResponse::FoundEdit(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetCreatorEditResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetCreatorEditResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetCreatorEditResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_creator_history(
+ &self,
+ param_ident: String,
+ param_limit: Option<i64>,
+ context: &C,
+ ) -> Result<GetCreatorHistoryResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_limit) = param_limit {
+ query_string.append_pair("limit", &param_limit.to_string());
+ }
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<Vec<models::EntityHistoryEntry>>(body)?;
+ Ok(GetCreatorHistoryResponse::FoundEntityHistory(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetCreatorHistoryResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetCreatorHistoryResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetCreatorHistoryResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_creator_redirects(
+ &self,
+ param_ident: String,
+ context: &C,
+ ) -> Result<GetCreatorRedirectsResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<Vec<String>>(body)?;
+ Ok(GetCreatorRedirectsResponse::FoundEntityRedirects(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetCreatorRedirectsResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetCreatorRedirectsResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetCreatorRedirectsResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_creator_releases(
+ &self,
+ param_ident: String,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Result<GetCreatorReleasesResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_hide) = param_hide {
+ query_string.append_pair("hide", &param_hide.to_string());
+ }
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<Vec<models::ReleaseEntity>>(body)?;
+ Ok(GetCreatorReleasesResponse::Found(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetCreatorReleasesResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetCreatorReleasesResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetCreatorReleasesResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_creator_revision(
+ &self,
+ param_rev_id: String,
+ param_expand: Option<String>,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Result<GetCreatorRevisionResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = 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());
+ }
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::CreatorEntity>(body)?;
+ Ok(GetCreatorRevisionResponse::FoundEntityRevision(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetCreatorRevisionResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetCreatorRevisionResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetCreatorRevisionResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_editgroup(
+ &self,
+ param_editgroup_id: String,
+ context: &C,
+ ) -> Result<GetEditgroupResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::Editgroup>(body)?;
+ Ok(GetEditgroupResponse::Found(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetEditgroupResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetEditgroupResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetEditgroupResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_editgroup_annotations(
+ &self,
+ param_editgroup_id: String,
+ param_expand: Option<String>,
+ context: &C,
+ ) -> Result<GetEditgroupAnnotationsResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_expand) = param_expand {
+ query_string.append_pair("expand", &param_expand.to_string());
+ }
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<Vec<models::EditgroupAnnotation>>(body)?;
+ Ok(GetEditgroupAnnotationsResponse::Success(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetEditgroupAnnotationsResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetEditgroupAnnotationsResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetEditgroupAnnotationsResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetEditgroupAnnotationsResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetEditgroupAnnotationsResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async 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,
+ ) -> Result<GetEditgroupsReviewableResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ let mut uri = format!("{}/v0/editgroup/reviewable", self.base_path);
+
+ // Query parameters
+ let query_string = {
+ let mut query_string = 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());
+ }
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<Vec<models::Editgroup>>(body)?;
+ Ok(GetEditgroupsReviewableResponse::Found(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetEditgroupsReviewableResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetEditgroupsReviewableResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetEditgroupsReviewableResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_editor(
+ &self,
+ param_editor_id: String,
+ context: &C,
+ ) -> Result<GetEditorResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::Editor>(body)?;
+ Ok(GetEditorResponse::Found(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetEditorResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetEditorResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetEditorResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async 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,
+ ) -> Result<GetEditorAnnotationsResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = 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());
+ }
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<Vec<models::EditgroupAnnotation>>(body)?;
+ Ok(GetEditorAnnotationsResponse::Success(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetEditorAnnotationsResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetEditorAnnotationsResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetEditorAnnotationsResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetEditorAnnotationsResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetEditorAnnotationsResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async 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,
+ ) -> Result<GetEditorEditgroupsResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = 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());
+ }
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<Vec<models::Editgroup>>(body)?;
+ Ok(GetEditorEditgroupsResponse::Found(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetEditorEditgroupsResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetEditorEditgroupsResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetEditorEditgroupsResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_file(
+ &self,
+ param_ident: String,
+ param_expand: Option<String>,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Result<GetFileResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ let mut uri = format!(
+ "{}/v0/file/{ident}",
+ self.base_path,
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let query_string = {
+ let mut query_string = 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());
+ }
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::FileEntity>(body)?;
+ Ok(GetFileResponse::FoundEntity(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetFileResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetFileResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetFileResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_file_edit(
+ &self,
+ param_edit_id: String,
+ context: &C,
+ ) -> Result<GetFileEditResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::EntityEdit>(body)?;
+ Ok(GetFileEditResponse::FoundEdit(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetFileEditResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetFileEditResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetFileEditResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_file_history(
+ &self,
+ param_ident: String,
+ param_limit: Option<i64>,
+ context: &C,
+ ) -> Result<GetFileHistoryResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_limit) = param_limit {
+ query_string.append_pair("limit", &param_limit.to_string());
+ }
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<Vec<models::EntityHistoryEntry>>(body)?;
+ Ok(GetFileHistoryResponse::FoundEntityHistory(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetFileHistoryResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetFileHistoryResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetFileHistoryResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_file_redirects(
+ &self,
+ param_ident: String,
+ context: &C,
+ ) -> Result<GetFileRedirectsResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<Vec<String>>(body)?;
+ Ok(GetFileRedirectsResponse::FoundEntityRedirects(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetFileRedirectsResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetFileRedirectsResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetFileRedirectsResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_file_revision(
+ &self,
+ param_rev_id: String,
+ param_expand: Option<String>,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Result<GetFileRevisionResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = 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());
+ }
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::FileEntity>(body)?;
+ Ok(GetFileRevisionResponse::FoundEntityRevision(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetFileRevisionResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetFileRevisionResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetFileRevisionResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_fileset(
+ &self,
+ param_ident: String,
+ param_expand: Option<String>,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Result<GetFilesetResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ let mut uri = format!(
+ "{}/v0/fileset/{ident}",
+ self.base_path,
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let query_string = {
+ let mut query_string = 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());
+ }
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::FilesetEntity>(body)?;
+ Ok(GetFilesetResponse::FoundEntity(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetFilesetResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetFilesetResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetFilesetResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_fileset_edit(
+ &self,
+ param_edit_id: String,
+ context: &C,
+ ) -> Result<GetFilesetEditResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::EntityEdit>(body)?;
+ Ok(GetFilesetEditResponse::FoundEdit(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetFilesetEditResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetFilesetEditResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetFilesetEditResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_fileset_history(
+ &self,
+ param_ident: String,
+ param_limit: Option<i64>,
+ context: &C,
+ ) -> Result<GetFilesetHistoryResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_limit) = param_limit {
+ query_string.append_pair("limit", &param_limit.to_string());
+ }
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<Vec<models::EntityHistoryEntry>>(body)?;
+ Ok(GetFilesetHistoryResponse::FoundEntityHistory(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetFilesetHistoryResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetFilesetHistoryResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetFilesetHistoryResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_fileset_redirects(
+ &self,
+ param_ident: String,
+ context: &C,
+ ) -> Result<GetFilesetRedirectsResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<Vec<String>>(body)?;
+ Ok(GetFilesetRedirectsResponse::FoundEntityRedirects(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetFilesetRedirectsResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetFilesetRedirectsResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetFilesetRedirectsResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_fileset_revision(
+ &self,
+ param_rev_id: String,
+ param_expand: Option<String>,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Result<GetFilesetRevisionResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = 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());
+ }
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::FilesetEntity>(body)?;
+ Ok(GetFilesetRevisionResponse::FoundEntityRevision(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetFilesetRevisionResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetFilesetRevisionResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetFilesetRevisionResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_release(
+ &self,
+ param_ident: String,
+ param_expand: Option<String>,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Result<GetReleaseResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ let mut uri = format!(
+ "{}/v0/release/{ident}",
+ self.base_path,
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let query_string = {
+ let mut query_string = 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());
+ }
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ReleaseEntity>(body)?;
+ Ok(GetReleaseResponse::FoundEntity(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetReleaseResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetReleaseResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetReleaseResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_release_edit(
+ &self,
+ param_edit_id: String,
+ context: &C,
+ ) -> Result<GetReleaseEditResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::EntityEdit>(body)?;
+ Ok(GetReleaseEditResponse::FoundEdit(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetReleaseEditResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetReleaseEditResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetReleaseEditResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_release_files(
+ &self,
+ param_ident: String,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Result<GetReleaseFilesResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_hide) = param_hide {
+ query_string.append_pair("hide", &param_hide.to_string());
+ }
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<Vec<models::FileEntity>>(body)?;
+ Ok(GetReleaseFilesResponse::Found(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetReleaseFilesResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetReleaseFilesResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetReleaseFilesResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_release_filesets(
+ &self,
+ param_ident: String,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Result<GetReleaseFilesetsResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_hide) = param_hide {
+ query_string.append_pair("hide", &param_hide.to_string());
+ }
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<Vec<models::FilesetEntity>>(body)?;
+ Ok(GetReleaseFilesetsResponse::Found(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetReleaseFilesetsResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetReleaseFilesetsResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetReleaseFilesetsResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_release_history(
+ &self,
+ param_ident: String,
+ param_limit: Option<i64>,
+ context: &C,
+ ) -> Result<GetReleaseHistoryResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_limit) = param_limit {
+ query_string.append_pair("limit", &param_limit.to_string());
+ }
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<Vec<models::EntityHistoryEntry>>(body)?;
+ Ok(GetReleaseHistoryResponse::FoundEntityHistory(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetReleaseHistoryResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetReleaseHistoryResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetReleaseHistoryResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_release_redirects(
+ &self,
+ param_ident: String,
+ context: &C,
+ ) -> Result<GetReleaseRedirectsResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<Vec<String>>(body)?;
+ Ok(GetReleaseRedirectsResponse::FoundEntityRedirects(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetReleaseRedirectsResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetReleaseRedirectsResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetReleaseRedirectsResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_release_revision(
+ &self,
+ param_rev_id: String,
+ param_expand: Option<String>,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Result<GetReleaseRevisionResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = 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());
+ }
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ReleaseEntity>(body)?;
+ Ok(GetReleaseRevisionResponse::FoundEntityRevision(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetReleaseRevisionResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetReleaseRevisionResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetReleaseRevisionResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_release_webcaptures(
+ &self,
+ param_ident: String,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Result<GetReleaseWebcapturesResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_hide) = param_hide {
+ query_string.append_pair("hide", &param_hide.to_string());
+ }
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<Vec<models::WebcaptureEntity>>(body)?;
+ Ok(GetReleaseWebcapturesResponse::Found(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetReleaseWebcapturesResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetReleaseWebcapturesResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetReleaseWebcapturesResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_webcapture(
+ &self,
+ param_ident: String,
+ param_expand: Option<String>,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Result<GetWebcaptureResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ let mut uri = format!(
+ "{}/v0/webcapture/{ident}",
+ self.base_path,
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let query_string = {
+ let mut query_string = 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());
+ }
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::WebcaptureEntity>(body)?;
+ Ok(GetWebcaptureResponse::FoundEntity(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetWebcaptureResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetWebcaptureResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetWebcaptureResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_webcapture_edit(
+ &self,
+ param_edit_id: String,
+ context: &C,
+ ) -> Result<GetWebcaptureEditResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::EntityEdit>(body)?;
+ Ok(GetWebcaptureEditResponse::FoundEdit(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetWebcaptureEditResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetWebcaptureEditResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetWebcaptureEditResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_webcapture_history(
+ &self,
+ param_ident: String,
+ param_limit: Option<i64>,
+ context: &C,
+ ) -> Result<GetWebcaptureHistoryResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_limit) = param_limit {
+ query_string.append_pair("limit", &param_limit.to_string());
+ }
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<Vec<models::EntityHistoryEntry>>(body)?;
+ Ok(GetWebcaptureHistoryResponse::FoundEntityHistory(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetWebcaptureHistoryResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetWebcaptureHistoryResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetWebcaptureHistoryResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_webcapture_redirects(
+ &self,
+ param_ident: String,
+ context: &C,
+ ) -> Result<GetWebcaptureRedirectsResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<Vec<String>>(body)?;
+ Ok(GetWebcaptureRedirectsResponse::FoundEntityRedirects(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetWebcaptureRedirectsResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetWebcaptureRedirectsResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetWebcaptureRedirectsResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_webcapture_revision(
+ &self,
+ param_rev_id: String,
+ param_expand: Option<String>,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Result<GetWebcaptureRevisionResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = 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());
+ }
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::WebcaptureEntity>(body)?;
+ Ok(GetWebcaptureRevisionResponse::FoundEntityRevision(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetWebcaptureRevisionResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetWebcaptureRevisionResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetWebcaptureRevisionResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_work(
+ &self,
+ param_ident: String,
+ param_expand: Option<String>,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Result<GetWorkResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ let mut uri = format!(
+ "{}/v0/work/{ident}",
+ self.base_path,
+ ident = utf8_percent_encode(&param_ident.to_string(), ID_ENCODE_SET)
+ );
+
+ // Query parameters
+ let query_string = {
+ let mut query_string = 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());
+ }
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::WorkEntity>(body)?;
+ Ok(GetWorkResponse::FoundEntity(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetWorkResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetWorkResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetWorkResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_work_edit(
+ &self,
+ param_edit_id: String,
+ context: &C,
+ ) -> Result<GetWorkEditResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::EntityEdit>(body)?;
+ Ok(GetWorkEditResponse::FoundEdit(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetWorkEditResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetWorkEditResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetWorkEditResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_work_history(
+ &self,
+ param_ident: String,
+ param_limit: Option<i64>,
+ context: &C,
+ ) -> Result<GetWorkHistoryResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_limit) = param_limit {
+ query_string.append_pair("limit", &param_limit.to_string());
+ }
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<Vec<models::EntityHistoryEntry>>(body)?;
+ Ok(GetWorkHistoryResponse::FoundEntityHistory(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetWorkHistoryResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetWorkHistoryResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetWorkHistoryResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_work_redirects(
+ &self,
+ param_ident: String,
+ context: &C,
+ ) -> Result<GetWorkRedirectsResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<Vec<String>>(body)?;
+ Ok(GetWorkRedirectsResponse::FoundEntityRedirects(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetWorkRedirectsResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetWorkRedirectsResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetWorkRedirectsResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_work_releases(
+ &self,
+ param_ident: String,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Result<GetWorkReleasesResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_hide) = param_hide {
+ query_string.append_pair("hide", &param_hide.to_string());
+ }
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<Vec<models::ReleaseEntity>>(body)?;
+ Ok(GetWorkReleasesResponse::Found(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetWorkReleasesResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetWorkReleasesResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetWorkReleasesResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn get_work_revision(
+ &self,
+ param_rev_id: String,
+ param_expand: Option<String>,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Result<GetWorkRevisionResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = 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());
+ }
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::WorkEntity>(body)?;
+ Ok(GetWorkRevisionResponse::FoundEntityRevision(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetWorkRevisionResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetWorkRevisionResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(GetWorkRevisionResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn lookup_container(
+ &self,
+ param_issnl: Option<String>,
+ param_wikidata_qid: Option<String>,
+ param_expand: Option<String>,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Result<LookupContainerResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ let mut uri = format!("{}/v0/container/lookup", self.base_path);
+
+ // Query parameters
+ let query_string = {
+ let mut query_string = 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());
+ }
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ContainerEntity>(body)?;
+ Ok(LookupContainerResponse::FoundEntity(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(LookupContainerResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(LookupContainerResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(LookupContainerResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn lookup_creator(
+ &self,
+ param_orcid: Option<String>,
+ param_wikidata_qid: Option<String>,
+ param_expand: Option<String>,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Result<LookupCreatorResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ let mut uri = format!("{}/v0/creator/lookup", self.base_path);
+
+ // Query parameters
+ let query_string = {
+ let mut query_string = 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());
+ }
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::CreatorEntity>(body)?;
+ Ok(LookupCreatorResponse::FoundEntity(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(LookupCreatorResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(LookupCreatorResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(LookupCreatorResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async 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,
+ ) -> Result<LookupFileResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ let mut uri = format!("{}/v0/file/lookup", self.base_path);
+
+ // Query parameters
+ let query_string = {
+ let mut query_string = 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());
+ }
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::FileEntity>(body)?;
+ Ok(LookupFileResponse::FoundEntity(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(LookupFileResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(LookupFileResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(LookupFileResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async 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_doaj: Option<String>,
+ param_dblp: Option<String>,
+ param_oai: Option<String>,
+ param_expand: Option<String>,
+ param_hide: Option<String>,
+ context: &C,
+ ) -> Result<LookupReleaseResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ let mut uri = format!("{}/v0/release/lookup", self.base_path);
+
+ // Query parameters
+ let query_string = {
+ let mut query_string = 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_doaj) = param_doaj {
+ query_string.append_pair("doaj", &param_doaj.to_string());
+ }
+ if let Some(param_dblp) = param_dblp {
+ query_string.append_pair("dblp", &param_dblp.to_string());
+ }
+ if let Some(param_oai) = param_oai {
+ query_string.append_pair("oai", &param_oai.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());
+ }
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("GET")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ReleaseEntity>(body)?;
+ Ok(LookupReleaseResponse::FoundEntity(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(LookupReleaseResponse::BadRequest(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(LookupReleaseResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(LookupReleaseResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn update_container(
+ &self,
+ param_editgroup_id: String,
+ param_ident: String,
+ param_container_entity: models::ContainerEntity,
+ context: &C,
+ ) -> Result<UpdateContainerResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("PUT")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let body = serde_json::to_string(&param_container_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 Err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ )))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::EntityEdit>(body)?;
+ Ok(UpdateContainerResponse::UpdatedEntity(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateContainerResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateContainerResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateContainerResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateContainerResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateContainerResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn update_creator(
+ &self,
+ param_editgroup_id: String,
+ param_ident: String,
+ param_creator_entity: models::CreatorEntity,
+ context: &C,
+ ) -> Result<UpdateCreatorResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("PUT")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let body =
+ serde_json::to_string(&param_creator_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 Err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ )))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::EntityEdit>(body)?;
+ Ok(UpdateCreatorResponse::UpdatedEntity(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateCreatorResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateCreatorResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateCreatorResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateCreatorResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateCreatorResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn update_editgroup(
+ &self,
+ param_editgroup_id: String,
+ param_editgroup: models::Editgroup,
+ param_submit: Option<bool>,
+ context: &C,
+ ) -> Result<UpdateEditgroupResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ if let Some(param_submit) = param_submit {
+ query_string.append_pair("submit", &param_submit.to_string());
+ }
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("PUT")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return 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 Err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ )))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::Editgroup>(body)?;
+ Ok(UpdateEditgroupResponse::UpdatedEditgroup(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateEditgroupResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateEditgroupResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateEditgroupResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateEditgroupResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateEditgroupResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn update_editor(
+ &self,
+ param_editor_id: String,
+ param_editor: models::Editor,
+ context: &C,
+ ) -> Result<UpdateEditorResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("PUT")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return 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 Err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ )))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::Editor>(body)?;
+ Ok(UpdateEditorResponse::UpdatedEditor(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateEditorResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateEditorResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateEditorResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateEditorResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateEditorResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn update_file(
+ &self,
+ param_editgroup_id: String,
+ param_ident: String,
+ param_file_entity: models::FileEntity,
+ context: &C,
+ ) -> Result<UpdateFileResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("PUT")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let body =
+ serde_json::to_string(&param_file_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 Err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ )))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::EntityEdit>(body)?;
+ Ok(UpdateFileResponse::UpdatedEntity(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateFileResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateFileResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateFileResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateFileResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateFileResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn update_fileset(
+ &self,
+ param_editgroup_id: String,
+ param_ident: String,
+ param_fileset_entity: models::FilesetEntity,
+ context: &C,
+ ) -> Result<UpdateFilesetResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("PUT")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let body =
+ serde_json::to_string(&param_fileset_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 Err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ )))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::EntityEdit>(body)?;
+ Ok(UpdateFilesetResponse::UpdatedEntity(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateFilesetResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateFilesetResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateFilesetResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateFilesetResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateFilesetResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn update_release(
+ &self,
+ param_editgroup_id: String,
+ param_ident: String,
+ param_release_entity: models::ReleaseEntity,
+ context: &C,
+ ) -> Result<UpdateReleaseResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("PUT")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let body =
+ serde_json::to_string(&param_release_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 Err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ )))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::EntityEdit>(body)?;
+ Ok(UpdateReleaseResponse::UpdatedEntity(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateReleaseResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateReleaseResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateReleaseResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateReleaseResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateReleaseResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn update_webcapture(
+ &self,
+ param_editgroup_id: String,
+ param_ident: String,
+ param_webcapture_entity: models::WebcaptureEntity,
+ context: &C,
+ ) -> Result<UpdateWebcaptureResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("PUT")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let body = serde_json::to_string(&param_webcapture_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 Err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ )))
+ }
+ },
+ );
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::EntityEdit>(body)?;
+ Ok(UpdateWebcaptureResponse::UpdatedEntity(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateWebcaptureResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateWebcaptureResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateWebcaptureResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateWebcaptureResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateWebcaptureResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+
+ async fn update_work(
+ &self,
+ param_editgroup_id: String,
+ param_ident: String,
+ param_work_entity: models::WorkEntity,
+ context: &C,
+ ) -> Result<UpdateWorkResponse, ApiError> {
+ let mut client_service = self.client_service.clone();
+ 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 query_string = {
+ let mut query_string = form_urlencoded::Serializer::new("".to_owned());
+ query_string.finish()
+ };
+ if !query_string.is_empty() {
+ uri += "?";
+ uri += &query_string;
+ }
+
+ let uri = match Uri::from_str(&uri) {
+ Ok(uri) => uri,
+ Err(err) => return Err(ApiError(format!("Unable to build URI: {}", err))),
+ };
+
+ let mut request = match Request::builder()
+ .method("PUT")
+ .uri(uri)
+ .body(Body::empty())
+ {
+ Ok(req) => req,
+ Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))),
+ };
+
+ let body =
+ serde_json::to_string(&param_work_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 Err(ApiError(format!(
+ "Unable to create header: {} - {}",
+ header, e
+ )))
+ }
+ },
+ );
+
+ let header = HeaderValue::from_str(
+ Has::<XSpanIdString>::get(context)
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ );
+ request.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ match header {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create X-Span ID header value: {}",
+ e
+ )))
+ }
+ },
+ );
+
+ if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() {
+ // Currently only authentication with Basic and Bearer are supported
+ match auth_data {
+ &AuthData::Bearer(ref bearer_header) => {
+ let auth = swagger::auth::Header(bearer_header.clone());
+ let header = match HeaderValue::from_str(&format!("{}", auth)) {
+ Ok(h) => h,
+ Err(e) => {
+ return Err(ApiError(format!(
+ "Unable to create Authorization header: {}",
+ e
+ )))
+ }
+ };
+ request
+ .headers_mut()
+ .insert(hyper::header::AUTHORIZATION, header);
+ }
+ _ => {}
+ }
+ }
+
+ let mut response = client_service
+ .call((request, context.clone()))
+ .map_err(|e| ApiError(format!("No response received: {}", e)))
+ .await?;
+
+ match response.status().as_u16() {
+ 200 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::EntityEdit>(body)?;
+ Ok(UpdateWorkResponse::UpdatedEntity(body))
+ }
+ 400 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateWorkResponse::BadRequest(body))
+ }
+ 401 => {
+ let response_www_authenticate = match response
+ .headers()
+ .get(HeaderName::from_static("www_authenticate"))
+ {
+ Some(response_www_authenticate) => {
+ let response_www_authenticate = response_www_authenticate.clone();
+ let response_www_authenticate = match TryInto::<
+ header::IntoHeaderValue<String>,
+ >::try_into(
+ response_www_authenticate
+ ) {
+ Ok(value) => value,
+ Err(e) => {
+ return Err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)));
+ }
+ };
+ let response_www_authenticate = response_www_authenticate.0;
+ Some(response_www_authenticate)
+ }
+ None => None,
+ };
+
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateWorkResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate,
+ })
+ }
+ 403 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateWorkResponse::Forbidden(body))
+ }
+ 404 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateWorkResponse::NotFound(body))
+ }
+ 500 => {
+ let body = response.into_body();
+ let body = body
+ .to_raw()
+ .map_err(|e| ApiError(format!("Failed to read response: {}", e)))
+ .await?;
+ let body = str::from_utf8(&body)
+ .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(body)?;
+ Ok(UpdateWorkResponse::GenericError(body))
+ }
+ code => {
+ let headers = response.headers().clone();
+ let body = response.into_body().take(100).to_raw().await;
+ Err(ApiError(format!(
+ "Unexpected response code {}:\n{:?}\n\n{}",
+ code,
+ headers,
+ match body {
+ Ok(body) => match String::from_utf8(body) {
+ Ok(body) => body,
+ Err(e) => format!("<Body was not UTF8: {:?}>", e),
+ },
+ Err(e) => format!("<Failed to read body: {}>", e),
+ }
+ )))
+ }
+ }
+ }
+}