use super::types;
use crate::{
ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt,
ResponseValue, encode_path,
};
#[derive(Debug, Clone)]
pub struct VectorizeDeprecatedGetVectorizeIndex<'a> {
client: &'a crate::Client,
account_id: Result<types::VectorizeIdentifier, String>,
index_name: Result<types::VectorizeIndexName, String>,
}
impl<'a> VectorizeDeprecatedGetVectorizeIndex<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
index_name: Err("index_name was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `VectorizeIdentifier` for account_id failed".to_string()
});
self
}
pub fn index_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeIndexName>,
{
self.index_name = value.try_into().map_err(|_| {
"conversion to `VectorizeIndexName` for index_name 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,
index_name,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let index_name = index_name.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/vectorize/indexes/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&index_name.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: "vectorize_deprecated_get_vectorize_index",
};
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 VectorizeDeprecatedUpdateVectorizeIndex<'a> {
client: &'a crate::Client,
account_id: Result<types::VectorizeIdentifier, String>,
index_name: Result<types::VectorizeIndexName, String>,
body: Result<types::builder::VectorizeUpdateIndexRequest, String>,
}
impl<'a> VectorizeDeprecatedUpdateVectorizeIndex<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
index_name: Err("index_name 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<types::VectorizeIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `VectorizeIdentifier` for account_id failed".to_string()
});
self
}
pub fn index_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeIndexName>,
{
self.index_name = value.try_into().map_err(|_| {
"conversion to `VectorizeIndexName` for index_name failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeUpdateIndexRequest>,
<V as std::convert::TryInto<types::VectorizeUpdateIndexRequest>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `VectorizeUpdateIndexRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::VectorizeUpdateIndexRequest,
) -> types::builder::VectorizeUpdateIndexRequest,
{
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,
index_name,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let index_name = index_name.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::VectorizeUpdateIndexRequest::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/vectorize/indexes/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&index_name.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: "vectorize_deprecated_update_vectorize_index",
};
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 VectorizeDeprecatedDeleteVectorizeIndex<'a> {
client: &'a crate::Client,
account_id: Result<types::VectorizeIdentifier, String>,
index_name: Result<types::VectorizeIndexName, String>,
}
impl<'a> VectorizeDeprecatedDeleteVectorizeIndex<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
index_name: Err("index_name was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `VectorizeIdentifier` for account_id failed".to_string()
});
self
}
pub fn index_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeIndexName>,
{
self.index_name = value.try_into().map_err(|_| {
"conversion to `VectorizeIndexName` for index_name 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,
index_name,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let index_name = index_name.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/vectorize/indexes/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&index_name.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: "vectorize_deprecated_delete_vectorize_index",
};
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 VectorizeDeprecatedDeleteVectorsById<'a> {
client: &'a crate::Client,
account_id: Result<types::VectorizeIdentifier, String>,
index_name: Result<types::VectorizeIndexName, String>,
body: Result<types::builder::VectorizeIndexDeleteVectorsByIdRequest, String>,
}
impl<'a> VectorizeDeprecatedDeleteVectorsById<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
index_name: Err("index_name 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<types::VectorizeIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `VectorizeIdentifier` for account_id failed".to_string()
});
self
}
pub fn index_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeIndexName>,
{
self.index_name = value.try_into().map_err(|_| {
"conversion to `VectorizeIndexName` for index_name failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeIndexDeleteVectorsByIdRequest>,
<V as std::convert::TryInto<types::VectorizeIndexDeleteVectorsByIdRequest>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `VectorizeIndexDeleteVectorsByIdRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::VectorizeIndexDeleteVectorsByIdRequest,
)
-> types::builder::VectorizeIndexDeleteVectorsByIdRequest,
{
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,
index_name,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let index_name = index_name.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::VectorizeIndexDeleteVectorsByIdRequest::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/vectorize/indexes/{}/delete-by-ids",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&index_name.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: "vectorize_deprecated_delete_vectors_by_id",
};
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 VectorizeDeprecatedGetVectorsById<'a> {
client: &'a crate::Client,
account_id: Result<types::VectorizeIdentifier, String>,
index_name: Result<types::VectorizeIndexName, String>,
body: Result<types::builder::VectorizeIndexGetVectorsByIdRequest, String>,
}
impl<'a> VectorizeDeprecatedGetVectorsById<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
index_name: Err("index_name 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<types::VectorizeIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `VectorizeIdentifier` for account_id failed".to_string()
});
self
}
pub fn index_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeIndexName>,
{
self.index_name = value.try_into().map_err(|_| {
"conversion to `VectorizeIndexName` for index_name failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeIndexGetVectorsByIdRequest>,
<V as std::convert::TryInto<types::VectorizeIndexGetVectorsByIdRequest>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `VectorizeIndexGetVectorsByIdRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::VectorizeIndexGetVectorsByIdRequest,
) -> types::builder::VectorizeIndexGetVectorsByIdRequest,
{
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,
index_name,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let index_name = index_name.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::VectorizeIndexGetVectorsByIdRequest::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/vectorize/indexes/{}/get-by-ids",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&index_name.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: "vectorize_deprecated_get_vectors_by_id",
};
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 VectorizeDeprecatedInsertVector<'a> {
client: &'a crate::Client,
account_id: Result<types::VectorizeIdentifier, String>,
index_name: Result<types::VectorizeIndexName, String>,
body: Result<::std::string::String, String>,
}
impl<'a> VectorizeDeprecatedInsertVector<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
index_name: Err("index_name was not initialized".to_string()),
body: Err("body was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `VectorizeIdentifier` for account_id failed".to_string()
});
self
}
pub fn index_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeIndexName>,
{
self.index_name = value.try_into().map_err(|_| {
"conversion to `VectorizeIndexName` for index_name failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.body = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for body 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,
index_name,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let index_name = index_name.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/vectorize/indexes/{}/insert",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&index_name.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: "vectorize_deprecated_insert_vector",
};
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 VectorizeDeprecatedQueryVector<'a> {
client: &'a crate::Client,
account_id: Result<types::VectorizeIdentifier, String>,
index_name: Result<types::VectorizeIndexName, String>,
body: Result<types::builder::VectorizeIndexQueryRequest, String>,
}
impl<'a> VectorizeDeprecatedQueryVector<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
index_name: Err("index_name 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<types::VectorizeIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `VectorizeIdentifier` for account_id failed".to_string()
});
self
}
pub fn index_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeIndexName>,
{
self.index_name = value.try_into().map_err(|_| {
"conversion to `VectorizeIndexName` for index_name failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeIndexQueryRequest>,
<V as std::convert::TryInto<types::VectorizeIndexQueryRequest>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `VectorizeIndexQueryRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::VectorizeIndexQueryRequest,
) -> types::builder::VectorizeIndexQueryRequest,
{
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,
index_name,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let index_name = index_name.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::VectorizeIndexQueryRequest::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/vectorize/indexes/{}/query",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&index_name.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: "vectorize_deprecated_query_vector",
};
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 VectorizeDeprecatedUpsertVector<'a> {
client: &'a crate::Client,
account_id: Result<types::VectorizeIdentifier, String>,
index_name: Result<types::VectorizeIndexName, String>,
body: Result<::std::string::String, String>,
}
impl<'a> VectorizeDeprecatedUpsertVector<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
index_name: Err("index_name was not initialized".to_string()),
body: Err("body was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `VectorizeIdentifier` for account_id failed".to_string()
});
self
}
pub fn index_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeIndexName>,
{
self.index_name = value.try_into().map_err(|_| {
"conversion to `VectorizeIndexName` for index_name failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.body = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for body 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,
index_name,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let index_name = index_name.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/vectorize/indexes/{}/upsert",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&index_name.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: "vectorize_deprecated_upsert_vector",
};
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 VectorizeListVectorizeIndexes<'a> {
client: &'a crate::Client,
account_id: Result<types::VectorizeIdentifier, String>,
}
impl<'a> VectorizeListVectorizeIndexes<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `VectorizeIdentifier` for account_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 } = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/vectorize/v2/indexes",
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"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "vectorize_list_vectorize_indexes",
};
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 VectorizeCreateVectorizeIndex<'a> {
client: &'a crate::Client,
account_id: Result<types::VectorizeIdentifier, String>,
body: Result<types::builder::VectorizeCreateIndexRequest, String>,
}
impl<'a> VectorizeCreateVectorizeIndex<'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<types::VectorizeIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `VectorizeIdentifier` for account_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeCreateIndexRequest>,
<V as std::convert::TryInto<types::VectorizeCreateIndexRequest>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `VectorizeCreateIndexRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::VectorizeCreateIndexRequest,
) -> types::builder::VectorizeCreateIndexRequest,
{
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::VectorizeCreateIndexRequest::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/vectorize/v2/indexes",
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: "vectorize_create_vectorize_index",
};
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 VectorizeGetVectorizeIndex<'a> {
client: &'a crate::Client,
account_id: Result<types::VectorizeIdentifier, String>,
index_name: Result<types::VectorizeIndexName, String>,
}
impl<'a> VectorizeGetVectorizeIndex<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
index_name: Err("index_name was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `VectorizeIdentifier` for account_id failed".to_string()
});
self
}
pub fn index_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeIndexName>,
{
self.index_name = value.try_into().map_err(|_| {
"conversion to `VectorizeIndexName` for index_name 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,
index_name,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let index_name = index_name.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/vectorize/v2/indexes/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&index_name.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: "vectorize_get_vectorize_index",
};
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 VectorizeDeleteVectorizeIndex<'a> {
client: &'a crate::Client,
account_id: Result<types::VectorizeIdentifier, String>,
index_name: Result<types::VectorizeIndexName, String>,
}
impl<'a> VectorizeDeleteVectorizeIndex<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
index_name: Err("index_name was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `VectorizeIdentifier` for account_id failed".to_string()
});
self
}
pub fn index_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeIndexName>,
{
self.index_name = value.try_into().map_err(|_| {
"conversion to `VectorizeIndexName` for index_name 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,
index_name,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let index_name = index_name.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/vectorize/v2/indexes/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&index_name.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: "vectorize_delete_vectorize_index",
};
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 VectorizeDeleteVectorsById<'a> {
client: &'a crate::Client,
account_id: Result<types::VectorizeIdentifier, String>,
index_name: Result<types::VectorizeIndexName, String>,
body: Result<types::builder::VectorizeIndexDeleteVectorsByIdRequest, String>,
}
impl<'a> VectorizeDeleteVectorsById<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
index_name: Err("index_name 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<types::VectorizeIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `VectorizeIdentifier` for account_id failed".to_string()
});
self
}
pub fn index_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeIndexName>,
{
self.index_name = value.try_into().map_err(|_| {
"conversion to `VectorizeIndexName` for index_name failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeIndexDeleteVectorsByIdRequest>,
<V as std::convert::TryInto<types::VectorizeIndexDeleteVectorsByIdRequest>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `VectorizeIndexDeleteVectorsByIdRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::VectorizeIndexDeleteVectorsByIdRequest,
)
-> types::builder::VectorizeIndexDeleteVectorsByIdRequest,
{
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,
index_name,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let index_name = index_name.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::VectorizeIndexDeleteVectorsByIdRequest::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/vectorize/v2/indexes/{}/delete_by_ids",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&index_name.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: "vectorize_delete_vectors_by_id",
};
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 VectorizeGetVectorsById<'a> {
client: &'a crate::Client,
account_id: Result<types::VectorizeIdentifier, String>,
index_name: Result<types::VectorizeIndexName, String>,
body: Result<types::builder::VectorizeIndexGetVectorsByIdRequest, String>,
}
impl<'a> VectorizeGetVectorsById<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
index_name: Err("index_name 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<types::VectorizeIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `VectorizeIdentifier` for account_id failed".to_string()
});
self
}
pub fn index_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeIndexName>,
{
self.index_name = value.try_into().map_err(|_| {
"conversion to `VectorizeIndexName` for index_name failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeIndexGetVectorsByIdRequest>,
<V as std::convert::TryInto<types::VectorizeIndexGetVectorsByIdRequest>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `VectorizeIndexGetVectorsByIdRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::VectorizeIndexGetVectorsByIdRequest,
) -> types::builder::VectorizeIndexGetVectorsByIdRequest,
{
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,
index_name,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let index_name = index_name.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::VectorizeIndexGetVectorsByIdRequest::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/vectorize/v2/indexes/{}/get_by_ids",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&index_name.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: "vectorize_get_vectors_by_id",
};
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 VectorizeIndexInfo<'a> {
client: &'a crate::Client,
account_id: Result<types::VectorizeIdentifier, String>,
index_name: Result<types::VectorizeIndexName, String>,
}
impl<'a> VectorizeIndexInfo<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
index_name: Err("index_name was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `VectorizeIdentifier` for account_id failed".to_string()
});
self
}
pub fn index_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeIndexName>,
{
self.index_name = value.try_into().map_err(|_| {
"conversion to `VectorizeIndexName` for index_name 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,
index_name,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let index_name = index_name.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/vectorize/v2/indexes/{}/info",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&index_name.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: "vectorize_index_info",
};
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 VectorizeInsertVector<'a> {
client: &'a crate::Client,
account_id: Result<types::VectorizeIdentifier, String>,
index_name: Result<types::VectorizeIndexName, String>,
unparsable_behavior: Result<types::VectorizeInsertVectorUnparsableBehavior, String>,
body: Result<::std::string::String, String>,
}
impl<'a> VectorizeInsertVector<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
index_name: Err("index_name was not initialized".to_string()),
unparsable_behavior: Err("unparsable_behavior was not initialized".to_string()),
body: Err("body was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `VectorizeIdentifier` for account_id failed".to_string()
});
self
}
pub fn index_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeIndexName>,
{
self.index_name = value.try_into().map_err(|_| {
"conversion to `VectorizeIndexName` for index_name failed".to_string()
});
self
}
pub fn unparsable_behavior<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeInsertVectorUnparsableBehavior>,
{
self . unparsable_behavior = value . try_into () . map_err (| _ | "conversion to `VectorizeInsertVectorUnparsableBehavior` for unparsable_behavior failed" . to_string ()) ;
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.body = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for body 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,
index_name,
unparsable_behavior,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let index_name = index_name.map_err(Error::InvalidRequest)?;
let unparsable_behavior = unparsable_behavior.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/vectorize/v2/indexes/{}/insert",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&index_name.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)
.query(&progenitor_client::QueryParam::new(
"unparsable-behavior",
&unparsable_behavior,
))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "vectorize_insert_vector",
};
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 VectorizeListVectors<'a> {
client: &'a crate::Client,
account_id: Result<types::VectorizeIdentifier, String>,
index_name: Result<types::VectorizeIndexName, String>,
count: Result<::std::num::NonZeroU64, String>,
cursor: Result<::std::string::String, String>,
}
impl<'a> VectorizeListVectors<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
index_name: Err("index_name was not initialized".to_string()),
count: Err("count was not initialized".to_string()),
cursor: Err("cursor was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `VectorizeIdentifier` for account_id failed".to_string()
});
self
}
pub fn index_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeIndexName>,
{
self.index_name = value.try_into().map_err(|_| {
"conversion to `VectorizeIndexName` for index_name failed".to_string()
});
self
}
pub fn count<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::num::NonZeroU64>,
{
self.count = value.try_into().map_err(|_| {
"conversion to `:: std :: num :: NonZeroU64` for count failed".to_string()
});
self
}
pub fn cursor<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.cursor = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for cursor 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,
index_name,
count,
cursor,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let index_name = index_name.map_err(Error::InvalidRequest)?;
let count = count.map_err(Error::InvalidRequest)?;
let cursor = cursor.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/vectorize/v2/indexes/{}/list",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&index_name.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("count", &count))
.query(&progenitor_client::QueryParam::new("cursor", &cursor))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "vectorize_list_vectors",
};
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 VectorizeCreateMetadataIndex<'a> {
client: &'a crate::Client,
account_id: Result<types::VectorizeIdentifier, String>,
index_name: Result<types::VectorizeIndexName, String>,
body: Result<types::builder::VectorizeCreateMetadataIndexRequest, String>,
}
impl<'a> VectorizeCreateMetadataIndex<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
index_name: Err("index_name 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<types::VectorizeIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `VectorizeIdentifier` for account_id failed".to_string()
});
self
}
pub fn index_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeIndexName>,
{
self.index_name = value.try_into().map_err(|_| {
"conversion to `VectorizeIndexName` for index_name failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeCreateMetadataIndexRequest>,
<V as std::convert::TryInto<types::VectorizeCreateMetadataIndexRequest>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `VectorizeCreateMetadataIndexRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::VectorizeCreateMetadataIndexRequest,
) -> types::builder::VectorizeCreateMetadataIndexRequest,
{
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,
index_name,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let index_name = index_name.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::VectorizeCreateMetadataIndexRequest::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/vectorize/v2/indexes/{}/metadata_index/create",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&index_name.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: "vectorize_create_metadata_index",
};
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 VectorizeDeleteMetadataIndex<'a> {
client: &'a crate::Client,
account_id: Result<types::VectorizeIdentifier, String>,
index_name: Result<types::VectorizeIndexName, String>,
body: Result<types::builder::VectorizeDeleteMetadataIndexRequest, String>,
}
impl<'a> VectorizeDeleteMetadataIndex<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
index_name: Err("index_name 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<types::VectorizeIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `VectorizeIdentifier` for account_id failed".to_string()
});
self
}
pub fn index_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeIndexName>,
{
self.index_name = value.try_into().map_err(|_| {
"conversion to `VectorizeIndexName` for index_name failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeDeleteMetadataIndexRequest>,
<V as std::convert::TryInto<types::VectorizeDeleteMetadataIndexRequest>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `VectorizeDeleteMetadataIndexRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::VectorizeDeleteMetadataIndexRequest,
) -> types::builder::VectorizeDeleteMetadataIndexRequest,
{
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,
index_name,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let index_name = index_name.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::VectorizeDeleteMetadataIndexRequest::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/vectorize/v2/indexes/{}/metadata_index/delete",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&index_name.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: "vectorize_delete_metadata_index",
};
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 VectorizeListMetadataIndexes<'a> {
client: &'a crate::Client,
account_id: Result<types::VectorizeIdentifier, String>,
index_name: Result<types::VectorizeIndexName, String>,
}
impl<'a> VectorizeListMetadataIndexes<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
index_name: Err("index_name was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `VectorizeIdentifier` for account_id failed".to_string()
});
self
}
pub fn index_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeIndexName>,
{
self.index_name = value.try_into().map_err(|_| {
"conversion to `VectorizeIndexName` for index_name 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,
index_name,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let index_name = index_name.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/vectorize/v2/indexes/{}/metadata_index/list",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&index_name.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: "vectorize_list_metadata_indexes",
};
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 VectorizeQueryVector<'a> {
client: &'a crate::Client,
account_id: Result<types::VectorizeIdentifier, String>,
index_name: Result<types::VectorizeIndexName, String>,
body: Result<types::builder::VectorizeIndexQueryV2Request, String>,
}
impl<'a> VectorizeQueryVector<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
index_name: Err("index_name 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<types::VectorizeIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `VectorizeIdentifier` for account_id failed".to_string()
});
self
}
pub fn index_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeIndexName>,
{
self.index_name = value.try_into().map_err(|_| {
"conversion to `VectorizeIndexName` for index_name failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeIndexQueryV2Request>,
<V as std::convert::TryInto<types::VectorizeIndexQueryV2Request>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `VectorizeIndexQueryV2Request` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::VectorizeIndexQueryV2Request,
) -> types::builder::VectorizeIndexQueryV2Request,
{
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,
index_name,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let index_name = index_name.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::VectorizeIndexQueryV2Request::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/vectorize/v2/indexes/{}/query",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&index_name.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: "vectorize_query_vector",
};
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 VectorizeUpsertVector<'a> {
client: &'a crate::Client,
account_id: Result<types::VectorizeIdentifier, String>,
index_name: Result<types::VectorizeIndexName, String>,
unparsable_behavior: Result<types::VectorizeUpsertVectorUnparsableBehavior, String>,
body: Result<::std::string::String, String>,
}
impl<'a> VectorizeUpsertVector<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
index_name: Err("index_name was not initialized".to_string()),
unparsable_behavior: Err("unparsable_behavior was not initialized".to_string()),
body: Err("body was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `VectorizeIdentifier` for account_id failed".to_string()
});
self
}
pub fn index_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeIndexName>,
{
self.index_name = value.try_into().map_err(|_| {
"conversion to `VectorizeIndexName` for index_name failed".to_string()
});
self
}
pub fn unparsable_behavior<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::VectorizeUpsertVectorUnparsableBehavior>,
{
self . unparsable_behavior = value . try_into () . map_err (| _ | "conversion to `VectorizeUpsertVectorUnparsableBehavior` for unparsable_behavior failed" . to_string ()) ;
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.body = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for body 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,
index_name,
unparsable_behavior,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let index_name = index_name.map_err(Error::InvalidRequest)?;
let unparsable_behavior = unparsable_behavior.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/vectorize/v2/indexes/{}/upsert",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&index_name.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)
.query(&progenitor_client::QueryParam::new(
"unparsable-behavior",
&unparsable_behavior,
))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "vectorize_upsert_vector",
};
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)),
}
}
}