use std::sync::Arc;
use std::borrow::Borrow;
use std::pin::Pin;
#[allow(unused_imports)]
use std::option::Option;
use hyper;
use hyper_util::client::legacy::connect::Connect;
use futures::Future;
use crate::models;
use super::{Error, configuration};
use super::request as __internal_request;
pub struct IndexApiClient<C: Connect>
where C: Clone + std::marker::Send + Sync + 'static {
configuration: Arc<configuration::Configuration<C>>,
}
impl<C: Connect> IndexApiClient<C>
where C: Clone + std::marker::Send + Sync {
pub fn new(configuration: Arc<configuration::Configuration<C>>) -> IndexApiClient<C> {
IndexApiClient {
configuration,
}
}
}
pub trait IndexApi: Send + Sync {
fn bulk(&self, body: &str) -> Pin<Box<dyn Future<Output = Result<models::BulkResponse, Error>> + Send>>;
fn delete(&self, delete_document_request: models::DeleteDocumentRequest) -> Pin<Box<dyn Future<Output = Result<models::DeleteResponse, Error>> + Send>>;
fn insert(&self, insert_document_request: models::InsertDocumentRequest) -> Pin<Box<dyn Future<Output = Result<models::SuccessResponse, Error>> + Send>>;
fn partial_replace(&self, table: &str, id: u64, replace_document_request: models::ReplaceDocumentRequest) -> Pin<Box<dyn Future<Output = Result<models::UpdateResponse, Error>> + Send>>;
fn replace(&self, insert_document_request: models::InsertDocumentRequest) -> Pin<Box<dyn Future<Output = Result<models::SuccessResponse, Error>> + Send>>;
fn update(&self, update_document_request: models::UpdateDocumentRequest) -> Pin<Box<dyn Future<Output = Result<models::UpdateResponse, Error>> + Send>>;
}
impl<C: Connect>IndexApi for IndexApiClient<C>
where C: Clone + std::marker::Send + Sync {
#[allow(unused_mut)]
fn bulk(&self, body: &str) -> Pin<Box<dyn Future<Output = Result<models::BulkResponse, Error>> + Send>> {
let mut req = __internal_request::Request::new(hyper::Method::POST, "/bulk".to_string())
;
req = req.with_body_param(body);
req.execute(self.configuration.borrow())
}
#[allow(unused_mut)]
fn delete(&self, delete_document_request: models::DeleteDocumentRequest) -> Pin<Box<dyn Future<Output = Result<models::DeleteResponse, Error>> + Send>> {
let mut req = __internal_request::Request::new(hyper::Method::POST, "/delete".to_string())
;
req = req.with_body_param(delete_document_request);
req.execute(self.configuration.borrow())
}
#[allow(unused_mut)]
fn insert(&self, insert_document_request: models::InsertDocumentRequest) -> Pin<Box<dyn Future<Output = Result<models::SuccessResponse, Error>> + Send>> {
let mut req = __internal_request::Request::new(hyper::Method::POST, "/insert".to_string())
;
req = req.with_body_param(insert_document_request);
req.execute(self.configuration.borrow())
}
#[allow(unused_mut)]
fn partial_replace(&self, table: &str, id: u64, replace_document_request: models::ReplaceDocumentRequest) -> Pin<Box<dyn Future<Output = Result<models::UpdateResponse, Error>> + Send>> {
let mut req = __internal_request::Request::new(hyper::Method::POST, "/{table}/_update/{id}".to_string())
;
req = req.with_path_param("table".to_string(), table.to_string());
req = req.with_path_param("id".to_string(), id.to_string());
req = req.with_body_param(replace_document_request);
req.execute(self.configuration.borrow())
}
#[allow(unused_mut)]
fn replace(&self, insert_document_request: models::InsertDocumentRequest) -> Pin<Box<dyn Future<Output = Result<models::SuccessResponse, Error>> + Send>> {
let mut req = __internal_request::Request::new(hyper::Method::POST, "/replace".to_string())
;
req = req.with_body_param(insert_document_request);
req.execute(self.configuration.borrow())
}
#[allow(unused_mut)]
fn update(&self, update_document_request: models::UpdateDocumentRequest) -> Pin<Box<dyn Future<Output = Result<models::UpdateResponse, Error>> + Send>> {
let mut req = __internal_request::Request::new(hyper::Method::POST, "/update".to_string())
;
req = req.with_body_param(update_document_request);
req.execute(self.configuration.borrow())
}
}