use futures; use futures::{future, stream, Future, Stream}; use hyper; use hyper::client::HttpConnector; use hyper::header::{HeaderName, HeaderValue, CONTENT_TYPE}; use hyper::{Body, Response, Uri}; #[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))] use hyper_openssl::HttpsConnector; use serde_json; use std::borrow::Cow; use std::convert::TryInto; use std::error; use std::fmt; use std::io::{Error, ErrorKind, Read}; use std::path::Path; use std::str; use std::str::FromStr; use std::string::ToString; use std::sync::Arc; use swagger; use swagger::{client::Service, ApiError, AuthData, Connector, Has, XSpanIdString}; use url::form_urlencoded; use url::percent_encoding::{utf8_percent_encode, PATH_SEGMENT_ENCODE_SET, QUERY_ENCODE_SET}; use crate::header; use crate::models; url::define_encode_set! { /// This encode set is used for object IDs /// /// Aside from the special characters defined in the `PATH_SEGMENT_ENCODE_SET`, /// the vertical bar (|) is encoded. pub ID_ENCODE_SET = [PATH_SEGMENT_ENCODE_SET] | {'|'} } use crate::{ AcceptEditgroupResponse, Api, AuthCheckResponse, AuthOidcResponse, CreateAuthTokenResponse, CreateContainerAutoBatchResponse, CreateContainerResponse, CreateCreatorAutoBatchResponse, CreateCreatorResponse, CreateEditgroupAnnotationResponse, CreateEditgroupResponse, CreateFileAutoBatchResponse, CreateFileResponse, CreateFilesetAutoBatchResponse, CreateFilesetResponse, CreateReleaseAutoBatchResponse, CreateReleaseResponse, CreateWebcaptureAutoBatchResponse, CreateWebcaptureResponse, CreateWorkAutoBatchResponse, CreateWorkResponse, DeleteContainerEditResponse, DeleteContainerResponse, DeleteCreatorEditResponse, DeleteCreatorResponse, DeleteFileEditResponse, DeleteFileResponse, DeleteFilesetEditResponse, DeleteFilesetResponse, DeleteReleaseEditResponse, DeleteReleaseResponse, DeleteWebcaptureEditResponse, DeleteWebcaptureResponse, DeleteWorkEditResponse, DeleteWorkResponse, GetChangelogEntryResponse, GetChangelogResponse, GetContainerEditResponse, GetContainerHistoryResponse, GetContainerRedirectsResponse, GetContainerResponse, GetContainerRevisionResponse, GetCreatorEditResponse, GetCreatorHistoryResponse, GetCreatorRedirectsResponse, GetCreatorReleasesResponse, GetCreatorResponse, GetCreatorRevisionResponse, GetEditgroupAnnotationsResponse, GetEditgroupResponse, GetEditgroupsReviewableResponse, GetEditorAnnotationsResponse, GetEditorEditgroupsResponse, GetEditorResponse, GetFileEditResponse, GetFileHistoryResponse, GetFileRedirectsResponse, GetFileResponse, GetFileRevisionResponse, GetFilesetEditResponse, GetFilesetHistoryResponse, GetFilesetRedirectsResponse, GetFilesetResponse, GetFilesetRevisionResponse, GetReleaseEditResponse, GetReleaseFilesResponse, GetReleaseFilesetsResponse, GetReleaseHistoryResponse, GetReleaseRedirectsResponse, GetReleaseResponse, GetReleaseRevisionResponse, GetReleaseWebcapturesResponse, GetWebcaptureEditResponse, GetWebcaptureHistoryResponse, GetWebcaptureRedirectsResponse, GetWebcaptureResponse, GetWebcaptureRevisionResponse, GetWorkEditResponse, GetWorkHistoryResponse, GetWorkRedirectsResponse, GetWorkReleasesResponse, GetWorkResponse, GetWorkRevisionResponse, LookupContainerResponse, LookupCreatorResponse, LookupFileResponse, LookupReleaseResponse, UpdateContainerResponse, UpdateCreatorResponse, UpdateEditgroupResponse, UpdateEditorResponse, UpdateFileResponse, UpdateFilesetResponse, UpdateReleaseResponse, UpdateWebcaptureResponse, UpdateWorkResponse, }; /// Convert input into a base path, e.g. "http://example:123". Also checks the scheme as it goes. fn into_base_path( input: &str, correct_scheme: Option<&'static str>, ) -> Result { // First convert to Uri, since a base path is a subset of Uri. let uri = Uri::from_str(input)?; let scheme = uri.scheme_part().ok_or(ClientInitError::InvalidScheme)?; // Check the scheme if necessary if let Some(correct_scheme) = correct_scheme { if scheme != correct_scheme { return Err(ClientInitError::InvalidScheme); } } let host = uri.host().ok_or_else(|| ClientInitError::MissingHost)?; let port = uri .port_part() .map(|x| format!(":{}", x)) .unwrap_or_default(); Ok(format!( "{}://{}{}{}", scheme, host, port, uri.path().trim_end_matches('/') )) } /// A client that implements the API by making HTTP calls out to a server. pub struct Client { /// Inner service client_service: Arc + Send + Sync>>, /// Base path of the API base_path: String, } impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "Client {{ base_path: {} }}", self.base_path) } } impl Clone for Client { fn clone(&self) -> Self { Client { client_service: self.client_service.clone(), base_path: self.base_path.clone(), } } } impl Client { /// Create a client with a custom implementation of hyper::client::Connect. /// /// Intended for use with custom implementations of connect for e.g. protocol logging /// or similar functionality which requires wrapping the transport layer. When wrapping a TCP connection, /// this function should be used in conjunction with `swagger::Connector::builder()`. /// /// For ordinary tcp connections, prefer the use of `try_new_http`, `try_new_https` /// and `try_new_https_mutual`, to avoid introducing a dependency on the underlying transport layer. /// /// # Arguments /// /// * `base_path` - base path of the client API, i.e. "www.my-api-implementation.com" /// * `protocol` - Which protocol to use when constructing the request url, e.g. `Some("http")` /// * `connector` - Implementation of `hyper::client::Connect` to use for the client pub fn try_new_with_connector( base_path: &str, protocol: Option<&'static str>, connector: C, ) -> Result where C: hyper::client::connect::Connect + 'static, C::Transport: 'static, C::Future: 'static, { let client_service = Box::new(hyper::client::Client::builder().build(connector)); Ok(Client { client_service: Arc::new(client_service), base_path: into_base_path(base_path, protocol)?, }) } /// Create an HTTP client. /// /// # Arguments /// * `base_path` - base path of the client API, i.e. "www.my-api-implementation.com" pub fn try_new_http(base_path: &str) -> Result { let http_connector = Connector::builder().build(); Self::try_new_with_connector(base_path, Some("http"), http_connector) } /// Create a client with a TLS connection to the server /// /// # Arguments /// * `base_path` - base path of the client API, i.e. "www.my-api-implementation.com" pub fn try_new_https(base_path: &str) -> Result { let https_connector = Connector::builder() .https() .build() .map_err(|e| ClientInitError::SslError(e))?; Self::try_new_with_connector(base_path, Some("https"), https_connector) } /// Create a client with a TLS connection to the server using a pinned certificate /// /// # Arguments /// * `base_path` - base path of the client API, i.e. "www.my-api-implementation.com" /// * `ca_certificate` - Path to CA certificate used to authenticate the server #[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))] pub fn try_new_https_pinned( base_path: &str, ca_certificate: CA, ) -> Result where CA: AsRef, { let https_connector = Connector::builder() .https() .pin_server_certificate(ca_certificate) .build() .map_err(|e| ClientInitError::SslError(e))?; Self::try_new_with_connector(base_path, Some("https"), https_connector) } /// Create a client with a mutually authenticated TLS connection to the server. /// /// # Arguments /// * `base_path` - base path of the client API, i.e. "www.my-api-implementation.com" /// * `ca_certificate` - Path to CA certificate used to authenticate the server /// * `client_key` - Path to the client private key /// * `client_certificate` - Path to the client's public certificate associated with the private key #[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))] pub fn try_new_https_mutual( base_path: &str, ca_certificate: CA, client_key: K, client_certificate: D, ) -> Result where CA: AsRef, K: AsRef, D: AsRef, { 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 Client { /// Constructor for creating a `Client` by passing in a pre-made `swagger::Service` /// /// This allows adding custom wrappers around the underlying transport, for example for logging. pub fn try_new_with_client_service( client_service: Arc + Send + Sync>>, base_path: &str, ) -> Result { Ok(Client { client_service: client_service, base_path: into_base_path(base_path, None)?, }) } } /// Error type failing to create a Client #[derive(Debug)] pub enum ClientInitError { /// Invalid URL Scheme InvalidScheme, /// Invalid URI InvalidUri(hyper::http::uri::InvalidUri), /// Missing Hostname MissingHost, /// SSL Connection Error #[cfg(any(target_os = "macos", target_os = "windows", target_os = "ios"))] SslError(native_tls::Error), /// SSL Connection Error #[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))] SslError(openssl::error::ErrorStack), } impl From for ClientInitError { fn from(err: hyper::http::uri::InvalidUri) -> ClientInitError { ClientInitError::InvalidUri(err) } } impl fmt::Display for ClientInitError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let s: &dyn fmt::Debug = self; s.fmt(f) } } impl error::Error for ClientInitError { fn description(&self) -> &str { "Failed to produce a hyper client." } } impl Api for Client where C: Has + Has>, F: Future, Error = hyper::Error> + Send + 'static, { fn accept_editgroup( &self, param_editgroup_id: String, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/editgroup/{editgroup_id}/accept", self.base_path, editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("POST") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { AcceptEditgroupResponse::MergedSuccessfully (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { AcceptEditgroupResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { AcceptEditgroupResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { AcceptEditgroupResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { AcceptEditgroupResponse::NotFound (body) }) ) as Box + Send> }, 409 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { AcceptEditgroupResponse::EditConflict (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { AcceptEditgroupResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn auth_check( &self, param_role: Option, context: &C, ) -> Box + Send> { let mut uri = format!("{}/v0/auth/check", self.base_path); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); if let Some(param_role) = param_role { query_string.append_pair("role", ¶m_role.to_string()); } let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { AuthCheckResponse::Success (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { AuthCheckResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { AuthCheckResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { AuthCheckResponse::Forbidden (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { AuthCheckResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn auth_oidc( &self, param_auth_oidc: models::AuthOidc, context: &C, ) -> Box + Send> { let mut uri = format!("{}/v0/auth/oidc", self.base_path); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("POST") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let body = serde_json::to_string(¶m_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 Box::new(future::err(ApiError(format!( "Unable to create header: {} - {}", header, e )))) } }, ); let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { AuthOidcResponse::Found (body) }) ) as Box + Send> }, 201 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { AuthOidcResponse::Created (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { AuthOidcResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { AuthOidcResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { AuthOidcResponse::Forbidden (body) }) ) as Box + Send> }, 409 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { AuthOidcResponse::Conflict (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { AuthOidcResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn create_auth_token( &self, param_editor_id: String, param_duration_seconds: Option, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/auth/token/{editor_id}", self.base_path, editor_id = utf8_percent_encode(¶m_editor_id.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); if let Some(param_duration_seconds) = param_duration_seconds { query_string.append_pair("duration_seconds", ¶m_duration_seconds.to_string()); } let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("POST") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateAuthTokenResponse::Success (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateAuthTokenResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateAuthTokenResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateAuthTokenResponse::Forbidden (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateAuthTokenResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn create_container( &self, param_editgroup_id: String, param_container_entity: models::ContainerEntity, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/editgroup/{editgroup_id}/container", self.base_path, editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("POST") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let body = serde_json::to_string(¶m_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 Box::new(future::err(ApiError(format!( "Unable to create header: {} - {}", header, e )))) } }, ); let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 201 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateContainerResponse::CreatedEntity (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateContainerResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateContainerResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateContainerResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateContainerResponse::NotFound (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateContainerResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn create_container_auto_batch( &self, param_container_auto_batch: models::ContainerAutoBatch, context: &C, ) -> Box + Send> { let mut uri = format!("{}/v0/editgroup/auto/container/batch", self.base_path); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("POST") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let body = serde_json::to_string(¶m_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 Box::new(future::err(ApiError(format!( "Unable to create header: {} - {}", header, e )))) } }, ); let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 201 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateContainerAutoBatchResponse::CreatedEditgroup (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateContainerAutoBatchResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateContainerAutoBatchResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateContainerAutoBatchResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateContainerAutoBatchResponse::NotFound (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateContainerAutoBatchResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn create_creator( &self, param_editgroup_id: String, param_creator_entity: models::CreatorEntity, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/editgroup/{editgroup_id}/creator", self.base_path, editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("POST") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let body = serde_json::to_string(¶m_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 Box::new(future::err(ApiError(format!( "Unable to create header: {} - {}", header, e )))) } }, ); let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 201 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateCreatorResponse::CreatedEntity (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateCreatorResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateCreatorResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateCreatorResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateCreatorResponse::NotFound (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateCreatorResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn create_creator_auto_batch( &self, param_creator_auto_batch: models::CreatorAutoBatch, context: &C, ) -> Box + Send> { let mut uri = format!("{}/v0/editgroup/auto/creator/batch", self.base_path); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("POST") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let body = serde_json::to_string(¶m_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 Box::new(future::err(ApiError(format!( "Unable to create header: {} - {}", header, e )))) } }, ); let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 201 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateCreatorAutoBatchResponse::CreatedEditgroup (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateCreatorAutoBatchResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateCreatorAutoBatchResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateCreatorAutoBatchResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateCreatorAutoBatchResponse::NotFound (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateCreatorAutoBatchResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn create_editgroup( &self, param_editgroup: models::Editgroup, context: &C, ) -> Box + Send> { let mut uri = format!("{}/v0/editgroup", self.base_path); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("POST") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let body = serde_json::to_string(¶m_editgroup).expect("impossible to fail to serialize"); *request.body_mut() = Body::from(body); let header = "application/json"; request.headers_mut().insert( CONTENT_TYPE, match HeaderValue::from_str(header) { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create header: {} - {}", header, e )))) } }, ); let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 201 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateEditgroupResponse::SuccessfullyCreated (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateEditgroupResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateEditgroupResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateEditgroupResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateEditgroupResponse::NotFound (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateEditgroupResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn create_editgroup_annotation( &self, param_editgroup_id: String, param_editgroup_annotation: models::EditgroupAnnotation, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/editgroup/{editgroup_id}/annotation", self.base_path, editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("POST") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let body = serde_json::to_string(¶m_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 Box::new(future::err(ApiError(format!( "Unable to create header: {} - {}", header, e )))) } }, ); let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 201 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateEditgroupAnnotationResponse::Created (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateEditgroupAnnotationResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateEditgroupAnnotationResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateEditgroupAnnotationResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateEditgroupAnnotationResponse::NotFound (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateEditgroupAnnotationResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn create_file( &self, param_editgroup_id: String, param_file_entity: models::FileEntity, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/editgroup/{editgroup_id}/file", self.base_path, editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("POST") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let body = serde_json::to_string(¶m_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 Box::new(future::err(ApiError(format!( "Unable to create header: {} - {}", header, e )))) } }, ); let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 201 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateFileResponse::CreatedEntity (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateFileResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateFileResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateFileResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateFileResponse::NotFound (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateFileResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn create_file_auto_batch( &self, param_file_auto_batch: models::FileAutoBatch, context: &C, ) -> Box + Send> { let mut uri = format!("{}/v0/editgroup/auto/file/batch", self.base_path); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("POST") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let body = serde_json::to_string(¶m_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 Box::new(future::err(ApiError(format!( "Unable to create header: {} - {}", header, e )))) } }, ); let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 201 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateFileAutoBatchResponse::CreatedEditgroup (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateFileAutoBatchResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateFileAutoBatchResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateFileAutoBatchResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateFileAutoBatchResponse::NotFound (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateFileAutoBatchResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn create_fileset( &self, param_editgroup_id: String, param_fileset_entity: models::FilesetEntity, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/editgroup/{editgroup_id}/fileset", self.base_path, editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("POST") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let body = serde_json::to_string(¶m_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 Box::new(future::err(ApiError(format!( "Unable to create header: {} - {}", header, e )))) } }, ); let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 201 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateFilesetResponse::CreatedEntity (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateFilesetResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateFilesetResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateFilesetResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateFilesetResponse::NotFound (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateFilesetResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn create_fileset_auto_batch( &self, param_fileset_auto_batch: models::FilesetAutoBatch, context: &C, ) -> Box + Send> { let mut uri = format!("{}/v0/editgroup/auto/fileset/batch", self.base_path); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("POST") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let body = serde_json::to_string(¶m_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 Box::new(future::err(ApiError(format!( "Unable to create header: {} - {}", header, e )))) } }, ); let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 201 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateFilesetAutoBatchResponse::CreatedEditgroup (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateFilesetAutoBatchResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateFilesetAutoBatchResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateFilesetAutoBatchResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateFilesetAutoBatchResponse::NotFound (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateFilesetAutoBatchResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn create_release( &self, param_editgroup_id: String, param_release_entity: models::ReleaseEntity, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/editgroup/{editgroup_id}/release", self.base_path, editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("POST") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let body = serde_json::to_string(¶m_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 Box::new(future::err(ApiError(format!( "Unable to create header: {} - {}", header, e )))) } }, ); let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 201 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateReleaseResponse::CreatedEntity (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateReleaseResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateReleaseResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateReleaseResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateReleaseResponse::NotFound (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateReleaseResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn create_release_auto_batch( &self, param_release_auto_batch: models::ReleaseAutoBatch, context: &C, ) -> Box + Send> { let mut uri = format!("{}/v0/editgroup/auto/release/batch", self.base_path); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("POST") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let body = serde_json::to_string(¶m_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 Box::new(future::err(ApiError(format!( "Unable to create header: {} - {}", header, e )))) } }, ); let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 201 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateReleaseAutoBatchResponse::CreatedEditgroup (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateReleaseAutoBatchResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateReleaseAutoBatchResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateReleaseAutoBatchResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateReleaseAutoBatchResponse::NotFound (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateReleaseAutoBatchResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn create_webcapture( &self, param_editgroup_id: String, param_webcapture_entity: models::WebcaptureEntity, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/editgroup/{editgroup_id}/webcapture", self.base_path, editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("POST") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let body = serde_json::to_string(¶m_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 Box::new(future::err(ApiError(format!( "Unable to create header: {} - {}", header, e )))) } }, ); let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 201 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateWebcaptureResponse::CreatedEntity (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateWebcaptureResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateWebcaptureResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateWebcaptureResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateWebcaptureResponse::NotFound (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateWebcaptureResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn create_webcapture_auto_batch( &self, param_webcapture_auto_batch: models::WebcaptureAutoBatch, context: &C, ) -> Box + Send> { let mut uri = format!("{}/v0/editgroup/auto/webcapture/batch", self.base_path); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("POST") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let body = serde_json::to_string(¶m_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 Box::new(future::err(ApiError(format!( "Unable to create header: {} - {}", header, e )))) } }, ); let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 201 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateWebcaptureAutoBatchResponse::CreatedEditgroup (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateWebcaptureAutoBatchResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateWebcaptureAutoBatchResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateWebcaptureAutoBatchResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateWebcaptureAutoBatchResponse::NotFound (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateWebcaptureAutoBatchResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn create_work( &self, param_editgroup_id: String, param_work_entity: models::WorkEntity, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/editgroup/{editgroup_id}/work", self.base_path, editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("POST") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let body = serde_json::to_string(¶m_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 Box::new(future::err(ApiError(format!( "Unable to create header: {} - {}", header, e )))) } }, ); let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 201 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateWorkResponse::CreatedEntity (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateWorkResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateWorkResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateWorkResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateWorkResponse::NotFound (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateWorkResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn create_work_auto_batch( &self, param_work_auto_batch: models::WorkAutoBatch, context: &C, ) -> Box + Send> { let mut uri = format!("{}/v0/editgroup/auto/work/batch", self.base_path); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("POST") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let body = serde_json::to_string(¶m_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 Box::new(future::err(ApiError(format!( "Unable to create header: {} - {}", header, e )))) } }, ); let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 201 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateWorkAutoBatchResponse::CreatedEditgroup (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateWorkAutoBatchResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateWorkAutoBatchResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateWorkAutoBatchResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateWorkAutoBatchResponse::NotFound (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { CreateWorkAutoBatchResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn delete_container( &self, param_editgroup_id: String, param_ident: String, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/editgroup/{editgroup_id}/container/{ident}", self.base_path, editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), ID_ENCODE_SET), ident = utf8_percent_encode(¶m_ident.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("DELETE") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteContainerResponse::DeletedEntity (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteContainerResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteContainerResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteContainerResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteContainerResponse::NotFound (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteContainerResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn delete_container_edit( &self, param_editgroup_id: String, param_edit_id: String, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/editgroup/{editgroup_id}/container/edit/{edit_id}", self.base_path, editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), ID_ENCODE_SET), edit_id = utf8_percent_encode(¶m_edit_id.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("DELETE") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteContainerEditResponse::DeletedEdit (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteContainerEditResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteContainerEditResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteContainerEditResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteContainerEditResponse::NotFound (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteContainerEditResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn delete_creator( &self, param_editgroup_id: String, param_ident: String, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/editgroup/{editgroup_id}/creator/{ident}", self.base_path, editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), ID_ENCODE_SET), ident = utf8_percent_encode(¶m_ident.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("DELETE") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteCreatorResponse::DeletedEntity (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteCreatorResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteCreatorResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteCreatorResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteCreatorResponse::NotFound (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteCreatorResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn delete_creator_edit( &self, param_editgroup_id: String, param_edit_id: String, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/editgroup/{editgroup_id}/creator/edit/{edit_id}", self.base_path, editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), ID_ENCODE_SET), edit_id = utf8_percent_encode(¶m_edit_id.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("DELETE") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteCreatorEditResponse::DeletedEdit (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteCreatorEditResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteCreatorEditResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteCreatorEditResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteCreatorEditResponse::NotFound (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteCreatorEditResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn delete_file( &self, param_editgroup_id: String, param_ident: String, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/editgroup/{editgroup_id}/file/{ident}", self.base_path, editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), ID_ENCODE_SET), ident = utf8_percent_encode(¶m_ident.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("DELETE") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteFileResponse::DeletedEntity (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteFileResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteFileResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteFileResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteFileResponse::NotFound (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteFileResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn delete_file_edit( &self, param_editgroup_id: String, param_edit_id: String, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/editgroup/{editgroup_id}/file/edit/{edit_id}", self.base_path, editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), ID_ENCODE_SET), edit_id = utf8_percent_encode(¶m_edit_id.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("DELETE") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteFileEditResponse::DeletedEdit (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteFileEditResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteFileEditResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteFileEditResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteFileEditResponse::NotFound (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteFileEditResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn delete_fileset( &self, param_editgroup_id: String, param_ident: String, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/editgroup/{editgroup_id}/fileset/{ident}", self.base_path, editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), ID_ENCODE_SET), ident = utf8_percent_encode(¶m_ident.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("DELETE") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteFilesetResponse::DeletedEntity (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteFilesetResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteFilesetResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteFilesetResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteFilesetResponse::NotFound (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteFilesetResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn delete_fileset_edit( &self, param_editgroup_id: String, param_edit_id: String, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/editgroup/{editgroup_id}/fileset/edit/{edit_id}", self.base_path, editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), ID_ENCODE_SET), edit_id = utf8_percent_encode(¶m_edit_id.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("DELETE") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteFilesetEditResponse::DeletedEdit (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteFilesetEditResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteFilesetEditResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteFilesetEditResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteFilesetEditResponse::NotFound (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteFilesetEditResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn delete_release( &self, param_editgroup_id: String, param_ident: String, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/editgroup/{editgroup_id}/release/{ident}", self.base_path, editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), ID_ENCODE_SET), ident = utf8_percent_encode(¶m_ident.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("DELETE") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteReleaseResponse::DeletedEntity (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteReleaseResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteReleaseResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteReleaseResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteReleaseResponse::NotFound (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteReleaseResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn delete_release_edit( &self, param_editgroup_id: String, param_edit_id: String, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/editgroup/{editgroup_id}/release/edit/{edit_id}", self.base_path, editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), ID_ENCODE_SET), edit_id = utf8_percent_encode(¶m_edit_id.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("DELETE") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteReleaseEditResponse::DeletedEdit (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteReleaseEditResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteReleaseEditResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteReleaseEditResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteReleaseEditResponse::NotFound (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteReleaseEditResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn delete_webcapture( &self, param_editgroup_id: String, param_ident: String, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/editgroup/{editgroup_id}/webcapture/{ident}", self.base_path, editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), ID_ENCODE_SET), ident = utf8_percent_encode(¶m_ident.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("DELETE") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteWebcaptureResponse::DeletedEntity (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteWebcaptureResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteWebcaptureResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteWebcaptureResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteWebcaptureResponse::NotFound (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteWebcaptureResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn delete_webcapture_edit( &self, param_editgroup_id: String, param_edit_id: String, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/editgroup/{editgroup_id}/webcapture/edit/{edit_id}", self.base_path, editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), ID_ENCODE_SET), edit_id = utf8_percent_encode(¶m_edit_id.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("DELETE") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteWebcaptureEditResponse::DeletedEdit (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteWebcaptureEditResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteWebcaptureEditResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteWebcaptureEditResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteWebcaptureEditResponse::NotFound (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteWebcaptureEditResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn delete_work( &self, param_editgroup_id: String, param_ident: String, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/editgroup/{editgroup_id}/work/{ident}", self.base_path, editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), ID_ENCODE_SET), ident = utf8_percent_encode(¶m_ident.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("DELETE") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteWorkResponse::DeletedEntity (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteWorkResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteWorkResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteWorkResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteWorkResponse::NotFound (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteWorkResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn delete_work_edit( &self, param_editgroup_id: String, param_edit_id: String, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/editgroup/{editgroup_id}/work/edit/{edit_id}", self.base_path, editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), ID_ENCODE_SET), edit_id = utf8_percent_encode(¶m_edit_id.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("DELETE") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteWorkEditResponse::DeletedEdit (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteWorkEditResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteWorkEditResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteWorkEditResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteWorkEditResponse::NotFound (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { DeleteWorkEditResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn get_changelog( &self, param_limit: Option, context: &C, ) -> Box + Send> { let mut uri = format!("{}/v0/changelog", self.base_path); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); if let Some(param_limit) = param_limit { query_string.append_pair("limit", ¶m_limit.to_string()); } let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::>( body, ) .map_err(|e| e.into()) }) }) .map(move |body| GetChangelogResponse::Success(body)), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetChangelogResponse::BadRequest(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetChangelogResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_changelog_entry( &self, param_index: i64, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/changelog/{index}", self.base_path, index = utf8_percent_encode(¶m_index.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| { GetChangelogEntryResponse::FoundChangelogEntry(body) }), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetChangelogEntryResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetChangelogEntryResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetChangelogEntryResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_container( &self, param_ident: String, param_expand: Option, param_hide: Option, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/container/{ident}", self.base_path, ident = utf8_percent_encode(¶m_ident.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); if let Some(param_expand) = param_expand { query_string.append_pair("expand", ¶m_expand.to_string()); } if let Some(param_hide) = param_hide { query_string.append_pair("hide", ¶m_hide.to_string()); } let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetContainerResponse::FoundEntity(body)), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetContainerResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetContainerResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetContainerResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_container_edit( &self, param_edit_id: String, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/container/edit/{edit_id}", self.base_path, edit_id = utf8_percent_encode(¶m_edit_id.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetContainerEditResponse::FoundEdit(body)), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetContainerEditResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetContainerEditResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetContainerEditResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_container_history( &self, param_ident: String, param_limit: Option, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/container/{ident}/history", self.base_path, ident = utf8_percent_encode(¶m_ident.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); if let Some(param_limit) = param_limit { query_string.append_pair("limit", ¶m_limit.to_string()); } let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::>( body, ) .map_err(|e| e.into()) }) }) .map(move |body| { GetContainerHistoryResponse::FoundEntityHistory(body) }), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetContainerHistoryResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetContainerHistoryResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetContainerHistoryResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_container_redirects( &self, param_ident: String, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/container/{ident}/redirects", self.base_path, ident = utf8_percent_encode(¶m_ident.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::>(body) .map_err(|e| e.into()) }) }) .map(move |body| { GetContainerRedirectsResponse::FoundEntityRedirects(body) }), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetContainerRedirectsResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetContainerRedirectsResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetContainerRedirectsResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_container_revision( &self, param_rev_id: String, param_expand: Option, param_hide: Option, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/container/rev/{rev_id}", self.base_path, rev_id = utf8_percent_encode(¶m_rev_id.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); if let Some(param_expand) = param_expand { query_string.append_pair("expand", ¶m_expand.to_string()); } if let Some(param_hide) = param_hide { query_string.append_pair("hide", ¶m_hide.to_string()); } let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| { GetContainerRevisionResponse::FoundEntityRevision(body) }), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetContainerRevisionResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetContainerRevisionResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetContainerRevisionResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_creator( &self, param_ident: String, param_expand: Option, param_hide: Option, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/creator/{ident}", self.base_path, ident = utf8_percent_encode(¶m_ident.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); if let Some(param_expand) = param_expand { query_string.append_pair("expand", ¶m_expand.to_string()); } if let Some(param_hide) = param_hide { query_string.append_pair("hide", ¶m_hide.to_string()); } let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetCreatorResponse::FoundEntity(body)), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetCreatorResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetCreatorResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetCreatorResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_creator_edit( &self, param_edit_id: String, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/creator/edit/{edit_id}", self.base_path, edit_id = utf8_percent_encode(¶m_edit_id.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetCreatorEditResponse::FoundEdit(body)), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetCreatorEditResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetCreatorEditResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetCreatorEditResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_creator_history( &self, param_ident: String, param_limit: Option, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/creator/{ident}/history", self.base_path, ident = utf8_percent_encode(¶m_ident.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); if let Some(param_limit) = param_limit { query_string.append_pair("limit", ¶m_limit.to_string()); } let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::>( body, ) .map_err(|e| e.into()) }) }) .map(move |body| { GetCreatorHistoryResponse::FoundEntityHistory(body) }), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetCreatorHistoryResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetCreatorHistoryResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetCreatorHistoryResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_creator_redirects( &self, param_ident: String, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/creator/{ident}/redirects", self.base_path, ident = utf8_percent_encode(¶m_ident.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::>(body) .map_err(|e| e.into()) }) }) .map(move |body| { GetCreatorRedirectsResponse::FoundEntityRedirects(body) }), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetCreatorRedirectsResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetCreatorRedirectsResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetCreatorRedirectsResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_creator_releases( &self, param_ident: String, param_hide: Option, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/creator/{ident}/releases", self.base_path, ident = utf8_percent_encode(¶m_ident.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); if let Some(param_hide) = param_hide { query_string.append_pair("hide", ¶m_hide.to_string()); } let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::>(body) .map_err(|e| e.into()) }) }) .map(move |body| GetCreatorReleasesResponse::Found(body)), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetCreatorReleasesResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetCreatorReleasesResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetCreatorReleasesResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_creator_revision( &self, param_rev_id: String, param_expand: Option, param_hide: Option, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/creator/rev/{rev_id}", self.base_path, rev_id = utf8_percent_encode(¶m_rev_id.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); if let Some(param_expand) = param_expand { query_string.append_pair("expand", ¶m_expand.to_string()); } if let Some(param_hide) = param_hide { query_string.append_pair("hide", ¶m_hide.to_string()); } let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| { GetCreatorRevisionResponse::FoundEntityRevision(body) }), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetCreatorRevisionResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetCreatorRevisionResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetCreatorRevisionResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_editgroup( &self, param_editgroup_id: String, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/editgroup/{editgroup_id}", self.base_path, editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetEditgroupResponse::Found(body)), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetEditgroupResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetEditgroupResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetEditgroupResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_editgroup_annotations( &self, param_editgroup_id: String, param_expand: Option, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/editgroup/{editgroup_id}/annotations", self.base_path, editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); if let Some(param_expand) = param_expand { query_string.append_pair("expand", ¶m_expand.to_string()); } let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::>(body) .map_err(|e| e.into()) ) ) .map(move |body| { GetEditgroupAnnotationsResponse::Success (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { GetEditgroupAnnotationsResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { GetEditgroupAnnotationsResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { GetEditgroupAnnotationsResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { GetEditgroupAnnotationsResponse::NotFound (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { GetEditgroupAnnotationsResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn get_editgroups_reviewable( &self, param_expand: Option, param_limit: Option, param_before: Option>, param_since: Option>, context: &C, ) -> Box + Send> { let mut uri = format!("{}/v0/editgroup/reviewable", self.base_path); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); if let Some(param_expand) = param_expand { query_string.append_pair("expand", ¶m_expand.to_string()); } if let Some(param_limit) = param_limit { query_string.append_pair("limit", ¶m_limit.to_string()); } if let Some(param_before) = param_before { query_string.append_pair("before", ¶m_before.to_string()); } if let Some(param_since) = param_since { query_string.append_pair("since", ¶m_since.to_string()); } let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::>(body) .map_err(|e| e.into()) }) }) .map(move |body| GetEditgroupsReviewableResponse::Found(body)), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetEditgroupsReviewableResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetEditgroupsReviewableResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| { GetEditgroupsReviewableResponse::GenericError(body) }), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_editor( &self, param_editor_id: String, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/editor/{editor_id}", self.base_path, editor_id = utf8_percent_encode(¶m_editor_id.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetEditorResponse::Found(body)), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetEditorResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetEditorResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetEditorResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_editor_annotations( &self, param_editor_id: String, param_limit: Option, param_before: Option>, param_since: Option>, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/editor/{editor_id}/annotations", self.base_path, editor_id = utf8_percent_encode(¶m_editor_id.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); if let Some(param_limit) = param_limit { query_string.append_pair("limit", ¶m_limit.to_string()); } if let Some(param_before) = param_before { query_string.append_pair("before", ¶m_before.to_string()); } if let Some(param_since) = param_since { query_string.append_pair("since", ¶m_since.to_string()); } let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::>(body) .map_err(|e| e.into()) ) ) .map(move |body| { GetEditorAnnotationsResponse::Success (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { GetEditorAnnotationsResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { GetEditorAnnotationsResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { GetEditorAnnotationsResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { GetEditorAnnotationsResponse::NotFound (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { GetEditorAnnotationsResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn get_editor_editgroups( &self, param_editor_id: String, param_limit: Option, param_before: Option>, param_since: Option>, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/editor/{editor_id}/editgroups", self.base_path, editor_id = utf8_percent_encode(¶m_editor_id.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); if let Some(param_limit) = param_limit { query_string.append_pair("limit", ¶m_limit.to_string()); } if let Some(param_before) = param_before { query_string.append_pair("before", ¶m_before.to_string()); } if let Some(param_since) = param_since { query_string.append_pair("since", ¶m_since.to_string()); } let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::>(body) .map_err(|e| e.into()) }) }) .map(move |body| GetEditorEditgroupsResponse::Found(body)), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetEditorEditgroupsResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetEditorEditgroupsResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetEditorEditgroupsResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_file( &self, param_ident: String, param_expand: Option, param_hide: Option, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/file/{ident}", self.base_path, ident = utf8_percent_encode(¶m_ident.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); if let Some(param_expand) = param_expand { query_string.append_pair("expand", ¶m_expand.to_string()); } if let Some(param_hide) = param_hide { query_string.append_pair("hide", ¶m_hide.to_string()); } let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetFileResponse::FoundEntity(body)), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetFileResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetFileResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetFileResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_file_edit( &self, param_edit_id: String, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/file/edit/{edit_id}", self.base_path, edit_id = utf8_percent_encode(¶m_edit_id.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetFileEditResponse::FoundEdit(body)), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetFileEditResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetFileEditResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetFileEditResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_file_history( &self, param_ident: String, param_limit: Option, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/file/{ident}/history", self.base_path, ident = utf8_percent_encode(¶m_ident.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); if let Some(param_limit) = param_limit { query_string.append_pair("limit", ¶m_limit.to_string()); } let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::>( body, ) .map_err(|e| e.into()) }) }) .map(move |body| GetFileHistoryResponse::FoundEntityHistory(body)), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetFileHistoryResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetFileHistoryResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetFileHistoryResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_file_redirects( &self, param_ident: String, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/file/{ident}/redirects", self.base_path, ident = utf8_percent_encode(¶m_ident.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::>(body) .map_err(|e| e.into()) }) }) .map(move |body| { GetFileRedirectsResponse::FoundEntityRedirects(body) }), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetFileRedirectsResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetFileRedirectsResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetFileRedirectsResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_file_revision( &self, param_rev_id: String, param_expand: Option, param_hide: Option, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/file/rev/{rev_id}", self.base_path, rev_id = utf8_percent_encode(¶m_rev_id.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); if let Some(param_expand) = param_expand { query_string.append_pair("expand", ¶m_expand.to_string()); } if let Some(param_hide) = param_hide { query_string.append_pair("hide", ¶m_hide.to_string()); } let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| { GetFileRevisionResponse::FoundEntityRevision(body) }), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetFileRevisionResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetFileRevisionResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetFileRevisionResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_fileset( &self, param_ident: String, param_expand: Option, param_hide: Option, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/fileset/{ident}", self.base_path, ident = utf8_percent_encode(¶m_ident.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); if let Some(param_expand) = param_expand { query_string.append_pair("expand", ¶m_expand.to_string()); } if let Some(param_hide) = param_hide { query_string.append_pair("hide", ¶m_hide.to_string()); } let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetFilesetResponse::FoundEntity(body)), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetFilesetResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetFilesetResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetFilesetResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_fileset_edit( &self, param_edit_id: String, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/fileset/edit/{edit_id}", self.base_path, edit_id = utf8_percent_encode(¶m_edit_id.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetFilesetEditResponse::FoundEdit(body)), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetFilesetEditResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetFilesetEditResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetFilesetEditResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_fileset_history( &self, param_ident: String, param_limit: Option, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/fileset/{ident}/history", self.base_path, ident = utf8_percent_encode(¶m_ident.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); if let Some(param_limit) = param_limit { query_string.append_pair("limit", ¶m_limit.to_string()); } let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::>( body, ) .map_err(|e| e.into()) }) }) .map(move |body| { GetFilesetHistoryResponse::FoundEntityHistory(body) }), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetFilesetHistoryResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetFilesetHistoryResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetFilesetHistoryResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_fileset_redirects( &self, param_ident: String, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/fileset/{ident}/redirects", self.base_path, ident = utf8_percent_encode(¶m_ident.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::>(body) .map_err(|e| e.into()) }) }) .map(move |body| { GetFilesetRedirectsResponse::FoundEntityRedirects(body) }), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetFilesetRedirectsResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetFilesetRedirectsResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetFilesetRedirectsResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_fileset_revision( &self, param_rev_id: String, param_expand: Option, param_hide: Option, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/fileset/rev/{rev_id}", self.base_path, rev_id = utf8_percent_encode(¶m_rev_id.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); if let Some(param_expand) = param_expand { query_string.append_pair("expand", ¶m_expand.to_string()); } if let Some(param_hide) = param_hide { query_string.append_pair("hide", ¶m_hide.to_string()); } let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| { GetFilesetRevisionResponse::FoundEntityRevision(body) }), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetFilesetRevisionResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetFilesetRevisionResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetFilesetRevisionResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_release( &self, param_ident: String, param_expand: Option, param_hide: Option, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/release/{ident}", self.base_path, ident = utf8_percent_encode(¶m_ident.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); if let Some(param_expand) = param_expand { query_string.append_pair("expand", ¶m_expand.to_string()); } if let Some(param_hide) = param_hide { query_string.append_pair("hide", ¶m_hide.to_string()); } let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetReleaseResponse::FoundEntity(body)), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetReleaseResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetReleaseResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetReleaseResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_release_edit( &self, param_edit_id: String, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/release/edit/{edit_id}", self.base_path, edit_id = utf8_percent_encode(¶m_edit_id.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetReleaseEditResponse::FoundEdit(body)), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetReleaseEditResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetReleaseEditResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetReleaseEditResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_release_files( &self, param_ident: String, param_hide: Option, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/release/{ident}/files", self.base_path, ident = utf8_percent_encode(¶m_ident.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); if let Some(param_hide) = param_hide { query_string.append_pair("hide", ¶m_hide.to_string()); } let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::>(body) .map_err(|e| e.into()) }) }) .map(move |body| GetReleaseFilesResponse::Found(body)), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetReleaseFilesResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetReleaseFilesResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetReleaseFilesResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_release_filesets( &self, param_ident: String, param_hide: Option, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/release/{ident}/filesets", self.base_path, ident = utf8_percent_encode(¶m_ident.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); if let Some(param_hide) = param_hide { query_string.append_pair("hide", ¶m_hide.to_string()); } let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::>(body) .map_err(|e| e.into()) }) }) .map(move |body| GetReleaseFilesetsResponse::Found(body)), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetReleaseFilesetsResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetReleaseFilesetsResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetReleaseFilesetsResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_release_history( &self, param_ident: String, param_limit: Option, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/release/{ident}/history", self.base_path, ident = utf8_percent_encode(¶m_ident.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); if let Some(param_limit) = param_limit { query_string.append_pair("limit", ¶m_limit.to_string()); } let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::>( body, ) .map_err(|e| e.into()) }) }) .map(move |body| { GetReleaseHistoryResponse::FoundEntityHistory(body) }), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetReleaseHistoryResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetReleaseHistoryResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetReleaseHistoryResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_release_redirects( &self, param_ident: String, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/release/{ident}/redirects", self.base_path, ident = utf8_percent_encode(¶m_ident.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::>(body) .map_err(|e| e.into()) }) }) .map(move |body| { GetReleaseRedirectsResponse::FoundEntityRedirects(body) }), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetReleaseRedirectsResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetReleaseRedirectsResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetReleaseRedirectsResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_release_revision( &self, param_rev_id: String, param_expand: Option, param_hide: Option, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/release/rev/{rev_id}", self.base_path, rev_id = utf8_percent_encode(¶m_rev_id.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); if let Some(param_expand) = param_expand { query_string.append_pair("expand", ¶m_expand.to_string()); } if let Some(param_hide) = param_hide { query_string.append_pair("hide", ¶m_hide.to_string()); } let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| { GetReleaseRevisionResponse::FoundEntityRevision(body) }), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetReleaseRevisionResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetReleaseRevisionResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetReleaseRevisionResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_release_webcaptures( &self, param_ident: String, param_hide: Option, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/release/{ident}/webcaptures", self.base_path, ident = utf8_percent_encode(¶m_ident.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); if let Some(param_hide) = param_hide { query_string.append_pair("hide", ¶m_hide.to_string()); } let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::>( body, ) .map_err(|e| e.into()) }) }) .map(move |body| GetReleaseWebcapturesResponse::Found(body)), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetReleaseWebcapturesResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetReleaseWebcapturesResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetReleaseWebcapturesResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_webcapture( &self, param_ident: String, param_expand: Option, param_hide: Option, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/webcapture/{ident}", self.base_path, ident = utf8_percent_encode(¶m_ident.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); if let Some(param_expand) = param_expand { query_string.append_pair("expand", ¶m_expand.to_string()); } if let Some(param_hide) = param_hide { query_string.append_pair("hide", ¶m_hide.to_string()); } let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetWebcaptureResponse::FoundEntity(body)), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetWebcaptureResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetWebcaptureResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetWebcaptureResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_webcapture_edit( &self, param_edit_id: String, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/webcapture/edit/{edit_id}", self.base_path, edit_id = utf8_percent_encode(¶m_edit_id.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetWebcaptureEditResponse::FoundEdit(body)), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetWebcaptureEditResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetWebcaptureEditResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetWebcaptureEditResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_webcapture_history( &self, param_ident: String, param_limit: Option, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/webcapture/{ident}/history", self.base_path, ident = utf8_percent_encode(¶m_ident.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); if let Some(param_limit) = param_limit { query_string.append_pair("limit", ¶m_limit.to_string()); } let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::>( body, ) .map_err(|e| e.into()) }) }) .map(move |body| { GetWebcaptureHistoryResponse::FoundEntityHistory(body) }), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetWebcaptureHistoryResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetWebcaptureHistoryResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetWebcaptureHistoryResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_webcapture_redirects( &self, param_ident: String, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/webcapture/{ident}/redirects", self.base_path, ident = utf8_percent_encode(¶m_ident.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::>(body) .map_err(|e| e.into()) }) }) .map(move |body| { GetWebcaptureRedirectsResponse::FoundEntityRedirects(body) }), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetWebcaptureRedirectsResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetWebcaptureRedirectsResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| { GetWebcaptureRedirectsResponse::GenericError(body) }), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_webcapture_revision( &self, param_rev_id: String, param_expand: Option, param_hide: Option, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/webcapture/rev/{rev_id}", self.base_path, rev_id = utf8_percent_encode(¶m_rev_id.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); if let Some(param_expand) = param_expand { query_string.append_pair("expand", ¶m_expand.to_string()); } if let Some(param_hide) = param_hide { query_string.append_pair("hide", ¶m_hide.to_string()); } let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| { GetWebcaptureRevisionResponse::FoundEntityRevision(body) }), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetWebcaptureRevisionResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetWebcaptureRevisionResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetWebcaptureRevisionResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_work( &self, param_ident: String, param_expand: Option, param_hide: Option, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/work/{ident}", self.base_path, ident = utf8_percent_encode(¶m_ident.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); if let Some(param_expand) = param_expand { query_string.append_pair("expand", ¶m_expand.to_string()); } if let Some(param_hide) = param_hide { query_string.append_pair("hide", ¶m_hide.to_string()); } let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetWorkResponse::FoundEntity(body)), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetWorkResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetWorkResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetWorkResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_work_edit( &self, param_edit_id: String, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/work/edit/{edit_id}", self.base_path, edit_id = utf8_percent_encode(¶m_edit_id.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetWorkEditResponse::FoundEdit(body)), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetWorkEditResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetWorkEditResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetWorkEditResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_work_history( &self, param_ident: String, param_limit: Option, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/work/{ident}/history", self.base_path, ident = utf8_percent_encode(¶m_ident.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); if let Some(param_limit) = param_limit { query_string.append_pair("limit", ¶m_limit.to_string()); } let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::>( body, ) .map_err(|e| e.into()) }) }) .map(move |body| GetWorkHistoryResponse::FoundEntityHistory(body)), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetWorkHistoryResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetWorkHistoryResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetWorkHistoryResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_work_redirects( &self, param_ident: String, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/work/{ident}/redirects", self.base_path, ident = utf8_percent_encode(¶m_ident.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::>(body) .map_err(|e| e.into()) }) }) .map(move |body| { GetWorkRedirectsResponse::FoundEntityRedirects(body) }), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetWorkRedirectsResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetWorkRedirectsResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetWorkRedirectsResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_work_releases( &self, param_ident: String, param_hide: Option, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/work/{ident}/releases", self.base_path, ident = utf8_percent_encode(¶m_ident.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); if let Some(param_hide) = param_hide { query_string.append_pair("hide", ¶m_hide.to_string()); } let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::>(body) .map_err(|e| e.into()) }) }) .map(move |body| GetWorkReleasesResponse::Found(body)), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetWorkReleasesResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetWorkReleasesResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetWorkReleasesResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn get_work_revision( &self, param_rev_id: String, param_expand: Option, param_hide: Option, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/work/rev/{rev_id}", self.base_path, rev_id = utf8_percent_encode(¶m_rev_id.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); if let Some(param_expand) = param_expand { query_string.append_pair("expand", ¶m_expand.to_string()); } if let Some(param_hide) = param_hide { query_string.append_pair("hide", ¶m_hide.to_string()); } let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| { GetWorkRevisionResponse::FoundEntityRevision(body) }), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetWorkRevisionResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetWorkRevisionResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| GetWorkRevisionResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn lookup_container( &self, param_issnl: Option, param_wikidata_qid: Option, param_expand: Option, param_hide: Option, context: &C, ) -> Box + Send> { let mut uri = format!("{}/v0/container/lookup", self.base_path); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); if let Some(param_issnl) = param_issnl { query_string.append_pair("issnl", ¶m_issnl.to_string()); } if let Some(param_wikidata_qid) = param_wikidata_qid { query_string.append_pair("wikidata_qid", ¶m_wikidata_qid.to_string()); } if let Some(param_expand) = param_expand { query_string.append_pair("expand", ¶m_expand.to_string()); } if let Some(param_hide) = param_hide { query_string.append_pair("hide", ¶m_hide.to_string()); } let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| LookupContainerResponse::FoundEntity(body)), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| LookupContainerResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| LookupContainerResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| LookupContainerResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn lookup_creator( &self, param_orcid: Option, param_wikidata_qid: Option, param_expand: Option, param_hide: Option, context: &C, ) -> Box + Send> { let mut uri = format!("{}/v0/creator/lookup", self.base_path); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); if let Some(param_orcid) = param_orcid { query_string.append_pair("orcid", ¶m_orcid.to_string()); } if let Some(param_wikidata_qid) = param_wikidata_qid { query_string.append_pair("wikidata_qid", ¶m_wikidata_qid.to_string()); } if let Some(param_expand) = param_expand { query_string.append_pair("expand", ¶m_expand.to_string()); } if let Some(param_hide) = param_hide { query_string.append_pair("hide", ¶m_hide.to_string()); } let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| LookupCreatorResponse::FoundEntity(body)), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| LookupCreatorResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| LookupCreatorResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| LookupCreatorResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn lookup_file( &self, param_md5: Option, param_sha1: Option, param_sha256: Option, param_expand: Option, param_hide: Option, context: &C, ) -> Box + Send> { let mut uri = format!("{}/v0/file/lookup", self.base_path); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); if let Some(param_md5) = param_md5 { query_string.append_pair("md5", ¶m_md5.to_string()); } if let Some(param_sha1) = param_sha1 { query_string.append_pair("sha1", ¶m_sha1.to_string()); } if let Some(param_sha256) = param_sha256 { query_string.append_pair("sha256", ¶m_sha256.to_string()); } if let Some(param_expand) = param_expand { query_string.append_pair("expand", ¶m_expand.to_string()); } if let Some(param_hide) = param_hide { query_string.append_pair("hide", ¶m_hide.to_string()); } let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| LookupFileResponse::FoundEntity(body)), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| LookupFileResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| LookupFileResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| LookupFileResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn lookup_release( &self, param_doi: Option, param_wikidata_qid: Option, param_isbn13: Option, param_pmid: Option, param_pmcid: Option, param_core: Option, param_arxiv: Option, param_jstor: Option, param_ark: Option, param_mag: Option, param_expand: Option, param_hide: Option, context: &C, ) -> Box + Send> { let mut uri = format!("{}/v0/release/lookup", self.base_path); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); if let Some(param_doi) = param_doi { query_string.append_pair("doi", ¶m_doi.to_string()); } if let Some(param_wikidata_qid) = param_wikidata_qid { query_string.append_pair("wikidata_qid", ¶m_wikidata_qid.to_string()); } if let Some(param_isbn13) = param_isbn13 { query_string.append_pair("isbn13", ¶m_isbn13.to_string()); } if let Some(param_pmid) = param_pmid { query_string.append_pair("pmid", ¶m_pmid.to_string()); } if let Some(param_pmcid) = param_pmcid { query_string.append_pair("pmcid", ¶m_pmcid.to_string()); } if let Some(param_core) = param_core { query_string.append_pair("core", ¶m_core.to_string()); } if let Some(param_arxiv) = param_arxiv { query_string.append_pair("arxiv", ¶m_arxiv.to_string()); } if let Some(param_jstor) = param_jstor { query_string.append_pair("jstor", ¶m_jstor.to_string()); } if let Some(param_ark) = param_ark { query_string.append_pair("ark", ¶m_ark.to_string()); } if let Some(param_mag) = param_mag { query_string.append_pair("mag", ¶m_mag.to_string()); } if let Some(param_expand) = param_expand { query_string.append_pair("expand", ¶m_expand.to_string()); } if let Some(param_hide) = param_hide { query_string.append_pair("hide", ¶m_hide.to_string()); } let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("GET") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); Box::new( self.client_service .request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| LookupReleaseResponse::FoundEntity(body)), ) as Box + Send> } 400 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| LookupReleaseResponse::BadRequest(body)), ) as Box + Send> } 404 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| LookupReleaseResponse::NotFound(body)), ) as Box + Send> } 500 => { let body = response.into_body(); Box::new( body.concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| { str::from_utf8(&body) .map_err(|e| { ApiError(format!("Response was not valid UTF8: {}", e)) }) .and_then(|body| { serde_json::from_str::(body) .map_err(|e| e.into()) }) }) .map(move |body| LookupReleaseResponse::GenericError(body)), ) as Box + Send> } code => { let headers = response.headers().clone(); Box::new(response.into_body().take(100).concat2().then(move |body| { future::err(ApiError(format!( "Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), } ))) })) as Box + Send> } }), ) } fn update_container( &self, param_editgroup_id: String, param_ident: String, param_container_entity: models::ContainerEntity, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/editgroup/{editgroup_id}/container/{ident}", self.base_path, editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), ID_ENCODE_SET), ident = utf8_percent_encode(¶m_ident.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("PUT") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let body = serde_json::to_string(¶m_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 Box::new(future::err(ApiError(format!( "Unable to create header: {} - {}", header, e )))) } }, ); let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateContainerResponse::UpdatedEntity (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateContainerResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateContainerResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateContainerResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateContainerResponse::NotFound (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateContainerResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn update_creator( &self, param_editgroup_id: String, param_ident: String, param_creator_entity: models::CreatorEntity, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/editgroup/{editgroup_id}/creator/{ident}", self.base_path, editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), ID_ENCODE_SET), ident = utf8_percent_encode(¶m_ident.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("PUT") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let body = serde_json::to_string(¶m_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 Box::new(future::err(ApiError(format!( "Unable to create header: {} - {}", header, e )))) } }, ); let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateCreatorResponse::UpdatedEntity (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateCreatorResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateCreatorResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateCreatorResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateCreatorResponse::NotFound (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateCreatorResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn update_editgroup( &self, param_editgroup_id: String, param_editgroup: models::Editgroup, param_submit: Option, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/editgroup/{editgroup_id}", self.base_path, editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); if let Some(param_submit) = param_submit { query_string.append_pair("submit", ¶m_submit.to_string()); } let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("PUT") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let body = serde_json::to_string(¶m_editgroup).expect("impossible to fail to serialize"); *request.body_mut() = Body::from(body); let header = "application/json"; request.headers_mut().insert( CONTENT_TYPE, match HeaderValue::from_str(header) { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create header: {} - {}", header, e )))) } }, ); let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateEditgroupResponse::UpdatedEditgroup (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateEditgroupResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateEditgroupResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateEditgroupResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateEditgroupResponse::NotFound (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateEditgroupResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn update_editor( &self, param_editor_id: String, param_editor: models::Editor, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/editor/{editor_id}", self.base_path, editor_id = utf8_percent_encode(¶m_editor_id.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("PUT") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let body = serde_json::to_string(¶m_editor).expect("impossible to fail to serialize"); *request.body_mut() = Body::from(body); let header = "application/json"; request.headers_mut().insert( CONTENT_TYPE, match HeaderValue::from_str(header) { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create header: {} - {}", header, e )))) } }, ); let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateEditorResponse::UpdatedEditor (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateEditorResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateEditorResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateEditorResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateEditorResponse::NotFound (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateEditorResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn update_file( &self, param_editgroup_id: String, param_ident: String, param_file_entity: models::FileEntity, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/editgroup/{editgroup_id}/file/{ident}", self.base_path, editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), ID_ENCODE_SET), ident = utf8_percent_encode(¶m_ident.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("PUT") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let body = serde_json::to_string(¶m_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 Box::new(future::err(ApiError(format!( "Unable to create header: {} - {}", header, e )))) } }, ); let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateFileResponse::UpdatedEntity (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateFileResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateFileResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateFileResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateFileResponse::NotFound (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateFileResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn update_fileset( &self, param_editgroup_id: String, param_ident: String, param_fileset_entity: models::FilesetEntity, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/editgroup/{editgroup_id}/fileset/{ident}", self.base_path, editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), ID_ENCODE_SET), ident = utf8_percent_encode(¶m_ident.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("PUT") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let body = serde_json::to_string(¶m_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 Box::new(future::err(ApiError(format!( "Unable to create header: {} - {}", header, e )))) } }, ); let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateFilesetResponse::UpdatedEntity (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateFilesetResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateFilesetResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateFilesetResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateFilesetResponse::NotFound (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateFilesetResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn update_release( &self, param_editgroup_id: String, param_ident: String, param_release_entity: models::ReleaseEntity, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/editgroup/{editgroup_id}/release/{ident}", self.base_path, editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), ID_ENCODE_SET), ident = utf8_percent_encode(¶m_ident.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("PUT") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let body = serde_json::to_string(¶m_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 Box::new(future::err(ApiError(format!( "Unable to create header: {} - {}", header, e )))) } }, ); let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateReleaseResponse::UpdatedEntity (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateReleaseResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateReleaseResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateReleaseResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateReleaseResponse::NotFound (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateReleaseResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn update_webcapture( &self, param_editgroup_id: String, param_ident: String, param_webcapture_entity: models::WebcaptureEntity, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/editgroup/{editgroup_id}/webcapture/{ident}", self.base_path, editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), ID_ENCODE_SET), ident = utf8_percent_encode(¶m_ident.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("PUT") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let body = serde_json::to_string(¶m_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 Box::new(future::err(ApiError(format!( "Unable to create header: {} - {}", header, e )))) } }, ); let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateWebcaptureResponse::UpdatedEntity (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateWebcaptureResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateWebcaptureResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateWebcaptureResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateWebcaptureResponse::NotFound (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateWebcaptureResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } fn update_work( &self, param_editgroup_id: String, param_ident: String, param_work_entity: models::WorkEntity, context: &C, ) -> Box + Send> { let mut uri = format!( "{}/v0/editgroup/{editgroup_id}/work/{ident}", self.base_path, editgroup_id = utf8_percent_encode(¶m_editgroup_id.to_string(), ID_ENCODE_SET), ident = utf8_percent_encode(¶m_ident.to_string(), ID_ENCODE_SET) ); // Query parameters let mut query_string = url::form_urlencoded::Serializer::new("".to_owned()); let query_string_str = query_string.finish(); if !query_string_str.is_empty() { uri += "?"; uri += &query_string_str; } let uri = match Uri::from_str(&uri) { Ok(uri) => uri, Err(err) => { return Box::new(future::err(ApiError(format!( "Unable to build URI: {}", err )))) } }; let mut request = match hyper::Request::builder() .method("PUT") .uri(uri) .body(Body::empty()) { Ok(req) => req, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create request: {}", e )))) } }; let body = serde_json::to_string(¶m_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 Box::new(future::err(ApiError(format!( "Unable to create header: {} - {}", header, e )))) } }, ); let header = HeaderValue::from_str( (context as &dyn Has) .get() .0 .clone() .to_string() .as_str(), ); request.headers_mut().insert( HeaderName::from_static("x-span-id"), match header { Ok(h) => h, Err(e) => { return Box::new(future::err(ApiError(format!( "Unable to create X-Span ID header value: {}", e )))) } }, ); if let Some(auth_data) = (context as &dyn Has>).get().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 Box::new(future::err(ApiError(format!( "Unable to create Authorization header: {}", e )))) } }; request .headers_mut() .insert(hyper::header::AUTHORIZATION, header); } _ => {} } } Box::new(self.client_service.request(request) .map_err(|e| ApiError(format!("No response received: {}", e))) .and_then(|mut response| { match response.status().as_u16() { 200 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateWorkResponse::UpdatedEntity (body) }) ) as Box + Send> }, 400 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateWorkResponse::BadRequest (body) }) ) as Box + Send> }, 401 => { let response_www_authenticate = match response.headers().get(HeaderName::from_static("www_authenticate")) { Some(response_www_authenticate) => response_www_authenticate.clone(), None => return Box::new(future::err(ApiError(String::from("Required response header WWW_Authenticate for response 401 was not found.")))) as Box + Send>, }; let response_www_authenticate = match TryInto::>::try_into(response_www_authenticate) { Ok(value) => value, Err(e) => { return Box::new(future::err(ApiError(format!("Invalid response header WWW_Authenticate for response 401 - {}", e)))) as Box + Send>; }, }; let response_www_authenticate = response_www_authenticate.0; let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateWorkResponse::NotAuthorized { body: body, www_authenticate: response_www_authenticate, } }) ) as Box + Send> }, 403 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateWorkResponse::Forbidden (body) }) ) as Box + Send> }, 404 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateWorkResponse::NotFound (body) }) ) as Box + Send> }, 500 => { let body = response.into_body(); Box::new( body .concat2() .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| serde_json::from_str::(body) .map_err(|e| e.into()) ) ) .map(move |body| { UpdateWorkResponse::GenericError (body) }) ) as Box + Send> }, code => { let headers = response.headers().clone(); Box::new(response.into_body() .take(100) .concat2() .then(move |body| future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, headers, match body { Ok(ref body) => match str::from_utf8(body) { Ok(body) => Cow::from(body), Err(e) => Cow::from(format!("", e)), }, Err(e) => Cow::from(format!("", e)), }))) ) ) as Box + Send> } } })) } }