use super::types;
use crate::{
ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt,
ResponseValue, encode_path,
};
#[derive(Debug, Clone)]
pub struct AiSearchListInstances<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
page: Result<::std::num::NonZeroU64, String>,
per_page: Result<::std::num::NonZeroU64, String>,
search: Result<::std::string::String, String>,
}
impl<'a> AiSearchListInstances<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
page: Err("page was not initialized".to_string()),
per_page: Err("per_page was not initialized".to_string()),
search: Err("search was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::num::NonZeroU64>,
{
self.page = value.try_into().map_err(|_| {
"conversion to `:: std :: num :: NonZeroU64` for page failed".to_string()
});
self
}
pub fn per_page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::num::NonZeroU64>,
{
self.per_page = value.try_into().map_err(|_| {
"conversion to `:: std :: num :: NonZeroU64` for per_page failed".to_string()
});
self
}
pub fn search<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.search = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for search failed".to_string()
});
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
page,
per_page,
search,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let page = page.map_err(Error::InvalidRequest)?;
let per_page = per_page.map_err(Error::InvalidRequest)?;
let search = search.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai-search/instances",
client.baseurl,
encode_path(&account_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.query(&progenitor_client::QueryParam::new("page", &page))
.query(&progenitor_client::QueryParam::new("per_page", &per_page))
.query(&progenitor_client::QueryParam::new("search", &search))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "ai_search_list_instances",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct AiSearchCreateInstances<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
body: Result<types::builder::AiSearchCreateInstancesBody, String>,
}
impl<'a> AiSearchCreateInstances<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AiSearchCreateInstancesBody>,
<V as std::convert::TryInto<types::AiSearchCreateInstancesBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `AiSearchCreateInstancesBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::AiSearchCreateInstancesBody,
) -> types::builder::AiSearchCreateInstancesBody,
{
self.body = self.body.map(f);
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::AiSearchCreateInstancesBody::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai-search/instances",
client.baseurl,
encode_path(&account_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.post(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "ai_search_create_instances",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
201u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct AiSearchFetchInstances<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
id: Result<types::AiSearchFetchInstancesId, String>,
}
impl<'a> AiSearchFetchInstances<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
id: Err("id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AiSearchFetchInstancesId>,
{
self.id = value
.try_into()
.map_err(|_| "conversion to `AiSearchFetchInstancesId` for id failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let id = id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai-search/instances/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "ai_search_fetch_instances",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct AiSearchUpdateInstances<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
id: Result<types::AiSearchUpdateInstancesId, String>,
body: Result<types::builder::AiSearchUpdateInstancesBody, String>,
}
impl<'a> AiSearchUpdateInstances<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
id: Err("id was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AiSearchUpdateInstancesId>,
{
self.id = value
.try_into()
.map_err(|_| "conversion to `AiSearchUpdateInstancesId` for id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AiSearchUpdateInstancesBody>,
<V as std::convert::TryInto<types::AiSearchUpdateInstancesBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `AiSearchUpdateInstancesBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::AiSearchUpdateInstancesBody,
) -> types::builder::AiSearchUpdateInstancesBody,
{
self.body = self.body.map(f);
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let id = id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::AiSearchUpdateInstancesBody::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai-search/instances/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.put(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "ai_search_update_instances",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct AiSearchDeleteInstances<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
id: Result<types::AiSearchDeleteInstancesId, String>,
}
impl<'a> AiSearchDeleteInstances<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
id: Err("id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AiSearchDeleteInstancesId>,
{
self.id = value
.try_into()
.map_err(|_| "conversion to `AiSearchDeleteInstancesId` for id failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let id = id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai-search/instances/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.delete(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "ai_search_delete_instances",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct AiSearchInstanceChatCompletion<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
id: Result<types::AiSearchInstanceChatCompletionId, String>,
body: Result<types::builder::AiSearchInstanceChatCompletionBody, String>,
}
impl<'a> AiSearchInstanceChatCompletion<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
id: Err("id was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AiSearchInstanceChatCompletionId>,
{
self.id = value.try_into().map_err(|_| {
"conversion to `AiSearchInstanceChatCompletionId` for id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AiSearchInstanceChatCompletionBody>,
<V as std::convert::TryInto<types::AiSearchInstanceChatCompletionBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `AiSearchInstanceChatCompletionBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::AiSearchInstanceChatCompletionBody,
) -> types::builder::AiSearchInstanceChatCompletionBody,
{
self.body = self.body.map(f);
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let id = id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::AiSearchInstanceChatCompletionBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai-search/instances/{}/chat/completions",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.post(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "ai_search_instance_chat_completion",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct AiSearchInstanceListItems<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
id: Result<types::AiSearchInstanceListItemsId, String>,
page: Result<::std::num::NonZeroU64, String>,
per_page: Result<i64, String>,
search: Result<::std::string::String, String>,
status: Result<types::AiSearchInstanceListItemsStatus, String>,
}
impl<'a> AiSearchInstanceListItems<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
id: Err("id was not initialized".to_string()),
page: Err("page was not initialized".to_string()),
per_page: Err("per_page was not initialized".to_string()),
search: Err("search was not initialized".to_string()),
status: Err("status was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AiSearchInstanceListItemsId>,
{
self.id = value.try_into().map_err(|_| {
"conversion to `AiSearchInstanceListItemsId` for id failed".to_string()
});
self
}
pub fn page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::num::NonZeroU64>,
{
self.page = value.try_into().map_err(|_| {
"conversion to `:: std :: num :: NonZeroU64` for page failed".to_string()
});
self
}
pub fn per_page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<i64>,
{
self.per_page = value
.try_into()
.map_err(|_| "conversion to `i64` for per_page failed".to_string());
self
}
pub fn search<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.search = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for search failed".to_string()
});
self
}
pub fn status<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AiSearchInstanceListItemsStatus>,
{
self.status = value.try_into().map_err(|_| {
"conversion to `AiSearchInstanceListItemsStatus` for status failed".to_string()
});
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
id,
page,
per_page,
search,
status,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let id = id.map_err(Error::InvalidRequest)?;
let page = page.map_err(Error::InvalidRequest)?;
let per_page = per_page.map_err(Error::InvalidRequest)?;
let search = search.map_err(Error::InvalidRequest)?;
let status = status.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai-search/instances/{}/items",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.query(&progenitor_client::QueryParam::new("page", &page))
.query(&progenitor_client::QueryParam::new("per_page", &per_page))
.query(&progenitor_client::QueryParam::new("search", &search))
.query(&progenitor_client::QueryParam::new("status", &status))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "ai_search_instance_list_items",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct AiSearchInstanceCreateOrUpdateItem<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
id: Result<types::AiSearchInstanceCreateOrUpdateItemId, String>,
body: Result<types::builder::AiSearchInstanceCreateOrUpdateItemBody, String>,
}
impl<'a> AiSearchInstanceCreateOrUpdateItem<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
id: Err("id was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AiSearchInstanceCreateOrUpdateItemId>,
{
self.id = value.try_into().map_err(|_| {
"conversion to `AiSearchInstanceCreateOrUpdateItemId` for id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AiSearchInstanceCreateOrUpdateItemBody>,
<V as std::convert::TryInto<types::AiSearchInstanceCreateOrUpdateItemBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `AiSearchInstanceCreateOrUpdateItemBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::AiSearchInstanceCreateOrUpdateItemBody,
)
-> types::builder::AiSearchInstanceCreateOrUpdateItemBody,
{
self.body = self.body.map(f);
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let id = id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::AiSearchInstanceCreateOrUpdateItemBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai-search/instances/{}/items",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.put(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "ai_search_instance_create_or_update_item",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct AiSearchInstanceGetItem<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
id: Result<types::AiSearchInstanceGetItemId, String>,
item_id: Result<::std::string::String, String>,
}
impl<'a> AiSearchInstanceGetItem<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
id: Err("id was not initialized".to_string()),
item_id: Err("item_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AiSearchInstanceGetItemId>,
{
self.id = value
.try_into()
.map_err(|_| "conversion to `AiSearchInstanceGetItemId` for id failed".to_string());
self
}
pub fn item_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.item_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for item_id failed".to_string()
});
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
id,
item_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let id = id.map_err(Error::InvalidRequest)?;
let item_id = item_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai-search/instances/{}/items/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&id.to_string()),
encode_path(&item_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "ai_search_instance_get_item",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct AiSearchInstanceSyncItem<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
id: Result<types::AiSearchInstanceSyncItemId, String>,
item_id: Result<::std::string::String, String>,
body: Result<types::builder::AiSearchInstanceSyncItemBody, String>,
}
impl<'a> AiSearchInstanceSyncItem<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
id: Err("id was not initialized".to_string()),
item_id: Err("item_id was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AiSearchInstanceSyncItemId>,
{
self.id = value.try_into().map_err(|_| {
"conversion to `AiSearchInstanceSyncItemId` for id failed".to_string()
});
self
}
pub fn item_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.item_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for item_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AiSearchInstanceSyncItemBody>,
<V as std::convert::TryInto<types::AiSearchInstanceSyncItemBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `AiSearchInstanceSyncItemBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::AiSearchInstanceSyncItemBody,
) -> types::builder::AiSearchInstanceSyncItemBody,
{
self.body = self.body.map(f);
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
id,
item_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let id = id.map_err(Error::InvalidRequest)?;
let item_id = item_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::AiSearchInstanceSyncItemBody::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai-search/instances/{}/items/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&id.to_string()),
encode_path(&item_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.patch(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "ai_search_instance_sync_item",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct AiSearchInstanceListJobs<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
id: Result<types::AiSearchInstanceListJobsId, String>,
page: Result<::std::num::NonZeroU64, String>,
per_page: Result<i64, String>,
}
impl<'a> AiSearchInstanceListJobs<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
id: Err("id was not initialized".to_string()),
page: Err("page was not initialized".to_string()),
per_page: Err("per_page was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AiSearchInstanceListJobsId>,
{
self.id = value.try_into().map_err(|_| {
"conversion to `AiSearchInstanceListJobsId` for id failed".to_string()
});
self
}
pub fn page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::num::NonZeroU64>,
{
self.page = value.try_into().map_err(|_| {
"conversion to `:: std :: num :: NonZeroU64` for page failed".to_string()
});
self
}
pub fn per_page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<i64>,
{
self.per_page = value
.try_into()
.map_err(|_| "conversion to `i64` for per_page failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
id,
page,
per_page,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let id = id.map_err(Error::InvalidRequest)?;
let page = page.map_err(Error::InvalidRequest)?;
let per_page = per_page.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai-search/instances/{}/jobs",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.query(&progenitor_client::QueryParam::new("page", &page))
.query(&progenitor_client::QueryParam::new("per_page", &per_page))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "ai_search_instance_list_jobs",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct AiSearchInstanceCreateJob<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
id: Result<types::AiSearchInstanceCreateJobId, String>,
}
impl<'a> AiSearchInstanceCreateJob<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
id: Err("id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AiSearchInstanceCreateJobId>,
{
self.id = value.try_into().map_err(|_| {
"conversion to `AiSearchInstanceCreateJobId` for id failed".to_string()
});
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let id = id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai-search/instances/{}/jobs",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.post(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "ai_search_instance_create_job",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct AiSearchInstanceGetJob<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
id: Result<types::AiSearchInstanceGetJobId, String>,
job_id: Result<::std::string::String, String>,
}
impl<'a> AiSearchInstanceGetJob<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
id: Err("id was not initialized".to_string()),
job_id: Err("job_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AiSearchInstanceGetJobId>,
{
self.id = value
.try_into()
.map_err(|_| "conversion to `AiSearchInstanceGetJobId` for id failed".to_string());
self
}
pub fn job_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.job_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for job_id failed".to_string()
});
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
id,
job_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let id = id.map_err(Error::InvalidRequest)?;
let job_id = job_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai-search/instances/{}/jobs/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&id.to_string()),
encode_path(&job_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "ai_search_instance_get_job",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct AiSearchInstanceChangeJobStatus<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
id: Result<types::AiSearchInstanceChangeJobStatusId, String>,
job_id: Result<::std::string::String, String>,
body: Result<types::builder::AiSearchInstanceChangeJobStatusBody, String>,
}
impl<'a> AiSearchInstanceChangeJobStatus<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
id: Err("id was not initialized".to_string()),
job_id: Err("job_id was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AiSearchInstanceChangeJobStatusId>,
{
self.id = value.try_into().map_err(|_| {
"conversion to `AiSearchInstanceChangeJobStatusId` for id failed".to_string()
});
self
}
pub fn job_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.job_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for job_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AiSearchInstanceChangeJobStatusBody>,
<V as std::convert::TryInto<types::AiSearchInstanceChangeJobStatusBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `AiSearchInstanceChangeJobStatusBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::AiSearchInstanceChangeJobStatusBody,
) -> types::builder::AiSearchInstanceChangeJobStatusBody,
{
self.body = self.body.map(f);
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
id,
job_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let id = id.map_err(Error::InvalidRequest)?;
let job_id = job_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::AiSearchInstanceChangeJobStatusBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai-search/instances/{}/jobs/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&id.to_string()),
encode_path(&job_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.patch(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "ai_search_instance_change_job_status",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct AiSearchInstanceListJobLogs<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
id: Result<types::AiSearchInstanceListJobLogsId, String>,
job_id: Result<::std::string::String, String>,
page: Result<::std::num::NonZeroU64, String>,
per_page: Result<i64, String>,
}
impl<'a> AiSearchInstanceListJobLogs<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
id: Err("id was not initialized".to_string()),
job_id: Err("job_id was not initialized".to_string()),
page: Err("page was not initialized".to_string()),
per_page: Err("per_page was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AiSearchInstanceListJobLogsId>,
{
self.id = value.try_into().map_err(|_| {
"conversion to `AiSearchInstanceListJobLogsId` for id failed".to_string()
});
self
}
pub fn job_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.job_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for job_id failed".to_string()
});
self
}
pub fn page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::num::NonZeroU64>,
{
self.page = value.try_into().map_err(|_| {
"conversion to `:: std :: num :: NonZeroU64` for page failed".to_string()
});
self
}
pub fn per_page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<i64>,
{
self.per_page = value
.try_into()
.map_err(|_| "conversion to `i64` for per_page failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
id,
job_id,
page,
per_page,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let id = id.map_err(Error::InvalidRequest)?;
let job_id = job_id.map_err(Error::InvalidRequest)?;
let page = page.map_err(Error::InvalidRequest)?;
let per_page = per_page.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai-search/instances/{}/jobs/{}/logs",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&id.to_string()),
encode_path(&job_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.query(&progenitor_client::QueryParam::new("page", &page))
.query(&progenitor_client::QueryParam::new("per_page", &per_page))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "ai_search_instance_list_job_logs",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct AiSearchInstanceSearch<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
id: Result<types::AiSearchInstanceSearchId, String>,
body: Result<types::builder::AiSearchInstanceSearchBody, String>,
}
impl<'a> AiSearchInstanceSearch<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
id: Err("id was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AiSearchInstanceSearchId>,
{
self.id = value
.try_into()
.map_err(|_| "conversion to `AiSearchInstanceSearchId` for id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AiSearchInstanceSearchBody>,
<V as std::convert::TryInto<types::AiSearchInstanceSearchBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `AiSearchInstanceSearchBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::AiSearchInstanceSearchBody,
) -> types::builder::AiSearchInstanceSearchBody,
{
self.body = self.body.map(f);
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let id = id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::AiSearchInstanceSearchBody::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai-search/instances/{}/search",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.post(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "ai_search_instance_search",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct AiSearchStats<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
id: Result<types::AiSearchStatsId, String>,
}
impl<'a> AiSearchStats<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
id: Err("id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AiSearchStatsId>,
{
self.id = value
.try_into()
.map_err(|_| "conversion to `AiSearchStatsId` for id failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let id = id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai-search/instances/{}/stats",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "ai_search_stats",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct AiSearchFetchTokens<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
id: Result<::uuid::Uuid, String>,
}
impl<'a> AiSearchFetchTokens<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
id: Err("id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::uuid::Uuid>,
{
self.id = value
.try_into()
.map_err(|_| "conversion to `:: uuid :: Uuid` for id failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let id = id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai-search/tokens/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "ai_search_fetch_tokens",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct AiSearchUpdateTokens<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
id: Result<::uuid::Uuid, String>,
body: Result<types::builder::AiSearchUpdateTokensBody, String>,
}
impl<'a> AiSearchUpdateTokens<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
id: Err("id was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::uuid::Uuid>,
{
self.id = value
.try_into()
.map_err(|_| "conversion to `:: uuid :: Uuid` for id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AiSearchUpdateTokensBody>,
<V as std::convert::TryInto<types::AiSearchUpdateTokensBody>>::Error: std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `AiSearchUpdateTokensBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::AiSearchUpdateTokensBody,
) -> types::builder::AiSearchUpdateTokensBody,
{
self.body = self.body.map(f);
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let id = id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::AiSearchUpdateTokensBody::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai-search/tokens/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.put(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "ai_search_update_tokens",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct AiSearchDeleteTokens<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
id: Result<::uuid::Uuid, String>,
}
impl<'a> AiSearchDeleteTokens<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
id: Err("id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::uuid::Uuid>,
{
self.id = value
.try_into()
.map_err(|_| "conversion to `:: uuid :: Uuid` for id failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let id = id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai-search/tokens/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.delete(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "ai_search_delete_tokens",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}