use super::types;
use crate::{
ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt,
ResponseValue, encode_path,
};
#[derive(Debug, Clone)]
pub struct WorkersAiUploadFinetuneAsset<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
finetune_id: Result<::std::string::String, String>,
body: Result<types::builder::WorkersAiUploadFinetuneAssetBody, String>,
}
impl<'a> WorkersAiUploadFinetuneAsset<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
finetune_id: Err("finetune_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 finetune_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.finetune_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for finetune_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAiUploadFinetuneAssetBody>,
<V as std::convert::TryInto<types::WorkersAiUploadFinetuneAssetBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `WorkersAiUploadFinetuneAssetBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::WorkersAiUploadFinetuneAssetBody,
) -> types::builder::WorkersAiUploadFinetuneAssetBody,
{
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,
finetune_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let finetune_id = finetune_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::WorkersAiUploadFinetuneAssetBody::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/finetunes/{}/finetune-assets",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&finetune_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: "workers_ai_upload_finetune_asset",
};
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 WorkersAiListPublicFinetunes<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
limit: Result<f64, String>,
offset: Result<f64, String>,
order_by: Result<::std::string::String, String>,
}
impl<'a> WorkersAiListPublicFinetunes<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
limit: Err("limit was not initialized".to_string()),
offset: Err("offset was not initialized".to_string()),
order_by: Err("order_by 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 limit<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<f64>,
{
self.limit = value
.try_into()
.map_err(|_| "conversion to `f64` for limit failed".to_string());
self
}
pub fn offset<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<f64>,
{
self.offset = value
.try_into()
.map_err(|_| "conversion to `f64` for offset failed".to_string());
self
}
pub fn order_by<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.order_by = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for order_by 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,
limit,
offset,
order_by,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let limit = limit.map_err(Error::InvalidRequest)?;
let offset = offset.map_err(Error::InvalidRequest)?;
let order_by = order_by.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/finetunes/public",
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("limit", &limit))
.query(&progenitor_client::QueryParam::new("offset", &offset))
.query(&progenitor_client::QueryParam::new("orderBy", &order_by))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_list_public_finetunes",
};
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 WorkersAiPostRunCfBaaiBgeBaseEnV15<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<types::WorkersAiPostRunCfBaaiBgeBaseEnV15Body, String>,
}
impl<'a> WorkersAiPostRunCfBaaiBgeBaseEnV15<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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<::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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAiPostRunCfBaaiBgeBaseEnV15Body>,
{
self.body = value.try_into().map_err(|_| {
"conversion to `WorkersAiPostRunCfBaaiBgeBaseEnV15Body` 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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/baai/bge-base-en-v1.5",
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)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_cf_baai_bge_base_en_v1_5",
};
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 WorkersAiPostRunCfBaaiBgeLargeEnV15<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<types::WorkersAiPostRunCfBaaiBgeLargeEnV15Body, String>,
}
impl<'a> WorkersAiPostRunCfBaaiBgeLargeEnV15<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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<::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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAiPostRunCfBaaiBgeLargeEnV15Body>,
{
self.body = value.try_into().map_err(|_| {
"conversion to `WorkersAiPostRunCfBaaiBgeLargeEnV15Body` 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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/baai/bge-large-en-v1.5",
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)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_cf_baai_bge_large_en_v1_5",
};
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 WorkersAiPostRunCfBaaiBgeM3<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<types::WorkersAiPostRunCfBaaiBgeM3Body, String>,
}
impl<'a> WorkersAiPostRunCfBaaiBgeM3<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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<::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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAiPostRunCfBaaiBgeM3Body>,
{
self.body = value.try_into().map_err(|_| {
"conversion to `WorkersAiPostRunCfBaaiBgeM3Body` 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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/baai/bge-m3",
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)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_cf_baai_bge_m3",
};
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 WorkersAiPostRunCfBaaiBgeRerankerBase<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<types::builder::WorkersAiPostRunCfBaaiBgeRerankerBaseBody, String>,
}
impl<'a> WorkersAiPostRunCfBaaiBgeRerankerBase<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAiPostRunCfBaaiBgeRerankerBaseBody>,
<V as std::convert::TryInto<types::WorkersAiPostRunCfBaaiBgeRerankerBaseBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `WorkersAiPostRunCfBaaiBgeRerankerBaseBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::WorkersAiPostRunCfBaaiBgeRerankerBaseBody,
)
-> types::builder::WorkersAiPostRunCfBaaiBgeRerankerBaseBody,
{
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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::WorkersAiPostRunCfBaaiBgeRerankerBaseBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/baai/bge-reranker-base",
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)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_cf_baai_bge_reranker_base",
};
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 WorkersAiPostRunCfBaaiBgeSmallEnV15<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<types::WorkersAiPostRunCfBaaiBgeSmallEnV15Body, String>,
}
impl<'a> WorkersAiPostRunCfBaaiBgeSmallEnV15<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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<::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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAiPostRunCfBaaiBgeSmallEnV15Body>,
{
self.body = value.try_into().map_err(|_| {
"conversion to `WorkersAiPostRunCfBaaiBgeSmallEnV15Body` 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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/baai/bge-small-en-v1.5",
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)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_cf_baai_bge_small_en_v1_5",
};
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 WorkersAiPostRunCfBaaiOmniBgeM3<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<types::WorkersAiPostRunCfBaaiOmniBgeM3Body, String>,
}
impl<'a> WorkersAiPostRunCfBaaiOmniBgeM3<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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<::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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAiPostRunCfBaaiOmniBgeM3Body>,
{
self.body = value.try_into().map_err(|_| {
"conversion to `WorkersAiPostRunCfBaaiOmniBgeM3Body` 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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/baai/omni-bge-m3",
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)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_cf_baai_omni_bge_m3",
};
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 WorkersAiPostWebsocketRunCfDeepgramAura<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
}
impl<'a> WorkersAiPostWebsocketRunCfDeepgramAura<'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<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub async fn send(self) -> Result<ResponseValue<()>, Error<()>> {
let Self { client, account_id } = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/deepgram/aura",
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).headers(header_map).build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_websocket_run_cf_deepgram_aura",
};
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() {
101u16 => Ok(ResponseValue::empty(response)),
200u16 => Ok(ResponseValue::empty(response)),
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct WorkersAiPostWebsocketRunCfDeepgramAura1<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
}
impl<'a> WorkersAiPostWebsocketRunCfDeepgramAura1<'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<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub async fn send(self) -> Result<ResponseValue<()>, Error<()>> {
let Self { client, account_id } = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/deepgram/aura-1",
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).headers(header_map).build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_websocket_run_cf_deepgram_aura_1",
};
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() {
101u16 => Ok(ResponseValue::empty(response)),
200u16 => Ok(ResponseValue::empty(response)),
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct WorkersAiPostRunCfDeepgramAura1<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<types::builder::WorkersAiPostRunCfDeepgramAura1Body, String>,
}
impl<'a> WorkersAiPostRunCfDeepgramAura1<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAiPostRunCfDeepgramAura1Body>,
<V as std::convert::TryInto<types::WorkersAiPostRunCfDeepgramAura1Body>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `WorkersAiPostRunCfDeepgramAura1Body` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::WorkersAiPostRunCfDeepgramAura1Body,
) -> types::builder::WorkersAiPostRunCfDeepgramAura1Body,
{
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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::WorkersAiPostRunCfDeepgramAura1Body::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/deepgram/aura-1",
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)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_cf_deepgram_aura_1",
};
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 WorkersAiPostWebsocketRunCfDeepgramAura2<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
}
impl<'a> WorkersAiPostWebsocketRunCfDeepgramAura2<'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<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub async fn send(self) -> Result<ResponseValue<()>, Error<()>> {
let Self { client, account_id } = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/deepgram/aura-2",
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).headers(header_map).build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_websocket_run_cf_deepgram_aura_2",
};
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() {
101u16 => Ok(ResponseValue::empty(response)),
200u16 => Ok(ResponseValue::empty(response)),
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct WorkersAiPostRunCfDeepgramAura2En<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<types::builder::WorkersAiPostRunCfDeepgramAura2EnBody, String>,
}
impl<'a> WorkersAiPostRunCfDeepgramAura2En<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAiPostRunCfDeepgramAura2EnBody>,
<V as std::convert::TryInto<types::WorkersAiPostRunCfDeepgramAura2EnBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `WorkersAiPostRunCfDeepgramAura2EnBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::WorkersAiPostRunCfDeepgramAura2EnBody,
)
-> types::builder::WorkersAiPostRunCfDeepgramAura2EnBody,
{
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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::WorkersAiPostRunCfDeepgramAura2EnBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/deepgram/aura-2-en",
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)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_cf_deepgram_aura_2_en",
};
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 WorkersAiPostRunCfDeepgramAura2Es<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<types::builder::WorkersAiPostRunCfDeepgramAura2EsBody, String>,
}
impl<'a> WorkersAiPostRunCfDeepgramAura2Es<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAiPostRunCfDeepgramAura2EsBody>,
<V as std::convert::TryInto<types::WorkersAiPostRunCfDeepgramAura2EsBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `WorkersAiPostRunCfDeepgramAura2EsBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::WorkersAiPostRunCfDeepgramAura2EsBody,
)
-> types::builder::WorkersAiPostRunCfDeepgramAura2EsBody,
{
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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::WorkersAiPostRunCfDeepgramAura2EsBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/deepgram/aura-2-es",
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)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_cf_deepgram_aura_2_es",
};
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 WorkersAiPostWebsocketRunCfDeepgramFlux<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
}
impl<'a> WorkersAiPostWebsocketRunCfDeepgramFlux<'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<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub async fn send(self) -> Result<ResponseValue<()>, Error<()>> {
let Self { client, account_id } = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/deepgram/flux",
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).headers(header_map).build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_websocket_run_cf_deepgram_flux",
};
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() {
101u16 => Ok(ResponseValue::empty(response)),
200u16 => Ok(ResponseValue::empty(response)),
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct WorkersAiPostRunCfDeepgramFlux<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<types::builder::WorkersAiPostRunCfDeepgramFluxBody, String>,
}
impl<'a> WorkersAiPostRunCfDeepgramFlux<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAiPostRunCfDeepgramFluxBody>,
<V as std::convert::TryInto<types::WorkersAiPostRunCfDeepgramFluxBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `WorkersAiPostRunCfDeepgramFluxBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::WorkersAiPostRunCfDeepgramFluxBody,
) -> types::builder::WorkersAiPostRunCfDeepgramFluxBody,
{
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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::WorkersAiPostRunCfDeepgramFluxBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/deepgram/flux",
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)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_cf_deepgram_flux",
};
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 WorkersAiPostWebsocketRunCfDeepgramNova3<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
}
impl<'a> WorkersAiPostWebsocketRunCfDeepgramNova3<'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<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub async fn send(self) -> Result<ResponseValue<()>, Error<()>> {
let Self { client, account_id } = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/deepgram/nova-3",
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).headers(header_map).build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_websocket_run_cf_deepgram_nova_3",
};
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() {
101u16 => Ok(ResponseValue::empty(response)),
200u16 => Ok(ResponseValue::empty(response)),
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct WorkersAiPostRunCfDeepgramNova3<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<types::builder::WorkersAiPostRunCfDeepgramNova3Body, String>,
}
impl<'a> WorkersAiPostRunCfDeepgramNova3<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAiPostRunCfDeepgramNova3Body>,
<V as std::convert::TryInto<types::WorkersAiPostRunCfDeepgramNova3Body>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `WorkersAiPostRunCfDeepgramNova3Body` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::WorkersAiPostRunCfDeepgramNova3Body,
) -> types::builder::WorkersAiPostRunCfDeepgramNova3Body,
{
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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::WorkersAiPostRunCfDeepgramNova3Body::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/deepgram/nova-3",
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)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_cf_deepgram_nova_3",
};
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 WorkersAiPostRunCfDefogSqlcoder7b2<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<types::WorkersAiPostRunCfDefogSqlcoder7b2Body, String>,
}
impl<'a> WorkersAiPostRunCfDefogSqlcoder7b2<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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<::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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAiPostRunCfDefogSqlcoder7b2Body>,
{
self.body = value.try_into().map_err(|_| {
"conversion to `WorkersAiPostRunCfDefogSqlcoder7b2Body` 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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/defog/sqlcoder-7b-2",
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)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_cf_defog_sqlcoder_7b_2",
};
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 WorkersAiPostRunCfFacebookBartLargeCnn<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<types::builder::WorkersAiPostRunCfFacebookBartLargeCnnBody, String>,
}
impl<'a> WorkersAiPostRunCfFacebookBartLargeCnn<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAiPostRunCfFacebookBartLargeCnnBody>,
<V as std::convert::TryInto<types::WorkersAiPostRunCfFacebookBartLargeCnnBody>>::Error:
std::fmt::Display,
{
self . body = value . try_into () . map (From :: from) . map_err (| s | format ! ("conversion to `WorkersAiPostRunCfFacebookBartLargeCnnBody` for body failed: {}" , s)) ;
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::WorkersAiPostRunCfFacebookBartLargeCnnBody,
)
-> types::builder::WorkersAiPostRunCfFacebookBartLargeCnnBody,
{
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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::WorkersAiPostRunCfFacebookBartLargeCnnBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/facebook/bart-large-cnn",
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)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_cf_facebook_bart_large_cnn",
};
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 WorkersAiPostRunCfGoogleGemma2bItLora<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<types::WorkersAiPostRunCfGoogleGemma2bItLoraBody, String>,
}
impl<'a> WorkersAiPostRunCfGoogleGemma2bItLora<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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<::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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAiPostRunCfGoogleGemma2bItLoraBody>,
{
self.body = value.try_into().map_err(|_| {
"conversion to `WorkersAiPostRunCfGoogleGemma2bItLoraBody` 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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/google/gemma-2b-it-lora",
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)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_cf_google_gemma_2b_it_lora",
};
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 WorkersAiPostRunCfGoogleGemma312bIt<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<types::WorkersAiPostRunCfGoogleGemma312bItBody, String>,
}
impl<'a> WorkersAiPostRunCfGoogleGemma312bIt<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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<::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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAiPostRunCfGoogleGemma312bItBody>,
{
self.body = value.try_into().map_err(|_| {
"conversion to `WorkersAiPostRunCfGoogleGemma312bItBody` 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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/google/gemma-3-12b-it",
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)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_cf_google_gemma_3_12b_it",
};
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 WorkersAiPostRunCfGoogleGemma7bItLora<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<types::WorkersAiPostRunCfGoogleGemma7bItLoraBody, String>,
}
impl<'a> WorkersAiPostRunCfGoogleGemma7bItLora<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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<::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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAiPostRunCfGoogleGemma7bItLoraBody>,
{
self.body = value.try_into().map_err(|_| {
"conversion to `WorkersAiPostRunCfGoogleGemma7bItLoraBody` 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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/google/gemma-7b-it-lora",
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)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_cf_google_gemma_7b_it_lora",
};
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 WorkersAiPostRunCfLeonardoLucidOrigin<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<types::builder::WorkersAiPostRunCfLeonardoLucidOriginBody, String>,
}
impl<'a> WorkersAiPostRunCfLeonardoLucidOrigin<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAiPostRunCfLeonardoLucidOriginBody>,
<V as std::convert::TryInto<types::WorkersAiPostRunCfLeonardoLucidOriginBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `WorkersAiPostRunCfLeonardoLucidOriginBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::WorkersAiPostRunCfLeonardoLucidOriginBody,
)
-> types::builder::WorkersAiPostRunCfLeonardoLucidOriginBody,
{
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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::WorkersAiPostRunCfLeonardoLucidOriginBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/leonardo/lucid-origin",
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)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_cf_leonardo_lucid_origin",
};
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 WorkersAiPostRunCfLeonardoPhoenix10<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<types::builder::WorkersAiPostRunCfLeonardoPhoenix10Body, String>,
}
impl<'a> WorkersAiPostRunCfLeonardoPhoenix10<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAiPostRunCfLeonardoPhoenix10Body>,
<V as std::convert::TryInto<types::WorkersAiPostRunCfLeonardoPhoenix10Body>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `WorkersAiPostRunCfLeonardoPhoenix10Body` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::WorkersAiPostRunCfLeonardoPhoenix10Body,
)
-> types::builder::WorkersAiPostRunCfLeonardoPhoenix10Body,
{
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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::WorkersAiPostRunCfLeonardoPhoenix10Body::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/leonardo/phoenix-1.0",
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)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_cf_leonardo_phoenix_1_0",
};
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 WorkersAiPostRunCfLykonDreamshaper8Lcm<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<types::builder::WorkersAiPostRunCfLykonDreamshaper8LcmBody, String>,
}
impl<'a> WorkersAiPostRunCfLykonDreamshaper8Lcm<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAiPostRunCfLykonDreamshaper8LcmBody>,
<V as std::convert::TryInto<types::WorkersAiPostRunCfLykonDreamshaper8LcmBody>>::Error:
std::fmt::Display,
{
self . body = value . try_into () . map (From :: from) . map_err (| s | format ! ("conversion to `WorkersAiPostRunCfLykonDreamshaper8LcmBody` for body failed: {}" , s)) ;
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::WorkersAiPostRunCfLykonDreamshaper8LcmBody,
)
-> types::builder::WorkersAiPostRunCfLykonDreamshaper8LcmBody,
{
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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::WorkersAiPostRunCfLykonDreamshaper8LcmBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/lykon/dreamshaper-8-lcm",
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)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_cf_lykon_dreamshaper_8_lcm",
};
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 WorkersAiPostRunCfMetaLlama27bChatFp16<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<types::WorkersAiPostRunCfMetaLlama27bChatFp16Body, String>,
}
impl<'a> WorkersAiPostRunCfMetaLlama27bChatFp16<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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<::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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAiPostRunCfMetaLlama27bChatFp16Body>,
{
self.body = value.try_into().map_err(|_| {
"conversion to `WorkersAiPostRunCfMetaLlama27bChatFp16Body` 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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/meta/llama-2-7b-chat-fp16",
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)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_cf_meta_llama_2_7b_chat_fp16",
};
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 WorkersAiPostRunCfMetaLlama27bChatInt8<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<types::WorkersAiPostRunCfMetaLlama27bChatInt8Body, String>,
}
impl<'a> WorkersAiPostRunCfMetaLlama27bChatInt8<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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<::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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAiPostRunCfMetaLlama27bChatInt8Body>,
{
self.body = value.try_into().map_err(|_| {
"conversion to `WorkersAiPostRunCfMetaLlama27bChatInt8Body` 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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/meta/llama-2-7b-chat-int8",
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)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_cf_meta_llama_2_7b_chat_int8",
};
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 WorkersAiPostRunCfMetaLlama38bInstruct<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<types::WorkersAiPostRunCfMetaLlama38bInstructBody, String>,
}
impl<'a> WorkersAiPostRunCfMetaLlama38bInstruct<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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<::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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAiPostRunCfMetaLlama38bInstructBody>,
{
self.body = value.try_into().map_err(|_| {
"conversion to `WorkersAiPostRunCfMetaLlama38bInstructBody` 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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/meta/llama-3-8b-instruct",
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)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_cf_meta_llama_3_8b_instruct",
};
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 WorkersAiPostRunCfMetaLlamaGuard38b<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<types::builder::WorkersAiPostRunCfMetaLlamaGuard38bBody, String>,
}
impl<'a> WorkersAiPostRunCfMetaLlamaGuard38b<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAiPostRunCfMetaLlamaGuard38bBody>,
<V as std::convert::TryInto<types::WorkersAiPostRunCfMetaLlamaGuard38bBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `WorkersAiPostRunCfMetaLlamaGuard38bBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::WorkersAiPostRunCfMetaLlamaGuard38bBody,
)
-> types::builder::WorkersAiPostRunCfMetaLlamaGuard38bBody,
{
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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::WorkersAiPostRunCfMetaLlamaGuard38bBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/meta/llama-guard-3-8b",
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)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_cf_meta_llama_guard_3_8b",
};
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 WorkersAiPostRunCfMetaM2m10012b<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<types::WorkersAiPostRunCfMetaM2m10012bBody, String>,
}
impl<'a> WorkersAiPostRunCfMetaM2m10012b<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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<::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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAiPostRunCfMetaM2m10012bBody>,
{
self.body = value.try_into().map_err(|_| {
"conversion to `WorkersAiPostRunCfMetaM2m10012bBody` 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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/meta/m2m100-1.2b",
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)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_cf_meta_m2m100_1_2b",
};
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 WorkersAiPostRunCfMicrosoftPhi2<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<types::WorkersAiPostRunCfMicrosoftPhi2Body, String>,
}
impl<'a> WorkersAiPostRunCfMicrosoftPhi2<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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<::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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAiPostRunCfMicrosoftPhi2Body>,
{
self.body = value.try_into().map_err(|_| {
"conversion to `WorkersAiPostRunCfMicrosoftPhi2Body` 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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/microsoft/phi-2",
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)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_cf_microsoft_phi_2",
};
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)]
pub struct WorkersAiPostRunCfMicrosoftResnet50<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<reqwest::Body, String>,
}
impl<'a> WorkersAiPostRunCfMicrosoftResnet50<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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<::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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<B>(mut self, value: B) -> Self
where
B: std::convert::TryInto<reqwest::Body>,
{
self.body = value
.try_into()
.map_err(|_| "conversion to `reqwest::Body` 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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/microsoft/resnet-50",
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"),
)
.header(
::reqwest::header::CONTENT_TYPE,
::reqwest::header::HeaderValue::from_static("application/octet-stream"),
)
.body(body)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_cf_microsoft_resnet_50",
};
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 WorkersAiPostRunCfMyshellAiMelotts<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<types::builder::WorkersAiPostRunCfMyshellAiMelottsBody, String>,
}
impl<'a> WorkersAiPostRunCfMyshellAiMelotts<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAiPostRunCfMyshellAiMelottsBody>,
<V as std::convert::TryInto<types::WorkersAiPostRunCfMyshellAiMelottsBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `WorkersAiPostRunCfMyshellAiMelottsBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::WorkersAiPostRunCfMyshellAiMelottsBody,
)
-> types::builder::WorkersAiPostRunCfMyshellAiMelottsBody,
{
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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::WorkersAiPostRunCfMyshellAiMelottsBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/myshell-ai/melotts",
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)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_cf_myshell_ai_melotts",
};
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 WorkersAiPostRunCfOpenaiGptOss20b<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<types::WorkersAiPostRunCfOpenaiGptOss20bBody, String>,
}
impl<'a> WorkersAiPostRunCfOpenaiGptOss20b<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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<::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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAiPostRunCfOpenaiGptOss20bBody>,
{
self.body = value.try_into().map_err(|_| {
"conversion to `WorkersAiPostRunCfOpenaiGptOss20bBody` 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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/openai/gpt-oss-20b",
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)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_cf_openai_gpt_oss_20b",
};
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 WorkersAiPostRunCfOpenaiGptOss120b<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<types::WorkersAiPostRunCfOpenaiGptOss120bBody, String>,
}
impl<'a> WorkersAiPostRunCfOpenaiGptOss120b<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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<::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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAiPostRunCfOpenaiGptOss120bBody>,
{
self.body = value.try_into().map_err(|_| {
"conversion to `WorkersAiPostRunCfOpenaiGptOss120bBody` 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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/openai/gpt-oss-120b",
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)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_cf_openai_gpt_oss_120b",
};
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)]
pub struct WorkersAiPostRunCfOpenaiWhisper<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<reqwest::Body, String>,
}
impl<'a> WorkersAiPostRunCfOpenaiWhisper<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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<::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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<B>(mut self, value: B) -> Self
where
B: std::convert::TryInto<reqwest::Body>,
{
self.body = value
.try_into()
.map_err(|_| "conversion to `reqwest::Body` 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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/openai/whisper",
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"),
)
.header(
::reqwest::header::CONTENT_TYPE,
::reqwest::header::HeaderValue::from_static("application/octet-stream"),
)
.body(body)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_cf_openai_whisper",
};
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)]
pub struct WorkersAiPostRunCfOpenaiWhisperTinyEn<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<reqwest::Body, String>,
}
impl<'a> WorkersAiPostRunCfOpenaiWhisperTinyEn<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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<::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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<B>(mut self, value: B) -> Self
where
B: std::convert::TryInto<reqwest::Body>,
{
self.body = value
.try_into()
.map_err(|_| "conversion to `reqwest::Body` 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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/openai/whisper-tiny-en",
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"),
)
.header(
::reqwest::header::CONTENT_TYPE,
::reqwest::header::HeaderValue::from_static("application/octet-stream"),
)
.body(body)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_cf_openai_whisper_tiny_en",
};
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 WorkersAiPostRunCfPfnetPlamoEmbedding1b<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<types::builder::WorkersAiPostRunCfPfnetPlamoEmbedding1bBody, String>,
}
impl<'a> WorkersAiPostRunCfPfnetPlamoEmbedding1b<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAiPostRunCfPfnetPlamoEmbedding1bBody>,
<V as std::convert::TryInto<types::WorkersAiPostRunCfPfnetPlamoEmbedding1bBody>>::Error:
std::fmt::Display,
{
self . body = value . try_into () . map (From :: from) . map_err (| s | format ! ("conversion to `WorkersAiPostRunCfPfnetPlamoEmbedding1bBody` for body failed: {}" , s)) ;
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::WorkersAiPostRunCfPfnetPlamoEmbedding1bBody,
)
-> types::builder::WorkersAiPostRunCfPfnetPlamoEmbedding1bBody,
{
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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::WorkersAiPostRunCfPfnetPlamoEmbedding1bBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/pfnet/plamo-embedding-1b",
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)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_cf_pfnet_plamo_embedding_1b",
};
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 WorkersAiPostRunCfQwenQwen1505bChat<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<types::WorkersAiPostRunCfQwenQwen1505bChatBody, String>,
}
impl<'a> WorkersAiPostRunCfQwenQwen1505bChat<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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<::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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAiPostRunCfQwenQwen1505bChatBody>,
{
self.body = value.try_into().map_err(|_| {
"conversion to `WorkersAiPostRunCfQwenQwen1505bChatBody` 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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/qwen/qwen1.5-0.5b-chat",
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)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_cf_qwen_qwen1_5_0_5b_chat",
};
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 WorkersAiPostRunCfQwenQwen1518bChat<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<types::WorkersAiPostRunCfQwenQwen1518bChatBody, String>,
}
impl<'a> WorkersAiPostRunCfQwenQwen1518bChat<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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<::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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAiPostRunCfQwenQwen1518bChatBody>,
{
self.body = value.try_into().map_err(|_| {
"conversion to `WorkersAiPostRunCfQwenQwen1518bChatBody` 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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/qwen/qwen1.5-1.8b-chat",
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)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_cf_qwen_qwen1_5_1_8b_chat",
};
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 WorkersAiPostRunCfQwenQwen157bChatAwq<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<types::WorkersAiPostRunCfQwenQwen157bChatAwqBody, String>,
}
impl<'a> WorkersAiPostRunCfQwenQwen157bChatAwq<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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<::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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAiPostRunCfQwenQwen157bChatAwqBody>,
{
self.body = value.try_into().map_err(|_| {
"conversion to `WorkersAiPostRunCfQwenQwen157bChatAwqBody` 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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/qwen/qwen1.5-7b-chat-awq",
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)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_cf_qwen_qwen1_5_7b_chat_awq",
};
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 WorkersAiPostRunCfQwenQwen1514bChatAwq<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<types::WorkersAiPostRunCfQwenQwen1514bChatAwqBody, String>,
}
impl<'a> WorkersAiPostRunCfQwenQwen1514bChatAwq<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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<::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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAiPostRunCfQwenQwen1514bChatAwqBody>,
{
self.body = value.try_into().map_err(|_| {
"conversion to `WorkersAiPostRunCfQwenQwen1514bChatAwqBody` 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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/qwen/qwen1.5-14b-chat-awq",
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)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_cf_qwen_qwen1_5_14b_chat_awq",
};
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 WorkersAiPostRunCfQwenQwen330bA3bFp8<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<types::WorkersAiPostRunCfQwenQwen330bA3bFp8Body, String>,
}
impl<'a> WorkersAiPostRunCfQwenQwen330bA3bFp8<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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<::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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAiPostRunCfQwenQwen330bA3bFp8Body>,
{
self.body = value.try_into().map_err(|_| {
"conversion to `WorkersAiPostRunCfQwenQwen330bA3bFp8Body` 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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/qwen/qwen3-30b-a3b-fp8",
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)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_cf_qwen_qwen3_30b_a3b_fp8",
};
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 WorkersAiPostRunCfQwenQwen3Embedding06b<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<types::builder::WorkersAiPostRunCfQwenQwen3Embedding06bBody, String>,
}
impl<'a> WorkersAiPostRunCfQwenQwen3Embedding06b<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAiPostRunCfQwenQwen3Embedding06bBody>,
<V as std::convert::TryInto<types::WorkersAiPostRunCfQwenQwen3Embedding06bBody>>::Error:
std::fmt::Display,
{
self . body = value . try_into () . map (From :: from) . map_err (| s | format ! ("conversion to `WorkersAiPostRunCfQwenQwen3Embedding06bBody` for body failed: {}" , s)) ;
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::WorkersAiPostRunCfQwenQwen3Embedding06bBody,
)
-> types::builder::WorkersAiPostRunCfQwenQwen3Embedding06bBody,
{
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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::WorkersAiPostRunCfQwenQwen3Embedding06bBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/qwen/qwen3-embedding-0.6b",
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)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_cf_qwen_qwen3_embedding_0_6b",
};
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 WorkersAiPostRunCfQwenQwq32b<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<types::WorkersAiPostRunCfQwenQwq32bBody, String>,
}
impl<'a> WorkersAiPostRunCfQwenQwq32b<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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<::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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAiPostRunCfQwenQwq32bBody>,
{
self.body = value.try_into().map_err(|_| {
"conversion to `WorkersAiPostRunCfQwenQwq32bBody` 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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/qwen/qwq-32b",
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)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_cf_qwen_qwq_32b",
};
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 WorkersAiPostRunCfTiiuaeFalcon7bInstruct<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<types::WorkersAiPostRunCfTiiuaeFalcon7bInstructBody, String>,
}
impl<'a> WorkersAiPostRunCfTiiuaeFalcon7bInstruct<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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<::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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAiPostRunCfTiiuaeFalcon7bInstructBody>,
{
self.body = value.try_into().map_err(|_| {
"conversion to `WorkersAiPostRunCfTiiuaeFalcon7bInstructBody` 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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/tiiuae/falcon-7b-instruct",
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)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_cf_tiiuae_falcon_7b_instruct",
};
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 WorkersAiPostRunCfZaiOrgGlm47Flash<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<types::WorkersAiPostRunCfZaiOrgGlm47FlashBody, String>,
}
impl<'a> WorkersAiPostRunCfZaiOrgGlm47Flash<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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<::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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAiPostRunCfZaiOrgGlm47FlashBody>,
{
self.body = value.try_into().map_err(|_| {
"conversion to `WorkersAiPostRunCfZaiOrgGlm47FlashBody` 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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@cf/zai-org/glm-4.7-flash",
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)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_cf_zai_org_glm_4_7_flash",
};
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 WorkersAiPostRunHfGoogleGemma7bIt<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
queue_request: Result<::std::string::String, String>,
tags: Result<::std::string::String, String>,
body: Result<types::WorkersAiPostRunHfGoogleGemma7bItBody, String>,
}
impl<'a> WorkersAiPostRunHfGoogleGemma7bIt<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
queue_request: Err("queue_request was not initialized".to_string()),
tags: Err("tags 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<::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 queue_request<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.queue_request = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for queue_request failed".to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAiPostRunHfGoogleGemma7bItBody>,
{
self.body = value.try_into().map_err(|_| {
"conversion to `WorkersAiPostRunHfGoogleGemma7bItBody` 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,
queue_request,
tags,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let queue_request = queue_request.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/@hf/google/gemma-7b-it",
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)
.query(&progenitor_client::QueryParam::new(
"queueRequest",
&queue_request,
))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_ai_post_run_hf_google_gemma_7b_it",
};
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 WorkersAiPostRunModel<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
model_name: Result<::std::string::String, String>,
body: Result<types::WorkersAiPostRunModelBody, String>,
}
impl<'a> WorkersAiPostRunModel<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
model_name: Err("model_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<::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 model_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.model_name = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for model_name failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAiPostRunModelBody>,
{
self.body = value.try_into().map_err(|_| {
"conversion to `WorkersAiPostRunModelBody` 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,
model_name,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let model_name = model_name.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/ai/run/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&model_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: "workers_ai_post_run_model",
};
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 WorkersAiGetToMarkdownSupported<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
}
impl<'a> WorkersAiGetToMarkdownSupported<'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<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` 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/{}/ai/tomarkdown/supported",
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: "workers_ai_get_to_markdown_supported",
};
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 WorkersKvNamespaceListNamespaces<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersKvIdentifier, String>,
direction: Result<types::WorkersKvNamespaceListNamespacesDirection, String>,
order: Result<types::WorkersKvNamespaceListNamespacesOrder, String>,
page: Result<f64, String>,
per_page: Result<f64, String>,
}
impl<'a> WorkersKvNamespaceListNamespaces<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
direction: Err("direction was not initialized".to_string()),
order: Err("order 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<types::WorkersKvIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `WorkersKvIdentifier` for account_id failed".to_string()
});
self
}
pub fn direction<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersKvNamespaceListNamespacesDirection>,
{
self.direction = value.try_into().map_err(|_| {
"conversion to `WorkersKvNamespaceListNamespacesDirection` for direction failed"
.to_string()
});
self
}
pub fn order<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersKvNamespaceListNamespacesOrder>,
{
self.order = value.try_into().map_err(|_| {
"conversion to `WorkersKvNamespaceListNamespacesOrder` for order failed".to_string()
});
self
}
pub fn page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<f64>,
{
self.page = value
.try_into()
.map_err(|_| "conversion to `f64` for page failed".to_string());
self
}
pub fn per_page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<f64>,
{
self.per_page = value
.try_into()
.map_err(|_| "conversion to `f64` 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,
direction,
order,
page,
per_page,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let direction = direction.map_err(Error::InvalidRequest)?;
let order = order.map_err(Error::InvalidRequest)?;
let page = page.map_err(Error::InvalidRequest)?;
let per_page = per_page.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/storage/kv/namespaces",
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("direction", &direction))
.query(&progenitor_client::QueryParam::new("order", &order))
.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: "workers_kv_namespace_list_namespaces",
};
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 WorkersKvNamespaceCreateANamespace<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersKvIdentifier, String>,
body: Result<types::builder::WorkersKvCreateRenameNamespaceBody, String>,
}
impl<'a> WorkersKvNamespaceCreateANamespace<'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::WorkersKvIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `WorkersKvIdentifier` for account_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersKvCreateRenameNamespaceBody>,
<V as std::convert::TryInto<types::WorkersKvCreateRenameNamespaceBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `WorkersKvCreateRenameNamespaceBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::WorkersKvCreateRenameNamespaceBody,
) -> types::builder::WorkersKvCreateRenameNamespaceBody,
{
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::WorkersKvCreateRenameNamespaceBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/storage/kv/namespaces",
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: "workers_kv_namespace_create_a_namespace",
};
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 WorkersKvNamespaceGetANamespace<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersKvIdentifier, String>,
namespace_id: Result<types::WorkersKvNamespaceIdentifier, String>,
}
impl<'a> WorkersKvNamespaceGetANamespace<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
namespace_id: Err("namespace_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersKvIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `WorkersKvIdentifier` for account_id failed".to_string()
});
self
}
pub fn namespace_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersKvNamespaceIdentifier>,
{
self.namespace_id = value.try_into().map_err(|_| {
"conversion to `WorkersKvNamespaceIdentifier` for namespace_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,
namespace_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let namespace_id = namespace_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/storage/kv/namespaces/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&namespace_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: "workers_kv_namespace_get_a_namespace",
};
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 WorkersKvNamespaceRenameANamespace<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersKvIdentifier, String>,
namespace_id: Result<types::WorkersKvNamespaceIdentifier, String>,
body: Result<types::builder::WorkersKvCreateRenameNamespaceBody, String>,
}
impl<'a> WorkersKvNamespaceRenameANamespace<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
namespace_id: Err("namespace_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::WorkersKvIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `WorkersKvIdentifier` for account_id failed".to_string()
});
self
}
pub fn namespace_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersKvNamespaceIdentifier>,
{
self.namespace_id = value.try_into().map_err(|_| {
"conversion to `WorkersKvNamespaceIdentifier` for namespace_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersKvCreateRenameNamespaceBody>,
<V as std::convert::TryInto<types::WorkersKvCreateRenameNamespaceBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `WorkersKvCreateRenameNamespaceBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::WorkersKvCreateRenameNamespaceBody,
) -> types::builder::WorkersKvCreateRenameNamespaceBody,
{
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,
namespace_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let namespace_id = namespace_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::WorkersKvCreateRenameNamespaceBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/storage/kv/namespaces/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&namespace_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: "workers_kv_namespace_rename_a_namespace",
};
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 WorkersKvNamespaceRemoveANamespace<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersKvIdentifier, String>,
namespace_id: Result<types::WorkersKvNamespaceIdentifier, String>,
body: Result<::serde_json::Map<::std::string::String, ::serde_json::Value>, String>,
}
impl<'a> WorkersKvNamespaceRemoveANamespace<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
namespace_id: Err("namespace_id 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::WorkersKvIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `WorkersKvIdentifier` for account_id failed".to_string()
});
self
}
pub fn namespace_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersKvNamespaceIdentifier>,
{
self.namespace_id = value.try_into().map_err(|_| {
"conversion to `WorkersKvNamespaceIdentifier` for namespace_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
{
self . body = value . try_into () . map_err (| _ | "conversion to `:: serde_json :: Map < :: std :: string :: String , :: serde_json :: Value >` 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,
namespace_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let namespace_id = namespace_id.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/storage/kv/namespaces/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&namespace_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"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_kv_namespace_remove_a_namespace",
};
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 WorkersKvNamespaceListANamespaceSKeys<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersKvIdentifier, String>,
namespace_id: Result<types::WorkersKvNamespaceIdentifier, String>,
cursor: Result<::std::string::String, String>,
limit: Result<f64, String>,
prefix: Result<::std::string::String, String>,
}
impl<'a> WorkersKvNamespaceListANamespaceSKeys<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
namespace_id: Err("namespace_id was not initialized".to_string()),
cursor: Err("cursor was not initialized".to_string()),
limit: Err("limit was not initialized".to_string()),
prefix: Err("prefix was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersKvIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `WorkersKvIdentifier` for account_id failed".to_string()
});
self
}
pub fn namespace_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersKvNamespaceIdentifier>,
{
self.namespace_id = value.try_into().map_err(|_| {
"conversion to `WorkersKvNamespaceIdentifier` for namespace_id 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 fn limit<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<f64>,
{
self.limit = value
.try_into()
.map_err(|_| "conversion to `f64` for limit failed".to_string());
self
}
pub fn prefix<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.prefix = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for prefix 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,
namespace_id,
cursor,
limit,
prefix,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let namespace_id = namespace_id.map_err(Error::InvalidRequest)?;
let cursor = cursor.map_err(Error::InvalidRequest)?;
let limit = limit.map_err(Error::InvalidRequest)?;
let prefix = prefix.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/storage/kv/namespaces/{}/keys",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&namespace_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("cursor", &cursor))
.query(&progenitor_client::QueryParam::new("limit", &limit))
.query(&progenitor_client::QueryParam::new("prefix", &prefix))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_kv_namespace_list_a_namespace_s_keys",
};
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 WorkersKvNamespaceReadTheMetadataForAKey<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersKvIdentifier, String>,
namespace_id: Result<types::WorkersKvNamespaceIdentifier, String>,
key_name: Result<types::WorkersKvKeyName, String>,
}
impl<'a> WorkersKvNamespaceReadTheMetadataForAKey<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
namespace_id: Err("namespace_id was not initialized".to_string()),
key_name: Err("key_name was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersKvIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `WorkersKvIdentifier` for account_id failed".to_string()
});
self
}
pub fn namespace_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersKvNamespaceIdentifier>,
{
self.namespace_id = value.try_into().map_err(|_| {
"conversion to `WorkersKvNamespaceIdentifier` for namespace_id failed".to_string()
});
self
}
pub fn key_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersKvKeyName>,
{
self.key_name = value
.try_into()
.map_err(|_| "conversion to `WorkersKvKeyName` for key_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,
namespace_id,
key_name,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let namespace_id = namespace_id.map_err(Error::InvalidRequest)?;
let key_name = key_name.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/storage/kv/namespaces/{}/metadata/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&namespace_id.to_string()),
encode_path(&key_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: "workers_kv_namespace_read_the_metadata_for_a_key",
};
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 WorkersKvNamespaceReadKeyValuePair<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersKvIdentifier, String>,
namespace_id: Result<types::WorkersKvNamespaceIdentifier, String>,
key_name: Result<types::WorkersKvKeyName, String>,
}
impl<'a> WorkersKvNamespaceReadKeyValuePair<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
namespace_id: Err("namespace_id was not initialized".to_string()),
key_name: Err("key_name was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersKvIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `WorkersKvIdentifier` for account_id failed".to_string()
});
self
}
pub fn namespace_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersKvNamespaceIdentifier>,
{
self.namespace_id = value.try_into().map_err(|_| {
"conversion to `WorkersKvNamespaceIdentifier` for namespace_id failed".to_string()
});
self
}
pub fn key_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersKvKeyName>,
{
self.key_name = value
.try_into()
.map_err(|_| "conversion to `WorkersKvKeyName` for key_name failed".to_string());
self
}
pub async fn send(self) -> Result<ResponseValue<ByteStream>, Error<()>> {
let Self {
client,
account_id,
namespace_id,
key_name,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let namespace_id = namespace_id.map_err(Error::InvalidRequest)?;
let key_name = key_name.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/storage/kv/namespaces/{}/values/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&namespace_id.to_string()),
encode_path(&key_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).headers(header_map).build()?;
let info = OperationInfo {
operation_id: "workers_kv_namespace_read_key_value_pair",
};
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 => Ok(ResponseValue::stream(response)),
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct WorkersKvNamespaceDeleteKeyValuePair<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersKvIdentifier, String>,
namespace_id: Result<types::WorkersKvNamespaceIdentifier, String>,
key_name: Result<types::WorkersKvKeyName, String>,
body: Result<::serde_json::Map<::std::string::String, ::serde_json::Value>, String>,
}
impl<'a> WorkersKvNamespaceDeleteKeyValuePair<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
namespace_id: Err("namespace_id was not initialized".to_string()),
key_name: Err("key_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::WorkersKvIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `WorkersKvIdentifier` for account_id failed".to_string()
});
self
}
pub fn namespace_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersKvNamespaceIdentifier>,
{
self.namespace_id = value.try_into().map_err(|_| {
"conversion to `WorkersKvNamespaceIdentifier` for namespace_id failed".to_string()
});
self
}
pub fn key_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersKvKeyName>,
{
self.key_name = value
.try_into()
.map_err(|_| "conversion to `WorkersKvKeyName` for key_name failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
{
self . body = value . try_into () . map_err (| _ | "conversion to `:: serde_json :: Map < :: std :: string :: String , :: serde_json :: Value >` 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,
namespace_id,
key_name,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let namespace_id = namespace_id.map_err(Error::InvalidRequest)?;
let key_name = key_name.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/storage/kv/namespaces/{}/values/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&namespace_id.to_string()),
encode_path(&key_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"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "workers_kv_namespace_delete_key_value_pair",
};
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 WorkerAssetsUpload<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
base64: Result<bool, String>,
body: Result<
::std::collections::HashMap<::std::string::String, ::std::string::String>,
String,
>,
}
impl<'a> WorkerAssetsUpload<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
base64: Err("base64 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::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn base64<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.base64 = value
.try_into()
.map_err(|_| "conversion to `bool` for base64 failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<
::std::collections::HashMap<::std::string::String, ::std::string::String>,
>,
{
self . body = value . try_into () . map_err (| _ | "conversion to `:: std :: collections :: HashMap < :: std :: string :: String , :: 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,
base64,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let base64 = base64.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/assets/upload",
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)
.query(&progenitor_client::QueryParam::new("base64", &base64))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "worker_assets_upload",
};
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 WorkerDomainGetADomain<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersAccountIdentifier, String>,
domain_id: Result<types::WorkersDomainIdentifier, String>,
}
impl<'a> WorkerDomainGetADomain<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
domain_id: Err("domain_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersAccountIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `WorkersAccountIdentifier` for account_id failed".to_string()
});
self
}
pub fn domain_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersDomainIdentifier>,
{
self.domain_id = value.try_into().map_err(|_| {
"conversion to `WorkersDomainIdentifier` for domain_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,
domain_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let domain_id = domain_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/domains/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&domain_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: "worker_domain_get_a_domain",
};
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 WorkerDomainDetachFromDomain<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersAccountIdentifier, String>,
domain_id: Result<types::WorkersDomainIdentifier, String>,
body: Result<::serde_json::Map<::std::string::String, ::serde_json::Value>, String>,
}
impl<'a> WorkerDomainDetachFromDomain<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
domain_id: Err("domain_id 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::WorkersAccountIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `WorkersAccountIdentifier` for account_id failed".to_string()
});
self
}
pub fn domain_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersDomainIdentifier>,
{
self.domain_id = value.try_into().map_err(|_| {
"conversion to `WorkersDomainIdentifier` for domain_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
{
self . body = value . try_into () . map_err (| _ | "conversion to `:: serde_json :: Map < :: std :: string :: String , :: serde_json :: Value >` 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,
domain_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let domain_id = domain_id.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/domains/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&domain_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"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "worker_domain_detach_from_domain",
};
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 WorkerPlacementListRegions<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
}
impl<'a> WorkerPlacementListRegions<'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::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` 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/{}/workers/placement/regions",
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: "worker_placement_list_regions",
};
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 WorkerScriptSearchWorkers<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
id: Result<::std::string::String, String>,
name: Result<::std::string::String, String>,
order_by: Result<types::WorkerScriptSearchWorkersOrderBy, String>,
page: Result<::std::num::NonZeroU64, String>,
per_page: Result<::std::num::NonZeroU64, String>,
}
impl<'a> WorkerScriptSearchWorkers<'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()),
name: Err("name was not initialized".to_string()),
order_by: Err("order_by 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<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for id failed".to_string()
});
self
}
pub fn name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.name = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for name failed".to_string()
});
self
}
pub fn order_by<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkerScriptSearchWorkersOrderBy>,
{
self.order_by = value.try_into().map_err(|_| {
"conversion to `WorkerScriptSearchWorkersOrderBy` for order_by 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 async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
id,
name,
order_by,
page,
per_page,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let id = id.map_err(Error::InvalidRequest)?;
let name = name.map_err(Error::InvalidRequest)?;
let order_by = order_by.map_err(Error::InvalidRequest)?;
let page = page.map_err(Error::InvalidRequest)?;
let per_page = per_page.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/scripts-search",
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("id", &id))
.query(&progenitor_client::QueryParam::new("name", &name))
.query(&progenitor_client::QueryParam::new("order_by", &order_by))
.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: "worker_script_search_workers",
};
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 WorkerScriptDownloadWorker<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
script_name: Result<types::WorkersScriptName, String>,
}
impl<'a> WorkerScriptDownloadWorker<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
script_name: Err("script_name was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_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,
script_name,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/scripts/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&script_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: "worker_script_download_worker",
};
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 WorkerScriptUploadWorkerModule<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
script_name: Result<types::WorkersScriptName, String>,
bindings_inherit: Result<types::WorkerScriptUploadWorkerModuleBindingsInherit, String>,
body: Result<types::builder::WorkerScriptUploadWorkerModuleBody, String>,
}
impl<'a> WorkerScriptUploadWorkerModule<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
script_name: Err("script_name was not initialized".to_string()),
bindings_inherit: Err("bindings_inherit 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::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_name failed".to_string()
});
self
}
pub fn bindings_inherit<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkerScriptUploadWorkerModuleBindingsInherit>,
{
self . bindings_inherit = value . try_into () . map_err (| _ | "conversion to `WorkerScriptUploadWorkerModuleBindingsInherit` for bindings_inherit failed" . to_string ()) ;
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkerScriptUploadWorkerModuleBody>,
<V as std::convert::TryInto<types::WorkerScriptUploadWorkerModuleBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `WorkerScriptUploadWorkerModuleBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::WorkerScriptUploadWorkerModuleBody,
) -> types::builder::WorkerScriptUploadWorkerModuleBody,
{
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,
script_name,
bindings_inherit,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let bindings_inherit = bindings_inherit.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::WorkerScriptUploadWorkerModuleBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/scripts/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&script_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)
.query(&progenitor_client::QueryParam::new(
"bindings_inherit",
&bindings_inherit,
))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "worker_script_upload_worker_module",
};
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 WorkerScriptDeleteWorker<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
script_name: Result<types::WorkersScriptName, String>,
force: Result<bool, String>,
body: Result<::serde_json::Map<::std::string::String, ::serde_json::Value>, String>,
}
impl<'a> WorkerScriptDeleteWorker<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
script_name: Err("script_name was not initialized".to_string()),
force: Err("force 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::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_name failed".to_string()
});
self
}
pub fn force<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.force = value
.try_into()
.map_err(|_| "conversion to `bool` for force failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
{
self . body = value . try_into () . map_err (| _ | "conversion to `:: serde_json :: Map < :: std :: string :: String , :: serde_json :: Value >` 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,
script_name,
force,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let force = force.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/scripts/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&script_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"),
)
.json(&body)
.query(&progenitor_client::QueryParam::new("force", &force))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "worker_script_delete_worker",
};
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 WorkerScriptPutContent<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
script_name: Result<types::WorkersScriptName, String>,
cf_worker_body_part: Result<::std::string::String, String>,
cf_worker_main_module_part: Result<::std::string::String, String>,
body: Result<types::builder::WorkerScriptPutContentBody, String>,
}
impl<'a> WorkerScriptPutContent<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
script_name: Err("script_name was not initialized".to_string()),
cf_worker_body_part: Err("cf_worker_body_part was not initialized".to_string()),
cf_worker_main_module_part: Err(
"cf_worker_main_module_part 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::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_name failed".to_string()
});
self
}
pub fn cf_worker_body_part<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.cf_worker_body_part = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for cf_worker_body_part failed"
.to_string()
});
self
}
pub fn cf_worker_main_module_part<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self . cf_worker_main_module_part = value . try_into () . map_err (| _ | "conversion to `:: std :: string :: String` for cf_worker_main_module_part failed" . to_string ()) ;
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkerScriptPutContentBody>,
<V as std::convert::TryInto<types::WorkerScriptPutContentBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `WorkerScriptPutContentBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::WorkerScriptPutContentBody,
) -> types::builder::WorkerScriptPutContentBody,
{
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,
script_name,
cf_worker_body_part,
cf_worker_main_module_part,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let cf_worker_body_part = cf_worker_body_part.map_err(Error::InvalidRequest)?;
let cf_worker_main_module_part =
cf_worker_main_module_part.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::WorkerScriptPutContentBody::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/scripts/{}/content",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&script_name.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(3usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
header_map.append(
"CF-WORKER-BODY-PART",
cf_worker_body_part.to_string().try_into()?,
);
header_map.append(
"CF-WORKER-MAIN-MODULE-PART",
cf_worker_main_module_part.to_string().try_into()?,
);
#[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: "worker_script_put_content",
};
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 WorkerScriptGetContent<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
script_name: Result<types::WorkersScriptName, String>,
}
impl<'a> WorkerScriptGetContent<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
script_name: Err("script_name was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_name failed".to_string()
});
self
}
pub async fn send(self) -> Result<ResponseValue<ByteStream>, Error<()>> {
let Self {
client,
account_id,
script_name,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/scripts/{}/content/v2",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&script_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).headers(header_map).build()?;
let info = OperationInfo {
operation_id: "worker_script_get_content",
};
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 => Ok(ResponseValue::stream(response)),
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct WorkerDeploymentsListDeployments<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
script_name: Result<types::WorkersScriptName, String>,
}
impl<'a> WorkerDeploymentsListDeployments<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
script_name: Err("script_name was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_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,
script_name,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/scripts/{}/deployments",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&script_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: "worker_deployments_list_deployments",
};
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 WorkerDeploymentsCreateDeployment<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
script_name: Result<types::WorkersScriptName, String>,
force: Result<bool, String>,
body: Result<types::builder::WorkersDeployment, String>,
}
impl<'a> WorkerDeploymentsCreateDeployment<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
script_name: Err("script_name was not initialized".to_string()),
force: Err("force 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::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_name failed".to_string()
});
self
}
pub fn force<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.force = value
.try_into()
.map_err(|_| "conversion to `bool` for force failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersDeployment>,
<V as std::convert::TryInto<types::WorkersDeployment>>::Error: std::fmt::Display,
{
self.body = value
.try_into()
.map(From::from)
.map_err(|s| format!("conversion to `WorkersDeployment` for body failed: {}", s));
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::WorkersDeployment,
) -> types::builder::WorkersDeployment,
{
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,
script_name,
force,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let force = force.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| types::WorkersDeployment::try_from(v).map_err(|e| e.to_string()))
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/scripts/{}/deployments",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&script_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("force", &force))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "worker_deployments_create_deployment",
};
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 WorkerDeploymentsGetDeployment<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
script_name: Result<types::WorkersScriptName, String>,
deployment_id: Result<::uuid::Uuid, String>,
}
impl<'a> WorkerDeploymentsGetDeployment<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
script_name: Err("script_name was not initialized".to_string()),
deployment_id: Err("deployment_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_name failed".to_string()
});
self
}
pub fn deployment_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::uuid::Uuid>,
{
self.deployment_id = value.try_into().map_err(|_| {
"conversion to `:: uuid :: Uuid` for deployment_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,
script_name,
deployment_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let deployment_id = deployment_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/scripts/{}/deployments/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&script_name.to_string()),
encode_path(&deployment_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: "worker_deployments_get_deployment",
};
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 WorkerDeploymentsDeleteDeployment<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
script_name: Result<types::WorkersScriptName, String>,
deployment_id: Result<::uuid::Uuid, String>,
}
impl<'a> WorkerDeploymentsDeleteDeployment<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
script_name: Err("script_name was not initialized".to_string()),
deployment_id: Err("deployment_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_name failed".to_string()
});
self
}
pub fn deployment_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::uuid::Uuid>,
{
self.deployment_id = value.try_into().map_err(|_| {
"conversion to `:: uuid :: Uuid` for deployment_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,
script_name,
deployment_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let deployment_id = deployment_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/scripts/{}/deployments/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&script_name.to_string()),
encode_path(&deployment_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: "worker_deployments_delete_deployment",
};
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 WorkerCronTriggerGetCronTriggers<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
script_name: Result<types::WorkersScriptName, String>,
}
impl<'a> WorkerCronTriggerGetCronTriggers<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
script_name: Err("script_name was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_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,
script_name,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/scripts/{}/schedules",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&script_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: "worker_cron_trigger_get_cron_triggers",
};
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 WorkerCronTriggerUpdateCronTriggers<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
script_name: Result<types::WorkersScriptName, String>,
body: Result<::std::vec::Vec<types::WorkersSchedule>, String>,
}
impl<'a> WorkerCronTriggerUpdateCronTriggers<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
script_name: Err("script_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::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_name failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::vec::Vec<types::WorkersSchedule>>,
{
self.body = value.try_into().map_err(|_| {
"conversion to `:: std :: vec :: Vec < WorkersSchedule >` 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,
script_name,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/scripts/{}/schedules",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&script_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: "worker_cron_trigger_update_cron_triggers",
};
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 WorkerScriptSettingsGetSettings<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
script_name: Result<types::WorkersScriptName, String>,
}
impl<'a> WorkerScriptSettingsGetSettings<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
script_name: Err("script_name was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_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,
script_name,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/scripts/{}/script-settings",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&script_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: "worker_script_settings_get_settings",
};
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 WorkerScriptSettingsPatchSettings<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
script_name: Result<types::WorkersScriptName, String>,
body: Result<types::builder::WorkersScriptSettingsItem, String>,
}
impl<'a> WorkerScriptSettingsPatchSettings<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
script_name: Err("script_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::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_name failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptSettingsItem>,
<V as std::convert::TryInto<types::WorkersScriptSettingsItem>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `WorkersScriptSettingsItem` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::WorkersScriptSettingsItem,
) -> types::builder::WorkersScriptSettingsItem,
{
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,
script_name,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::WorkersScriptSettingsItem::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/scripts/{}/script-settings",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&script_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
.patch(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "worker_script_settings_patch_settings",
};
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 WorkerListScriptSecrets<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
script_name: Result<types::WorkersScriptName, String>,
}
impl<'a> WorkerListScriptSecrets<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
script_name: Err("script_name was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_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,
script_name,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/scripts/{}/secrets",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&script_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: "worker_list_script_secrets",
};
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 WorkerPutScriptSecret<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
script_name: Result<types::WorkersScriptName, String>,
body: Result<types::WorkersSecret, String>,
}
impl<'a> WorkerPutScriptSecret<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
script_name: Err("script_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::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_name failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersSecret>,
{
self.body = value
.try_into()
.map_err(|_| "conversion to `WorkersSecret` 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,
script_name,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/scripts/{}/secrets",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&script_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: "worker_put_script_secret",
};
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 WorkerGetScriptSecret<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
script_name: Result<types::WorkersScriptName, String>,
secret_name: Result<types::WorkersSecretName, String>,
url_encoded: Result<types::WorkersSecretNameUrlEncoded, String>,
}
impl<'a> WorkerGetScriptSecret<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
script_name: Err("script_name was not initialized".to_string()),
secret_name: Err("secret_name was not initialized".to_string()),
url_encoded: Err("url_encoded was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_name failed".to_string()
});
self
}
pub fn secret_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersSecretName>,
{
self.secret_name = value.try_into().map_err(|_| {
"conversion to `WorkersSecretName` for secret_name failed".to_string()
});
self
}
pub fn url_encoded<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersSecretNameUrlEncoded>,
{
self.url_encoded = value.try_into().map_err(|_| {
"conversion to `WorkersSecretNameUrlEncoded` for url_encoded 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,
script_name,
secret_name,
url_encoded,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let secret_name = secret_name.map_err(Error::InvalidRequest)?;
let url_encoded = url_encoded.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/scripts/{}/secrets/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&script_name.to_string()),
encode_path(&secret_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(
"url_encoded",
&url_encoded,
))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "worker_get_script_secret",
};
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 WorkerDeleteScriptSecret<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
script_name: Result<types::WorkersScriptName, String>,
secret_name: Result<types::WorkersSecretName, String>,
url_encoded: Result<types::WorkersSecretNameUrlEncoded, String>,
}
impl<'a> WorkerDeleteScriptSecret<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
script_name: Err("script_name was not initialized".to_string()),
secret_name: Err("secret_name was not initialized".to_string()),
url_encoded: Err("url_encoded was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_name failed".to_string()
});
self
}
pub fn secret_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersSecretName>,
{
self.secret_name = value.try_into().map_err(|_| {
"conversion to `WorkersSecretName` for secret_name failed".to_string()
});
self
}
pub fn url_encoded<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersSecretNameUrlEncoded>,
{
self.url_encoded = value.try_into().map_err(|_| {
"conversion to `WorkersSecretNameUrlEncoded` for url_encoded 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,
script_name,
secret_name,
url_encoded,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let secret_name = secret_name.map_err(Error::InvalidRequest)?;
let url_encoded = url_encoded.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/scripts/{}/secrets/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&script_name.to_string()),
encode_path(&secret_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"),
)
.query(&progenitor_client::QueryParam::new(
"url_encoded",
&url_encoded,
))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "worker_delete_script_secret",
};
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 WorkerScriptGetSettings<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
script_name: Result<types::WorkersScriptName, String>,
}
impl<'a> WorkerScriptGetSettings<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
script_name: Err("script_name was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_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,
script_name,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/scripts/{}/settings",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&script_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: "worker_script_get_settings",
};
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 WorkerScriptPatchSettings<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
script_name: Result<types::WorkersScriptName, String>,
body: Result<types::builder::WorkerScriptPatchSettingsBody, String>,
}
impl<'a> WorkerScriptPatchSettings<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
script_name: Err("script_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::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_name failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkerScriptPatchSettingsBody>,
<V as std::convert::TryInto<types::WorkerScriptPatchSettingsBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `WorkerScriptPatchSettingsBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::WorkerScriptPatchSettingsBody,
) -> types::builder::WorkerScriptPatchSettingsBody,
{
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,
script_name,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::WorkerScriptPatchSettingsBody::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/scripts/{}/settings",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&script_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
.patch(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "worker_script_patch_settings",
};
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 WorkerScriptGetSubdomain<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
script_name: Result<types::WorkersScriptName, String>,
}
impl<'a> WorkerScriptGetSubdomain<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
script_name: Err("script_name was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_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,
script_name,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/scripts/{}/subdomain",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&script_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: "worker_script_get_subdomain",
};
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 WorkerScriptPostSubdomain<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
script_name: Result<types::WorkersScriptName, String>,
body: Result<types::builder::WorkerScriptPostSubdomainBody, String>,
}
impl<'a> WorkerScriptPostSubdomain<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
script_name: Err("script_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::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_name failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkerScriptPostSubdomainBody>,
<V as std::convert::TryInto<types::WorkerScriptPostSubdomainBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `WorkerScriptPostSubdomainBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::WorkerScriptPostSubdomainBody,
) -> types::builder::WorkerScriptPostSubdomainBody,
{
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,
script_name,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::WorkerScriptPostSubdomainBody::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/scripts/{}/subdomain",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&script_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: "worker_script_post_subdomain",
};
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 WorkerScriptDeleteSubdomain<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
script_name: Result<types::WorkersScriptName, String>,
}
impl<'a> WorkerScriptDeleteSubdomain<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
script_name: Err("script_name was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_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,
script_name,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/scripts/{}/subdomain",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&script_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: "worker_script_delete_subdomain",
};
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 WorkerTailLogsStartTail<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
script_name: Result<types::WorkersScriptName, String>,
body: Result<::serde_json::Map<::std::string::String, ::serde_json::Value>, String>,
}
impl<'a> WorkerTailLogsStartTail<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
script_name: Err("script_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::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_name failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
{
self . body = value . try_into () . map_err (| _ | "conversion to `:: serde_json :: Map < :: std :: string :: String , :: serde_json :: Value >` 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,
script_name,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/scripts/{}/tails",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&script_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: "worker_tail_logs_start_tail",
};
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 WorkerTailLogsDeleteTail<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
script_name: Result<types::WorkersScriptName, String>,
id: Result<types::WorkersIdentifier, String>,
body: Result<::serde_json::Map<::std::string::String, ::serde_json::Value>, String>,
}
impl<'a> WorkerTailLogsDeleteTail<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
script_name: Err("script_name was not initialized".to_string()),
id: Err("id 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::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_name failed".to_string()
});
self
}
pub fn id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
{
self . body = value . try_into () . map_err (| _ | "conversion to `:: serde_json :: Map < :: std :: string :: String , :: serde_json :: Value >` 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,
script_name,
id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let id = id.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/scripts/{}/tails/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&script_name.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"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "worker_tail_logs_delete_tail",
};
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 WorkerScriptFetchUsageModel<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
script_name: Result<types::WorkersScriptName, String>,
}
impl<'a> WorkerScriptFetchUsageModel<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
script_name: Err("script_name was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_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,
script_name,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/scripts/{}/usage-model",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&script_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: "worker_script_fetch_usage_model",
};
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 WorkerScriptUpdateUsageModel<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
script_name: Result<types::WorkersScriptName, String>,
body: Result<types::builder::WorkerScriptUpdateUsageModelBody, String>,
}
impl<'a> WorkerScriptUpdateUsageModel<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
script_name: Err("script_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::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_name failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkerScriptUpdateUsageModelBody>,
<V as std::convert::TryInto<types::WorkerScriptUpdateUsageModelBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `WorkerScriptUpdateUsageModelBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::WorkerScriptUpdateUsageModelBody,
) -> types::builder::WorkerScriptUpdateUsageModelBody,
{
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,
script_name,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::WorkerScriptUpdateUsageModelBody::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/scripts/{}/usage-model",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&script_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: "worker_script_update_usage_model",
};
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 WorkerVersionsListVersions<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
script_name: Result<types::WorkersSchemasScriptName, String>,
deployable: Result<bool, String>,
page: Result<i64, String>,
per_page: Result<i64, String>,
}
impl<'a> WorkerVersionsListVersions<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
script_name: Err("script_name was not initialized".to_string()),
deployable: Err("deployable 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<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersSchemasScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersSchemasScriptName` for script_name failed".to_string()
});
self
}
pub fn deployable<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.deployable = value
.try_into()
.map_err(|_| "conversion to `bool` for deployable failed".to_string());
self
}
pub fn page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<i64>,
{
self.page = value
.try_into()
.map_err(|_| "conversion to `i64` 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,
script_name,
deployable,
page,
per_page,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let deployable = deployable.map_err(Error::InvalidRequest)?;
let page = page.map_err(Error::InvalidRequest)?;
let per_page = per_page.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/scripts/{}/versions",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&script_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(
"deployable",
&deployable,
))
.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: "worker_versions_list_versions",
};
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 WorkerVersionsUploadVersion<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
script_name: Result<types::WorkersSchemasScriptName, String>,
bindings_inherit: Result<types::WorkerVersionsUploadVersionBindingsInherit, String>,
body: Result<types::builder::WorkerVersionsUploadVersionBody, String>,
}
impl<'a> WorkerVersionsUploadVersion<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
script_name: Err("script_name was not initialized".to_string()),
bindings_inherit: Err("bindings_inherit 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::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersSchemasScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersSchemasScriptName` for script_name failed".to_string()
});
self
}
pub fn bindings_inherit<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkerVersionsUploadVersionBindingsInherit>,
{
self . bindings_inherit = value . try_into () . map_err (| _ | "conversion to `WorkerVersionsUploadVersionBindingsInherit` for bindings_inherit failed" . to_string ()) ;
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkerVersionsUploadVersionBody>,
<V as std::convert::TryInto<types::WorkerVersionsUploadVersionBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `WorkerVersionsUploadVersionBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::WorkerVersionsUploadVersionBody,
) -> types::builder::WorkerVersionsUploadVersionBody,
{
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,
script_name,
bindings_inherit,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let bindings_inherit = bindings_inherit.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::WorkerVersionsUploadVersionBody::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/scripts/{}/versions",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&script_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(
"bindings_inherit",
&bindings_inherit,
))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "worker_versions_upload_version",
};
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 WorkerVersionsGetVersionDetail<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
script_name: Result<types::WorkersSchemasScriptName, String>,
version_id: Result<types::WorkersVersionIdentifier, String>,
}
impl<'a> WorkerVersionsGetVersionDetail<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
script_name: Err("script_name was not initialized".to_string()),
version_id: Err("version_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersSchemasScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersSchemasScriptName` for script_name failed".to_string()
});
self
}
pub fn version_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersVersionIdentifier>,
{
self.version_id = value.try_into().map_err(|_| {
"conversion to `WorkersVersionIdentifier` for version_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,
script_name,
version_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let version_id = version_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/scripts/{}/versions/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&script_name.to_string()),
encode_path(&version_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: "worker_versions_get_version_detail",
};
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 WorkerEnvironmentGetScriptContent<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
service_name: Result<types::WorkersService, String>,
environment_name: Result<types::WorkersEnvironment, String>,
}
impl<'a> WorkerEnvironmentGetScriptContent<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
service_name: Err("service_name was not initialized".to_string()),
environment_name: Err("environment_name was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn service_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersService>,
{
self.service_name = value
.try_into()
.map_err(|_| "conversion to `WorkersService` for service_name failed".to_string());
self
}
pub fn environment_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersEnvironment>,
{
self.environment_name = value.try_into().map_err(|_| {
"conversion to `WorkersEnvironment` for environment_name failed".to_string()
});
self
}
pub async fn send(self) -> Result<ResponseValue<ByteStream>, Error<()>> {
let Self {
client,
account_id,
service_name,
environment_name,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let service_name = service_name.map_err(Error::InvalidRequest)?;
let environment_name = environment_name.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/services/{}/environments/{}/content",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&service_name.to_string()),
encode_path(&environment_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).headers(header_map).build()?;
let info = OperationInfo {
operation_id: "worker_environment_get_script_content",
};
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 => Ok(ResponseValue::stream(response)),
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct WorkerEnvironmentPutScriptContent<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
service_name: Result<types::WorkersService, String>,
environment_name: Result<types::WorkersEnvironment, String>,
cf_worker_body_part: Result<::std::string::String, String>,
cf_worker_main_module_part: Result<::std::string::String, String>,
body: Result<types::builder::WorkerEnvironmentPutScriptContentBody, String>,
}
impl<'a> WorkerEnvironmentPutScriptContent<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
service_name: Err("service_name was not initialized".to_string()),
environment_name: Err("environment_name was not initialized".to_string()),
cf_worker_body_part: Err("cf_worker_body_part was not initialized".to_string()),
cf_worker_main_module_part: Err(
"cf_worker_main_module_part 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::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn service_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersService>,
{
self.service_name = value
.try_into()
.map_err(|_| "conversion to `WorkersService` for service_name failed".to_string());
self
}
pub fn environment_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersEnvironment>,
{
self.environment_name = value.try_into().map_err(|_| {
"conversion to `WorkersEnvironment` for environment_name failed".to_string()
});
self
}
pub fn cf_worker_body_part<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.cf_worker_body_part = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for cf_worker_body_part failed"
.to_string()
});
self
}
pub fn cf_worker_main_module_part<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self . cf_worker_main_module_part = value . try_into () . map_err (| _ | "conversion to `:: std :: string :: String` for cf_worker_main_module_part failed" . to_string ()) ;
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkerEnvironmentPutScriptContentBody>,
<V as std::convert::TryInto<types::WorkerEnvironmentPutScriptContentBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `WorkerEnvironmentPutScriptContentBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::WorkerEnvironmentPutScriptContentBody,
)
-> types::builder::WorkerEnvironmentPutScriptContentBody,
{
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,
service_name,
environment_name,
cf_worker_body_part,
cf_worker_main_module_part,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let service_name = service_name.map_err(Error::InvalidRequest)?;
let environment_name = environment_name.map_err(Error::InvalidRequest)?;
let cf_worker_body_part = cf_worker_body_part.map_err(Error::InvalidRequest)?;
let cf_worker_main_module_part =
cf_worker_main_module_part.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::WorkerEnvironmentPutScriptContentBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/services/{}/environments/{}/content",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&service_name.to_string()),
encode_path(&environment_name.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(3usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
header_map.append(
"CF-WORKER-BODY-PART",
cf_worker_body_part.to_string().try_into()?,
);
header_map.append(
"CF-WORKER-MAIN-MODULE-PART",
cf_worker_main_module_part.to_string().try_into()?,
);
#[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: "worker_environment_put_script_content",
};
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 WorkerScriptEnvironmentGetSettings<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
service_name: Result<types::WorkersService, String>,
environment_name: Result<types::WorkersEnvironment, String>,
}
impl<'a> WorkerScriptEnvironmentGetSettings<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
service_name: Err("service_name was not initialized".to_string()),
environment_name: Err("environment_name was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn service_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersService>,
{
self.service_name = value
.try_into()
.map_err(|_| "conversion to `WorkersService` for service_name failed".to_string());
self
}
pub fn environment_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersEnvironment>,
{
self.environment_name = value.try_into().map_err(|_| {
"conversion to `WorkersEnvironment` for environment_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,
service_name,
environment_name,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let service_name = service_name.map_err(Error::InvalidRequest)?;
let environment_name = environment_name.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/services/{}/environments/{}/settings",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&service_name.to_string()),
encode_path(&environment_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: "worker_script_environment_get_settings",
};
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 WorkerScriptEnvironmentPatchSettings<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
service_name: Result<types::WorkersService, String>,
environment_name: Result<types::WorkersEnvironment, String>,
body: Result<types::builder::WorkersScriptSettingsResponse, String>,
}
impl<'a> WorkerScriptEnvironmentPatchSettings<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
service_name: Err("service_name was not initialized".to_string()),
environment_name: Err("environment_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::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn service_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersService>,
{
self.service_name = value
.try_into()
.map_err(|_| "conversion to `WorkersService` for service_name failed".to_string());
self
}
pub fn environment_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersEnvironment>,
{
self.environment_name = value.try_into().map_err(|_| {
"conversion to `WorkersEnvironment` for environment_name failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptSettingsResponse>,
<V as std::convert::TryInto<types::WorkersScriptSettingsResponse>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `WorkersScriptSettingsResponse` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::WorkersScriptSettingsResponse,
) -> types::builder::WorkersScriptSettingsResponse,
{
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,
service_name,
environment_name,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let service_name = service_name.map_err(Error::InvalidRequest)?;
let environment_name = environment_name.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::WorkersScriptSettingsResponse::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/services/{}/environments/{}/settings",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&service_name.to_string()),
encode_path(&environment_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
.patch(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "worker_script_environment_patch_settings",
};
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 WorkerSubdomainDeleteSubdomain<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
}
impl<'a> WorkerSubdomainDeleteSubdomain<'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::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub async fn send(self) -> Result<ResponseValue<()>, Error<()>> {
let Self { client, account_id } = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/subdomain",
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.delete(url).headers(header_map).build()?;
let info = OperationInfo {
operation_id: "worker_subdomain_delete_subdomain",
};
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() {
204u16 => Ok(ResponseValue::empty(response)),
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct WorkerRoutesGetRoute<'a> {
client: &'a crate::Client,
zone_id: Result<types::WorkersIdentifier, String>,
route_id: Result<types::WorkersIdentifier, String>,
}
impl<'a> WorkerRoutesGetRoute<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
route_id: Err("route_id was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.zone_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for zone_id failed".to_string());
self
}
pub fn route_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.route_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for route_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,
zone_id,
route_id,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let route_id = route_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/workers/routes/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&route_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: "worker_routes_get_route",
};
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 WorkerRoutesUpdateRoute<'a> {
client: &'a crate::Client,
zone_id: Result<types::WorkersIdentifier, String>,
route_id: Result<types::WorkersIdentifier, String>,
body: Result<types::builder::WorkersRoute, String>,
}
impl<'a> WorkerRoutesUpdateRoute<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
route_id: Err("route_id was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.zone_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for zone_id failed".to_string());
self
}
pub fn route_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.route_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for route_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersRoute>,
<V as std::convert::TryInto<types::WorkersRoute>>::Error: std::fmt::Display,
{
self.body = value
.try_into()
.map(From::from)
.map_err(|s| format!("conversion to `WorkersRoute` for body failed: {}", s));
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(types::builder::WorkersRoute) -> types::builder::WorkersRoute,
{
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,
zone_id,
route_id,
body,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let route_id = route_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| types::WorkersRoute::try_from(v).map_err(|e| e.to_string()))
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/workers/routes/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&route_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: "worker_routes_update_route",
};
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 WorkerRoutesDeleteRoute<'a> {
client: &'a crate::Client,
zone_id: Result<types::WorkersIdentifier, String>,
route_id: Result<types::WorkersIdentifier, String>,
}
impl<'a> WorkerRoutesDeleteRoute<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
route_id: Err("route_id was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.zone_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for zone_id failed".to_string());
self
}
pub fn route_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.route_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for route_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,
zone_id,
route_id,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let route_id = route_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/workers/routes/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&route_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: "worker_routes_delete_route",
};
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)),
}
}
}