//! Typed perplexity actions for the One SDK, built on the `withone` crate.
#![allow(clippy::all)]
pub mod create_embeddings {
use ::one::{Error, IntoOperation, Method, Operation};
///Generates embeddings for one or more input texts. These embeddings can be used for semantic search, clustering, and other machine learning applications.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct Input {
///Number of dimensions for output embeddings (Matryoshka). Model-specific ranges: 128–1024 for pplx-embed-v1-0.6b; 128–2560 for pplx-embed-v1-4b. Defaults to the model’s full dimensions (1024 or 2560).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub dimensions: ::std::option::Option<i64>,
///Output encoding format for embeddings. base64_int8 returns base64-encoded signed int8 values. base64_binary returns base64-encoded packed binary (1 bit per dimension). Default: base64_int8.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub encoding_format: ::std::option::Option<InputEncodingFormat>,
///Input text(s) to embed.
pub input: InputInput,
///Embedding model to use.
pub model: InputModel,
}
impl Input {
pub fn builder() -> builder::Input {
Default::default()
}
}
///Output encoding format for embeddings. base64_int8 returns base64-encoded signed int8 values. base64_binary returns base64-encoded packed binary (1 bit per dimension). Default: base64_int8.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum InputEncodingFormat {
#[serde(rename = "base64_int8")]
Base64Int8,
#[serde(rename = "base64_binary")]
Base64Binary,
}
impl ::std::fmt::Display for InputEncodingFormat {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Base64Int8 => f.write_str("base64_int8"),
Self::Base64Binary => f.write_str("base64_binary"),
}
}
}
impl ::std::str::FromStr for InputEncodingFormat {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"base64_int8" => Ok(Self::Base64Int8),
"base64_binary" => Ok(Self::Base64Binary),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for InputEncodingFormat {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for InputEncodingFormat {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Input text(s) to embed.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(untagged)]
pub enum InputInput {
String(::std::string::String),
Array(::std::vec::Vec<::std::string::String>),
}
impl ::std::convert::From<::std::vec::Vec<::std::string::String>> for InputInput {
fn from(value: ::std::vec::Vec<::std::string::String>) -> Self {
Self::Array(value)
}
}
///Embedding model to use.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum InputModel {
#[serde(rename = "pplx-embed-v1-0.6b")]
PplxEmbedV106b,
#[serde(rename = "pplx-embed-v1-4b")]
PplxEmbedV14b,
}
impl ::std::fmt::Display for InputModel {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::PplxEmbedV106b => f.write_str("pplx-embed-v1-0.6b"),
Self::PplxEmbedV14b => f.write_str("pplx-embed-v1-4b"),
}
}
}
impl ::std::str::FromStr for InputModel {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"pplx-embed-v1-0.6b" => Ok(Self::PplxEmbedV106b),
"pplx-embed-v1-4b" => Ok(Self::PplxEmbedV14b),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for InputModel {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for InputModel {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Input {
dimensions: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
encoding_format: ::std::result::Result<
::std::option::Option<super::InputEncodingFormat>,
::std::string::String,
>,
input: ::std::result::Result<super::InputInput, ::std::string::String>,
model: ::std::result::Result<super::InputModel, ::std::string::String>,
}
impl ::std::default::Default for Input {
fn default() -> Self {
Self {
dimensions: Ok(Default::default()),
encoding_format: Ok(Default::default()),
input: Err("no value supplied for input".to_string()),
model: Err("no value supplied for model".to_string()),
}
}
}
impl Input {
pub fn dimensions<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.dimensions = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for dimensions: {e}")
});
self
}
pub fn encoding_format<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<super::InputEncodingFormat>,
>,
T::Error: ::std::fmt::Display,
{
self.encoding_format = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for encoding_format: {e}")
});
self
}
pub fn input<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::InputInput>,
T::Error: ::std::fmt::Display,
{
self.input = value
.try_into()
.map_err(|e| format!("error converting supplied value for input: {e}"));
self
}
pub fn model<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::InputModel>,
T::Error: ::std::fmt::Display,
{
self.model = value
.try_into()
.map_err(|e| format!("error converting supplied value for model: {e}"));
self
}
}
impl ::std::convert::TryFrom<Input> for super::Input {
type Error = super::error::ConversionError;
fn try_from(
value: Input,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
dimensions: value.dimensions?,
encoding_format: value.encoding_format?,
input: value.input?,
model: value.model?,
})
}
}
impl ::std::convert::From<super::Input> for Input {
fn from(value: super::Input) -> Self {
Self {
dimensions: Ok(value.dimensions),
encoding_format: Ok(value.encoding_format),
input: Ok(value.input),
model: Ok(value.model),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
pub mod output {
///Cost breakdown for the request.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Cost {
///Currency of the cost values.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub currency: ::std::option::Option<CostCurrency>,
///Cost for input tokens in USD.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub input_cost: ::std::option::Option<f64>,
///Total cost for the request in USD.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub total_cost: ::std::option::Option<f64>,
}
impl Cost {
pub fn builder() -> builder::Cost {
Default::default()
}
}
///Currency of the cost values.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum CostCurrency {
#[serde(rename = "USD")]
Usd,
}
impl ::std::fmt::Display for CostCurrency {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Usd => f.write_str("USD"),
}
}
}
impl ::std::str::FromStr for CostCurrency {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"USD" => Ok(Self::Usd),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for CostCurrency {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for CostCurrency {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///An embedding result corresponding to one input text.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct EmbeddingItem {
///Base64-encoded embedding vector. For base64_int8: decode to a signed int8 array (length = dimensions). For base64_binary: decode to packed bits (length = dimensions / 8 bytes).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub embedding: ::std::option::Option<::std::string::String>,
///Index of the input text this embedding corresponds to.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub index: ::std::option::Option<i64>,
///The object type for the embedding item.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub object: ::std::option::Option<::std::string::String>,
}
impl EmbeddingItem {
pub fn builder() -> builder::EmbeddingItem {
Default::default()
}
}
///Response structure for embedding creation, including success and validation error responses.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Output {
///List of embedding objects.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub data: ::std::vec::Vec<EmbeddingItem>,
///Validation error details for a 422 Unprocessable Entity response.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub detail: ::std::vec::Vec<ValidationErrorDetail>,
///The model used to generate embeddings.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub model: ::std::option::Option<::std::string::String>,
///The object type. Example: "list".
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub object: ::std::option::Option<::std::string::String>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub usage: ::std::option::Option<Usage>,
}
impl Output {
pub fn builder() -> builder::Output {
Default::default()
}
}
///Token usage and cost information.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Usage {
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub cost: ::std::option::Option<Cost>,
///Number of tokens in the input texts.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub prompt_tokens: ::std::option::Option<i64>,
///Total number of tokens processed.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub total_tokens: ::std::option::Option<i64>,
}
impl Usage {
pub fn builder() -> builder::Usage {
Default::default()
}
}
///A single validation error detail entry.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct ValidationErrorDetail {
///Location of the validation error.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub loc: ::std::vec::Vec<::std::string::String>,
///Validation error message.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub msg: ::std::option::Option<::std::string::String>,
///Validation error type.
#[serde(rename = "type", skip_serializing_if = "::std::option::Option::is_none")]
pub type_: ::std::option::Option<::std::string::String>,
}
impl ValidationErrorDetail {
pub fn builder() -> builder::ValidationErrorDetail {
Default::default()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Cost {
currency: ::std::result::Result<
::std::option::Option<super::CostCurrency>,
::std::string::String,
>,
input_cost: ::std::result::Result<
::std::option::Option<f64>,
::std::string::String,
>,
total_cost: ::std::result::Result<
::std::option::Option<f64>,
::std::string::String,
>,
}
impl ::std::default::Default for Cost {
fn default() -> Self {
Self {
currency: Ok(Default::default()),
input_cost: Ok(Default::default()),
total_cost: Ok(Default::default()),
}
}
}
impl Cost {
pub fn currency<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::CostCurrency>>,
T::Error: ::std::fmt::Display,
{
self.currency = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for currency: {e}")
});
self
}
pub fn input_cost<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<f64>>,
T::Error: ::std::fmt::Display,
{
self.input_cost = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for input_cost: {e}")
});
self
}
pub fn total_cost<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<f64>>,
T::Error: ::std::fmt::Display,
{
self.total_cost = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for total_cost: {e}")
});
self
}
}
impl ::std::convert::TryFrom<Cost> for super::Cost {
type Error = super::error::ConversionError;
fn try_from(
value: Cost,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
currency: value.currency?,
input_cost: value.input_cost?,
total_cost: value.total_cost?,
})
}
}
impl ::std::convert::From<super::Cost> for Cost {
fn from(value: super::Cost) -> Self {
Self {
currency: Ok(value.currency),
input_cost: Ok(value.input_cost),
total_cost: Ok(value.total_cost),
}
}
}
#[derive(Clone, Debug)]
pub struct EmbeddingItem {
embedding: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
index: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
object: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for EmbeddingItem {
fn default() -> Self {
Self {
embedding: Ok(Default::default()),
index: Ok(Default::default()),
object: Ok(Default::default()),
}
}
}
impl EmbeddingItem {
pub fn embedding<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.embedding = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for embedding: {e}")
});
self
}
pub fn index<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.index = value
.try_into()
.map_err(|e| format!("error converting supplied value for index: {e}"));
self
}
pub fn object<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.object = value
.try_into()
.map_err(|e| format!("error converting supplied value for object: {e}"));
self
}
}
impl ::std::convert::TryFrom<EmbeddingItem> for super::EmbeddingItem {
type Error = super::error::ConversionError;
fn try_from(
value: EmbeddingItem,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
embedding: value.embedding?,
index: value.index?,
object: value.object?,
})
}
}
impl ::std::convert::From<super::EmbeddingItem> for EmbeddingItem {
fn from(value: super::EmbeddingItem) -> Self {
Self {
embedding: Ok(value.embedding),
index: Ok(value.index),
object: Ok(value.object),
}
}
}
#[derive(Clone, Debug)]
pub struct Output {
data: ::std::result::Result<
::std::vec::Vec<super::EmbeddingItem>,
::std::string::String,
>,
detail: ::std::result::Result<
::std::vec::Vec<super::ValidationErrorDetail>,
::std::string::String,
>,
model: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
object: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
usage: ::std::result::Result<
::std::option::Option<super::Usage>,
::std::string::String,
>,
}
impl ::std::default::Default for Output {
fn default() -> Self {
Self {
data: Ok(Default::default()),
detail: Ok(Default::default()),
model: Ok(Default::default()),
object: Ok(Default::default()),
usage: Ok(Default::default()),
}
}
}
impl Output {
pub fn data<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::EmbeddingItem>>,
T::Error: ::std::fmt::Display,
{
self.data = value
.try_into()
.map_err(|e| format!("error converting supplied value for data: {e}"));
self
}
pub fn detail<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::ValidationErrorDetail>>,
T::Error: ::std::fmt::Display,
{
self.detail = value
.try_into()
.map_err(|e| format!("error converting supplied value for detail: {e}"));
self
}
pub fn model<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.model = value
.try_into()
.map_err(|e| format!("error converting supplied value for model: {e}"));
self
}
pub fn object<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.object = value
.try_into()
.map_err(|e| format!("error converting supplied value for object: {e}"));
self
}
pub fn usage<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Usage>>,
T::Error: ::std::fmt::Display,
{
self.usage = value
.try_into()
.map_err(|e| format!("error converting supplied value for usage: {e}"));
self
}
}
impl ::std::convert::TryFrom<Output> for super::Output {
type Error = super::error::ConversionError;
fn try_from(
value: Output,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
data: value.data?,
detail: value.detail?,
model: value.model?,
object: value.object?,
usage: value.usage?,
})
}
}
impl ::std::convert::From<super::Output> for Output {
fn from(value: super::Output) -> Self {
Self {
data: Ok(value.data),
detail: Ok(value.detail),
model: Ok(value.model),
object: Ok(value.object),
usage: Ok(value.usage),
}
}
}
#[derive(Clone, Debug)]
pub struct Usage {
cost: ::std::result::Result<
::std::option::Option<super::Cost>,
::std::string::String,
>,
prompt_tokens: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
total_tokens: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
}
impl ::std::default::Default for Usage {
fn default() -> Self {
Self {
cost: Ok(Default::default()),
prompt_tokens: Ok(Default::default()),
total_tokens: Ok(Default::default()),
}
}
}
impl Usage {
pub fn cost<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Cost>>,
T::Error: ::std::fmt::Display,
{
self.cost = value
.try_into()
.map_err(|e| format!("error converting supplied value for cost: {e}"));
self
}
pub fn prompt_tokens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.prompt_tokens = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for prompt_tokens: {e}")
});
self
}
pub fn total_tokens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.total_tokens = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for total_tokens: {e}")
});
self
}
}
impl ::std::convert::TryFrom<Usage> for super::Usage {
type Error = super::error::ConversionError;
fn try_from(
value: Usage,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
cost: value.cost?,
prompt_tokens: value.prompt_tokens?,
total_tokens: value.total_tokens?,
})
}
}
impl ::std::convert::From<super::Usage> for Usage {
fn from(value: super::Usage) -> Self {
Self {
cost: Ok(value.cost),
prompt_tokens: Ok(value.prompt_tokens),
total_tokens: Ok(value.total_tokens),
}
}
}
#[derive(Clone, Debug)]
pub struct ValidationErrorDetail {
loc: ::std::result::Result<
::std::vec::Vec<::std::string::String>,
::std::string::String,
>,
msg: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
type_: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for ValidationErrorDetail {
fn default() -> Self {
Self {
loc: Ok(Default::default()),
msg: Ok(Default::default()),
type_: Ok(Default::default()),
}
}
}
impl ValidationErrorDetail {
pub fn loc<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.loc = value
.try_into()
.map_err(|e| format!("error converting supplied value for loc: {e}"));
self
}
pub fn msg<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.msg = value
.try_into()
.map_err(|e| format!("error converting supplied value for msg: {e}"));
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
}
impl ::std::convert::TryFrom<ValidationErrorDetail>
for super::ValidationErrorDetail {
type Error = super::error::ConversionError;
fn try_from(
value: ValidationErrorDetail,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
loc: value.loc?,
msg: value.msg?,
type_: value.type_?,
})
}
}
impl ::std::convert::From<super::ValidationErrorDetail> for ValidationErrorDetail {
fn from(value: super::ValidationErrorDetail) -> Self {
Self {
loc: Ok(value.loc),
msg: Ok(value.msg),
type_: Ok(value.type_),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
}
/// Where each field of `Input` goes in the request.
pub const ROUTING: ::one::Routing = ::one::Routing { routes: &[::one::Route { field: "dimensions", part: ::one::Part::Body, key: Some("dimensions") }, ::one::Route { field: "encoding_format", part: ::one::Part::Body, key: Some("encoding_format") }, ::one::Route { field: "input", part: ::one::Part::Body, key: Some("input") }, ::one::Route { field: "model", part: ::one::Part::Body, key: Some("model") }], required_parts: &[::one::Part::Body] };
/// Builds the `create_embeddings` action.
///
/// # Example input
/// ```json
/// {
/// "dimensions": 512,
/// "encoding_format": "base64_binary",
/// "input": [
/// "First text",
/// "Second text",
/// "Third text"
/// ],
/// "model": "pplx-embed-v1-4b"
/// }
/// ```
pub fn build(input: Input) -> ::std::result::Result<Operation<output::Output>, Error> {
::std::result::Result::Ok(Operation::action("conn_mod_def::GJ6CZdszRmI::5QKcMrnZSe6MnnVIKtksZQ", Method::POST, "/v1/embeddings").with_routed(&input, &ROUTING)?
.merge_headers(::serde_json::from_str("{\"Accept\":\"application/json\",\"Content-Type\":\"application/json\"}").map_err(Error::Decode)?).returns::<output::Output>())
}
impl IntoOperation for Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
build(self)
}
}
impl IntoOperation for builder::Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
Input::try_from(self).map_err(|error| Error::InvalidInput(::std::boxed::Box::new(error))).and_then(build)
}
}
}
/// Starts building the `create_embeddings` action's input; pass the builder to `run`.
pub fn create_embeddings() -> create_embeddings::builder::Input {
create_embeddings::builder::Input::default()
}
pub mod get_async_chat_completion_response {
use ::one::{Error, IntoOperation, Method, Operation};
///Retrieves the result of a previously created asynchronous chat completion request. The response includes the request status and, when completed, the generated chat completion payload.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct Input {
///Identifier of the async chat completion request whose response you want to retrieve. Must be a non-empty string. CLI --path-vars key must be apiRequest (camelCase, NOT api_request).
#[serde(rename = "apiRequest")]
pub api_request: InputApiRequest,
}
impl Input {
pub fn builder() -> builder::Input {
Default::default()
}
}
///Identifier of the async chat completion request whose response you want to retrieve. Must be a non-empty string. CLI --path-vars key must be apiRequest (camelCase, NOT api_request).
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct InputApiRequest(::std::string::String);
impl ::std::ops::Deref for InputApiRequest {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<InputApiRequest> for ::std::string::String {
fn from(value: InputApiRequest) -> Self {
value.0
}
}
impl ::std::str::FromStr for InputApiRequest {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
::std::convert::TryFrom::try_from(value)
}
}
impl ::std::convert::TryFrom<&str> for InputApiRequest {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<::std::string::String> for InputApiRequest {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
::std::convert::TryFrom::try_from(value.as_str())
}
}
impl<'de> ::serde::Deserialize<'de> for InputApiRequest {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::convert::TryFrom::try_from(
::std::string::String::deserialize(deserializer)?,
)
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Input {
api_request: ::std::result::Result<
super::InputApiRequest,
::std::string::String,
>,
}
impl ::std::default::Default for Input {
fn default() -> Self {
Self {
api_request: Err("no value supplied for api_request".to_string()),
}
}
}
impl Input {
pub fn api_request<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::InputApiRequest>,
T::Error: ::std::fmt::Display,
{
self.api_request = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for api_request: {e}")
});
self
}
}
impl ::std::convert::TryFrom<Input> for super::Input {
type Error = super::error::ConversionError;
fn try_from(
value: Input,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
api_request: value.api_request?,
})
}
}
impl ::std::convert::From<super::Input> for Input {
fn from(value: super::Input) -> Self {
Self {
api_request: Ok(value.api_request),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
pub mod output {
///The chat completion response payload (present when available).
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct ChatCompletionResponsePayload {
///Array of completion choices.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub choices: ::std::vec::Vec<ChatCompletionResponsePayloadChoicesItem>,
///List of citation strings, if provided.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub citations: ::std::option::Option<::std::vec::Vec<::std::string::String>>,
///Unix timestamp when the completion was created.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub created: ::std::option::Option<i64>,
///Unique identifier for the completion.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub id: ::std::option::Option<::std::string::String>,
///Images returned by the model, if any.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub images: ::std::option::Option<
::std::vec::Vec<ChatCompletionResponsePayloadImagesItem>,
>,
///Model used for generation.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub model: ::std::option::Option<::std::string::String>,
///Object type identifier. Default: "chat.completion".
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub object: ::std::option::Option<::std::string::String>,
///Related questions, if any.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub related_questions: ::std::option::Option<::std::vec::Vec<::std::string::String>>,
///Search results used/returned by the model, if any.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub search_results: ::std::option::Option<
::std::vec::Vec<ChatCompletionResponsePayloadSearchResultsItem>,
>,
///Usage information (schema referenced as UsageInfo).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub usage: ::std::option::Option<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
}
impl ChatCompletionResponsePayload {
pub fn builder() -> builder::ChatCompletionResponsePayload {
Default::default()
}
}
///`ChatCompletionResponsePayloadChoicesItem`
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct ChatCompletionResponsePayloadChoicesItem {
///Chat message delta output (schema referenced as ChatMessage-Output).
#[serde(default, skip_serializing_if = "::serde_json::Map::is_empty")]
pub delta: ::serde_json::Map<::std::string::String, ::serde_json::Value>,
///Reason generation finished. Allowed: "stop", "length".
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub finish_reason: ::std::option::Option<
ChatCompletionResponsePayloadChoicesItemFinishReason,
>,
///Index of the choice in the array.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub index: ::std::option::Option<i64>,
///Chat message output (schema referenced as ChatMessage-Output).
#[serde(default, skip_serializing_if = "::serde_json::Map::is_empty")]
pub message: ::serde_json::Map<::std::string::String, ::serde_json::Value>,
}
impl ChatCompletionResponsePayloadChoicesItem {
pub fn builder() -> builder::ChatCompletionResponsePayloadChoicesItem {
Default::default()
}
}
///Reason generation finished. Allowed: "stop", "length".
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum ChatCompletionResponsePayloadChoicesItemFinishReason {
#[serde(rename = "stop")]
Stop,
#[serde(rename = "length")]
Length,
}
impl ::std::fmt::Display for ChatCompletionResponsePayloadChoicesItemFinishReason {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Stop => f.write_str("stop"),
Self::Length => f.write_str("length"),
}
}
}
impl ::std::str::FromStr for ChatCompletionResponsePayloadChoicesItemFinishReason {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"stop" => Ok(Self::Stop),
"length" => Ok(Self::Length),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str>
for ChatCompletionResponsePayloadChoicesItemFinishReason {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String>
for ChatCompletionResponsePayloadChoicesItemFinishReason {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///`ChatCompletionResponsePayloadImagesItem`
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct ChatCompletionResponsePayloadImagesItem {
///Height of the image in pixels.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub height: ::std::option::Option<i64>,
///URL of the image.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub image_url: ::std::option::Option<::std::string::String>,
///Original URL where the image was found.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub origin_url: ::std::option::Option<::std::string::String>,
///Title or description of the image.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub title: ::std::option::Option<::std::string::String>,
///Width of the image in pixels.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub width: ::std::option::Option<i64>,
}
impl ChatCompletionResponsePayloadImagesItem {
pub fn builder() -> builder::ChatCompletionResponsePayloadImagesItem {
Default::default()
}
}
///`ChatCompletionResponsePayloadSearchResultsItem`
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct ChatCompletionResponsePayloadSearchResultsItem {
///Date associated with the result (if provided).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub date: ::std::option::Option<::std::string::String>,
///Last updated timestamp/date for the result (if provided).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub last_updated: ::std::option::Option<::std::string::String>,
///Text snippet from the search result. Default: "".
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub snippet: ::std::option::Option<::std::string::String>,
///Source type. Allowed: web, attachment. Default: "web".
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub source: ::std::option::Option<
ChatCompletionResponsePayloadSearchResultsItemSource,
>,
///Title of the search result page.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub title: ::std::option::Option<::std::string::String>,
///URL of the search result page.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub url: ::std::option::Option<::std::string::String>,
}
impl ChatCompletionResponsePayloadSearchResultsItem {
pub fn builder() -> builder::ChatCompletionResponsePayloadSearchResultsItem {
Default::default()
}
}
///Source type. Allowed: web, attachment. Default: "web".
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum ChatCompletionResponsePayloadSearchResultsItemSource {
#[serde(rename = "web")]
Web,
#[serde(rename = "attachment")]
Attachment,
}
impl ::std::fmt::Display for ChatCompletionResponsePayloadSearchResultsItemSource {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Web => f.write_str("web"),
Self::Attachment => f.write_str("attachment"),
}
}
}
impl ::std::str::FromStr for ChatCompletionResponsePayloadSearchResultsItemSource {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"web" => Ok(Self::Web),
"attachment" => Ok(Self::Attachment),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str>
for ChatCompletionResponsePayloadSearchResultsItemSource {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String>
for ChatCompletionResponsePayloadSearchResultsItemSource {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Successful or error response returned by the API.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Output {
///Unix timestamp when processing completed (if available).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub completed_at: ::std::option::Option<i64>,
///Unix timestamp when the request was created.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub created_at: ::std::option::Option<i64>,
///422 Unprocessable Entity error details for missing or invalid path parameter.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub detail: ::std::vec::Vec<OutputDetailItem>,
///Error message if the request failed.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub error_message: ::std::option::Option<::std::string::String>,
///Unix timestamp when the request failed (if it failed).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub failed_at: ::std::option::Option<i64>,
///Unique identifier for the async request.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub id: ::std::option::Option<::std::string::String>,
///Model used for the request.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub model: ::std::option::Option<::std::string::String>,
///The chat completion response payload (present when available).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub response: ::std::option::Option<ChatCompletionResponsePayload>,
///Unix timestamp when processing started (if available).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub started_at: ::std::option::Option<i64>,
///Async request status. Allowed: "CREATED", "IN_PROGRESS", "COMPLETED", "FAILED".
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub status: ::std::option::Option<OutputStatus>,
}
impl Output {
pub fn builder() -> builder::Output {
Default::default()
}
}
///`OutputDetailItem`
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct OutputDetailItem {
///Location of the validation error.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub loc: ::std::vec::Vec<::std::string::String>,
///Validation error message.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub msg: ::std::option::Option<::std::string::String>,
///Validation error type.
#[serde(rename = "type", skip_serializing_if = "::std::option::Option::is_none")]
pub type_: ::std::option::Option<::std::string::String>,
}
impl OutputDetailItem {
pub fn builder() -> builder::OutputDetailItem {
Default::default()
}
}
///Async request status. Allowed: "CREATED", "IN_PROGRESS", "COMPLETED", "FAILED".
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum OutputStatus {
#[serde(rename = "CREATED")]
Created,
#[serde(rename = "IN_PROGRESS")]
InProgress,
#[serde(rename = "COMPLETED")]
Completed,
#[serde(rename = "FAILED")]
Failed,
}
impl ::std::fmt::Display for OutputStatus {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Created => f.write_str("CREATED"),
Self::InProgress => f.write_str("IN_PROGRESS"),
Self::Completed => f.write_str("COMPLETED"),
Self::Failed => f.write_str("FAILED"),
}
}
}
impl ::std::str::FromStr for OutputStatus {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"CREATED" => Ok(Self::Created),
"IN_PROGRESS" => Ok(Self::InProgress),
"COMPLETED" => Ok(Self::Completed),
"FAILED" => Ok(Self::Failed),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for OutputStatus {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for OutputStatus {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct ChatCompletionResponsePayload {
choices: ::std::result::Result<
::std::vec::Vec<super::ChatCompletionResponsePayloadChoicesItem>,
::std::string::String,
>,
citations: ::std::result::Result<
::std::option::Option<::std::vec::Vec<::std::string::String>>,
::std::string::String,
>,
created: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
images: ::std::result::Result<
::std::option::Option<
::std::vec::Vec<super::ChatCompletionResponsePayloadImagesItem>,
>,
::std::string::String,
>,
model: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
object: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
related_questions: ::std::result::Result<
::std::option::Option<::std::vec::Vec<::std::string::String>>,
::std::string::String,
>,
search_results: ::std::result::Result<
::std::option::Option<
::std::vec::Vec<super::ChatCompletionResponsePayloadSearchResultsItem>,
>,
::std::string::String,
>,
usage: ::std::result::Result<
::std::option::Option<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
::std::string::String,
>,
}
impl ::std::default::Default for ChatCompletionResponsePayload {
fn default() -> Self {
Self {
choices: Ok(Default::default()),
citations: Ok(Default::default()),
created: Ok(Default::default()),
id: Ok(Default::default()),
images: Ok(Default::default()),
model: Ok(Default::default()),
object: Ok(Default::default()),
related_questions: Ok(Default::default()),
search_results: Ok(Default::default()),
usage: Ok(Default::default()),
}
}
}
impl ChatCompletionResponsePayload {
pub fn choices<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::vec::Vec<super::ChatCompletionResponsePayloadChoicesItem>,
>,
T::Error: ::std::fmt::Display,
{
self.choices = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for choices: {e}")
});
self
}
pub fn citations<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<::std::vec::Vec<::std::string::String>>,
>,
T::Error: ::std::fmt::Display,
{
self.citations = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for citations: {e}")
});
self
}
pub fn created<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.created = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for created: {e}")
});
self
}
pub fn id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.id = value
.try_into()
.map_err(|e| format!("error converting supplied value for id: {e}"));
self
}
pub fn images<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<
::std::vec::Vec<super::ChatCompletionResponsePayloadImagesItem>,
>,
>,
T::Error: ::std::fmt::Display,
{
self.images = value
.try_into()
.map_err(|e| format!("error converting supplied value for images: {e}"));
self
}
pub fn model<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.model = value
.try_into()
.map_err(|e| format!("error converting supplied value for model: {e}"));
self
}
pub fn object<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.object = value
.try_into()
.map_err(|e| format!("error converting supplied value for object: {e}"));
self
}
pub fn related_questions<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<::std::vec::Vec<::std::string::String>>,
>,
T::Error: ::std::fmt::Display,
{
self.related_questions = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for related_questions: {e}")
});
self
}
pub fn search_results<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<
::std::vec::Vec<
super::ChatCompletionResponsePayloadSearchResultsItem,
>,
>,
>,
T::Error: ::std::fmt::Display,
{
self.search_results = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for search_results: {e}")
});
self
}
pub fn usage<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
>,
T::Error: ::std::fmt::Display,
{
self.usage = value
.try_into()
.map_err(|e| format!("error converting supplied value for usage: {e}"));
self
}
}
impl ::std::convert::TryFrom<ChatCompletionResponsePayload>
for super::ChatCompletionResponsePayload {
type Error = super::error::ConversionError;
fn try_from(
value: ChatCompletionResponsePayload,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
choices: value.choices?,
citations: value.citations?,
created: value.created?,
id: value.id?,
images: value.images?,
model: value.model?,
object: value.object?,
related_questions: value.related_questions?,
search_results: value.search_results?,
usage: value.usage?,
})
}
}
impl ::std::convert::From<super::ChatCompletionResponsePayload>
for ChatCompletionResponsePayload {
fn from(value: super::ChatCompletionResponsePayload) -> Self {
Self {
choices: Ok(value.choices),
citations: Ok(value.citations),
created: Ok(value.created),
id: Ok(value.id),
images: Ok(value.images),
model: Ok(value.model),
object: Ok(value.object),
related_questions: Ok(value.related_questions),
search_results: Ok(value.search_results),
usage: Ok(value.usage),
}
}
}
#[derive(Clone, Debug)]
pub struct ChatCompletionResponsePayloadChoicesItem {
delta: ::std::result::Result<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
::std::string::String,
>,
finish_reason: ::std::result::Result<
::std::option::Option<
super::ChatCompletionResponsePayloadChoicesItemFinishReason,
>,
::std::string::String,
>,
index: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
message: ::std::result::Result<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
::std::string::String,
>,
}
impl ::std::default::Default for ChatCompletionResponsePayloadChoicesItem {
fn default() -> Self {
Self {
delta: Ok(Default::default()),
finish_reason: Ok(Default::default()),
index: Ok(Default::default()),
message: Ok(Default::default()),
}
}
}
impl ChatCompletionResponsePayloadChoicesItem {
pub fn delta<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
T::Error: ::std::fmt::Display,
{
self.delta = value
.try_into()
.map_err(|e| format!("error converting supplied value for delta: {e}"));
self
}
pub fn finish_reason<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<
super::ChatCompletionResponsePayloadChoicesItemFinishReason,
>,
>,
T::Error: ::std::fmt::Display,
{
self.finish_reason = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for finish_reason: {e}")
});
self
}
pub fn index<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.index = value
.try_into()
.map_err(|e| format!("error converting supplied value for index: {e}"));
self
}
pub fn message<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
T::Error: ::std::fmt::Display,
{
self.message = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for message: {e}")
});
self
}
}
impl ::std::convert::TryFrom<ChatCompletionResponsePayloadChoicesItem>
for super::ChatCompletionResponsePayloadChoicesItem {
type Error = super::error::ConversionError;
fn try_from(
value: ChatCompletionResponsePayloadChoicesItem,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
delta: value.delta?,
finish_reason: value.finish_reason?,
index: value.index?,
message: value.message?,
})
}
}
impl ::std::convert::From<super::ChatCompletionResponsePayloadChoicesItem>
for ChatCompletionResponsePayloadChoicesItem {
fn from(value: super::ChatCompletionResponsePayloadChoicesItem) -> Self {
Self {
delta: Ok(value.delta),
finish_reason: Ok(value.finish_reason),
index: Ok(value.index),
message: Ok(value.message),
}
}
}
#[derive(Clone, Debug)]
pub struct ChatCompletionResponsePayloadImagesItem {
height: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
image_url: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
origin_url: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
title: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
width: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
}
impl ::std::default::Default for ChatCompletionResponsePayloadImagesItem {
fn default() -> Self {
Self {
height: Ok(Default::default()),
image_url: Ok(Default::default()),
origin_url: Ok(Default::default()),
title: Ok(Default::default()),
width: Ok(Default::default()),
}
}
}
impl ChatCompletionResponsePayloadImagesItem {
pub fn height<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.height = value
.try_into()
.map_err(|e| format!("error converting supplied value for height: {e}"));
self
}
pub fn image_url<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.image_url = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for image_url: {e}")
});
self
}
pub fn origin_url<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.origin_url = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for origin_url: {e}")
});
self
}
pub fn title<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.title = value
.try_into()
.map_err(|e| format!("error converting supplied value for title: {e}"));
self
}
pub fn width<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.width = value
.try_into()
.map_err(|e| format!("error converting supplied value for width: {e}"));
self
}
}
impl ::std::convert::TryFrom<ChatCompletionResponsePayloadImagesItem>
for super::ChatCompletionResponsePayloadImagesItem {
type Error = super::error::ConversionError;
fn try_from(
value: ChatCompletionResponsePayloadImagesItem,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
height: value.height?,
image_url: value.image_url?,
origin_url: value.origin_url?,
title: value.title?,
width: value.width?,
})
}
}
impl ::std::convert::From<super::ChatCompletionResponsePayloadImagesItem>
for ChatCompletionResponsePayloadImagesItem {
fn from(value: super::ChatCompletionResponsePayloadImagesItem) -> Self {
Self {
height: Ok(value.height),
image_url: Ok(value.image_url),
origin_url: Ok(value.origin_url),
title: Ok(value.title),
width: Ok(value.width),
}
}
}
#[derive(Clone, Debug)]
pub struct ChatCompletionResponsePayloadSearchResultsItem {
date: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
last_updated: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
snippet: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
source: ::std::result::Result<
::std::option::Option<
super::ChatCompletionResponsePayloadSearchResultsItemSource,
>,
::std::string::String,
>,
title: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
url: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for ChatCompletionResponsePayloadSearchResultsItem {
fn default() -> Self {
Self {
date: Ok(Default::default()),
last_updated: Ok(Default::default()),
snippet: Ok(Default::default()),
source: Ok(Default::default()),
title: Ok(Default::default()),
url: Ok(Default::default()),
}
}
}
impl ChatCompletionResponsePayloadSearchResultsItem {
pub fn date<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.date = value
.try_into()
.map_err(|e| format!("error converting supplied value for date: {e}"));
self
}
pub fn last_updated<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.last_updated = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for last_updated: {e}")
});
self
}
pub fn snippet<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.snippet = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for snippet: {e}")
});
self
}
pub fn source<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<
super::ChatCompletionResponsePayloadSearchResultsItemSource,
>,
>,
T::Error: ::std::fmt::Display,
{
self.source = value
.try_into()
.map_err(|e| format!("error converting supplied value for source: {e}"));
self
}
pub fn title<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.title = value
.try_into()
.map_err(|e| format!("error converting supplied value for title: {e}"));
self
}
pub fn url<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.url = value
.try_into()
.map_err(|e| format!("error converting supplied value for url: {e}"));
self
}
}
impl ::std::convert::TryFrom<ChatCompletionResponsePayloadSearchResultsItem>
for super::ChatCompletionResponsePayloadSearchResultsItem {
type Error = super::error::ConversionError;
fn try_from(
value: ChatCompletionResponsePayloadSearchResultsItem,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
date: value.date?,
last_updated: value.last_updated?,
snippet: value.snippet?,
source: value.source?,
title: value.title?,
url: value.url?,
})
}
}
impl ::std::convert::From<super::ChatCompletionResponsePayloadSearchResultsItem>
for ChatCompletionResponsePayloadSearchResultsItem {
fn from(value: super::ChatCompletionResponsePayloadSearchResultsItem) -> Self {
Self {
date: Ok(value.date),
last_updated: Ok(value.last_updated),
snippet: Ok(value.snippet),
source: Ok(value.source),
title: Ok(value.title),
url: Ok(value.url),
}
}
}
#[derive(Clone, Debug)]
pub struct Output {
completed_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
created_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
detail: ::std::result::Result<
::std::vec::Vec<super::OutputDetailItem>,
::std::string::String,
>,
error_message: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
failed_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
model: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
response: ::std::result::Result<
::std::option::Option<super::ChatCompletionResponsePayload>,
::std::string::String,
>,
started_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
status: ::std::result::Result<
::std::option::Option<super::OutputStatus>,
::std::string::String,
>,
}
impl ::std::default::Default for Output {
fn default() -> Self {
Self {
completed_at: Ok(Default::default()),
created_at: Ok(Default::default()),
detail: Ok(Default::default()),
error_message: Ok(Default::default()),
failed_at: Ok(Default::default()),
id: Ok(Default::default()),
model: Ok(Default::default()),
response: Ok(Default::default()),
started_at: Ok(Default::default()),
status: Ok(Default::default()),
}
}
}
impl Output {
pub fn completed_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.completed_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for completed_at: {e}")
});
self
}
pub fn created_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.created_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for created_at: {e}")
});
self
}
pub fn detail<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::OutputDetailItem>>,
T::Error: ::std::fmt::Display,
{
self.detail = value
.try_into()
.map_err(|e| format!("error converting supplied value for detail: {e}"));
self
}
pub fn error_message<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.error_message = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for error_message: {e}")
});
self
}
pub fn failed_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.failed_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for failed_at: {e}")
});
self
}
pub fn id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.id = value
.try_into()
.map_err(|e| format!("error converting supplied value for id: {e}"));
self
}
pub fn model<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.model = value
.try_into()
.map_err(|e| format!("error converting supplied value for model: {e}"));
self
}
pub fn response<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<super::ChatCompletionResponsePayload>,
>,
T::Error: ::std::fmt::Display,
{
self.response = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for response: {e}")
});
self
}
pub fn started_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.started_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for started_at: {e}")
});
self
}
pub fn status<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::OutputStatus>>,
T::Error: ::std::fmt::Display,
{
self.status = value
.try_into()
.map_err(|e| format!("error converting supplied value for status: {e}"));
self
}
}
impl ::std::convert::TryFrom<Output> for super::Output {
type Error = super::error::ConversionError;
fn try_from(
value: Output,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
completed_at: value.completed_at?,
created_at: value.created_at?,
detail: value.detail?,
error_message: value.error_message?,
failed_at: value.failed_at?,
id: value.id?,
model: value.model?,
response: value.response?,
started_at: value.started_at?,
status: value.status?,
})
}
}
impl ::std::convert::From<super::Output> for Output {
fn from(value: super::Output) -> Self {
Self {
completed_at: Ok(value.completed_at),
created_at: Ok(value.created_at),
detail: Ok(value.detail),
error_message: Ok(value.error_message),
failed_at: Ok(value.failed_at),
id: Ok(value.id),
model: Ok(value.model),
response: Ok(value.response),
started_at: Ok(value.started_at),
status: Ok(value.status),
}
}
}
#[derive(Clone, Debug)]
pub struct OutputDetailItem {
loc: ::std::result::Result<
::std::vec::Vec<::std::string::String>,
::std::string::String,
>,
msg: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
type_: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for OutputDetailItem {
fn default() -> Self {
Self {
loc: Ok(Default::default()),
msg: Ok(Default::default()),
type_: Ok(Default::default()),
}
}
}
impl OutputDetailItem {
pub fn loc<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.loc = value
.try_into()
.map_err(|e| format!("error converting supplied value for loc: {e}"));
self
}
pub fn msg<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.msg = value
.try_into()
.map_err(|e| format!("error converting supplied value for msg: {e}"));
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
}
impl ::std::convert::TryFrom<OutputDetailItem> for super::OutputDetailItem {
type Error = super::error::ConversionError;
fn try_from(
value: OutputDetailItem,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
loc: value.loc?,
msg: value.msg?,
type_: value.type_?,
})
}
}
impl ::std::convert::From<super::OutputDetailItem> for OutputDetailItem {
fn from(value: super::OutputDetailItem) -> Self {
Self {
loc: Ok(value.loc),
msg: Ok(value.msg),
type_: Ok(value.type_),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
}
/// Where each field of `Input` goes in the request.
pub const ROUTING: ::one::Routing = ::one::Routing { routes: &[::one::Route { field: "apiRequest", part: ::one::Part::Path, key: Some("apiRequest") }], required_parts: &[::one::Part::Path] };
/// Builds the `get_async_chat_completion_response` action.
///
/// # Example input
/// ```json
/// {
/// "apiRequest": "req_abc123"
/// }
/// ```
pub fn build(input: Input) -> ::std::result::Result<Operation<output::Output>, Error> {
::std::result::Result::Ok(Operation::action("conn_mod_def::GJ6CZpCyaCE::92w3q2h1RBy0zJ6NmDUWRg", Method::GET, "/v1/async/sonar/{{apiRequest}}").with_routed(&input, &ROUTING)?
.merge_headers(::serde_json::from_str("{\"Accept\":\"application/json\"}").map_err(Error::Decode)?).returns::<output::Output>())
}
impl IntoOperation for Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
build(self)
}
}
impl IntoOperation for builder::Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
Input::try_from(self).map_err(|error| Error::InvalidInput(::std::boxed::Box::new(error))).and_then(build)
}
}
}
/// Starts building the `get_async_chat_completion_response` action's input; pass the builder to `run`.
pub fn get_async_chat_completion_response() -> get_async_chat_completion_response::builder::Input {
get_async_chat_completion_response::builder::Input::default()
}
pub mod search_web {
use ::one::{Error, IntoOperation, Method, Operation};
///Searches the web for the given query and returns a list of relevant web pages with extracted snippets and optional date metadata.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct Input {
///ISO 3166-1 alpha-2 country code.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub country: ::std::option::Option<InputCountry>,
///Filter results to pages last updated after this value. Format not specified in source.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub last_updated_after_filter: ::std::option::Option<::std::string::String>,
///Filter results to pages last updated before this value. Format not specified in source.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub last_updated_before_filter: ::std::option::Option<::std::string::String>,
///Maximum number of results to return. Default: 10.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub max_results: ::std::option::Option<::std::num::NonZeroU64>,
///Maximum tokens for context. Default: 10000.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub max_tokens: ::std::option::Option<::std::num::NonZeroU64>,
///Maximum tokens per page. Default: 4096.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub max_tokens_per_page: ::std::option::Option<::std::num::NonZeroU64>,
///Search query text. Can be a single string or an array of strings.
pub query: InputQuery,
///Filter results to pages with dates after this value. Format not specified in source.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub search_after_date_filter: ::std::option::Option<::std::string::String>,
///Filter results to pages with dates before this value. Format not specified in source.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub search_before_date_filter: ::std::option::Option<::std::string::String>,
///Filter results to specific domain(s).
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub search_domain_filter: ::std::vec::Vec<::std::string::String>,
///Filter results by language(s).
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub search_language_filter: ::std::vec::Vec<::std::string::String>,
///Recency filter.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub search_recency_filter: ::std::option::Option<InputSearchRecencyFilter>,
}
impl Input {
pub fn builder() -> builder::Input {
Default::default()
}
}
///ISO 3166-1 alpha-2 country code.
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct InputCountry(::std::string::String);
impl ::std::ops::Deref for InputCountry {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<InputCountry> for ::std::string::String {
fn from(value: InputCountry) -> Self {
value.0
}
}
impl ::std::str::FromStr for InputCountry {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
::std::convert::TryFrom::try_from(value)
}
}
impl ::std::convert::TryFrom<&str> for InputCountry {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 2usize {
return Err("longer than 2 characters".into());
}
if value.chars().count() < 2usize {
return Err("shorter than 2 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<::std::string::String> for InputCountry {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
::std::convert::TryFrom::try_from(value.as_str())
}
}
impl<'de> ::serde::Deserialize<'de> for InputCountry {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::convert::TryFrom::try_from(
::std::string::String::deserialize(deserializer)?,
)
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///Search query text. Can be a single string or an array of strings.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(untagged)]
pub enum InputQuery {
String(::std::string::String),
Array(::std::vec::Vec<::std::string::String>),
}
impl ::std::convert::From<::std::vec::Vec<::std::string::String>> for InputQuery {
fn from(value: ::std::vec::Vec<::std::string::String>) -> Self {
Self::Array(value)
}
}
///Recency filter.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum InputSearchRecencyFilter {
#[serde(rename = "hour")]
Hour,
#[serde(rename = "day")]
Day,
#[serde(rename = "week")]
Week,
#[serde(rename = "month")]
Month,
#[serde(rename = "year")]
Year,
}
impl ::std::fmt::Display for InputSearchRecencyFilter {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Hour => f.write_str("hour"),
Self::Day => f.write_str("day"),
Self::Week => f.write_str("week"),
Self::Month => f.write_str("month"),
Self::Year => f.write_str("year"),
}
}
}
impl ::std::str::FromStr for InputSearchRecencyFilter {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"hour" => Ok(Self::Hour),
"day" => Ok(Self::Day),
"week" => Ok(Self::Week),
"month" => Ok(Self::Month),
"year" => Ok(Self::Year),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for InputSearchRecencyFilter {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for InputSearchRecencyFilter {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Input {
country: ::std::result::Result<
::std::option::Option<super::InputCountry>,
::std::string::String,
>,
last_updated_after_filter: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
last_updated_before_filter: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
max_results: ::std::result::Result<
::std::option::Option<::std::num::NonZeroU64>,
::std::string::String,
>,
max_tokens: ::std::result::Result<
::std::option::Option<::std::num::NonZeroU64>,
::std::string::String,
>,
max_tokens_per_page: ::std::result::Result<
::std::option::Option<::std::num::NonZeroU64>,
::std::string::String,
>,
query: ::std::result::Result<super::InputQuery, ::std::string::String>,
search_after_date_filter: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
search_before_date_filter: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
search_domain_filter: ::std::result::Result<
::std::vec::Vec<::std::string::String>,
::std::string::String,
>,
search_language_filter: ::std::result::Result<
::std::vec::Vec<::std::string::String>,
::std::string::String,
>,
search_recency_filter: ::std::result::Result<
::std::option::Option<super::InputSearchRecencyFilter>,
::std::string::String,
>,
}
impl ::std::default::Default for Input {
fn default() -> Self {
Self {
country: Ok(Default::default()),
last_updated_after_filter: Ok(Default::default()),
last_updated_before_filter: Ok(Default::default()),
max_results: Ok(Default::default()),
max_tokens: Ok(Default::default()),
max_tokens_per_page: Ok(Default::default()),
query: Err("no value supplied for query".to_string()),
search_after_date_filter: Ok(Default::default()),
search_before_date_filter: Ok(Default::default()),
search_domain_filter: Ok(Default::default()),
search_language_filter: Ok(Default::default()),
search_recency_filter: Ok(Default::default()),
}
}
}
impl Input {
pub fn country<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::InputCountry>>,
T::Error: ::std::fmt::Display,
{
self.country = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for country: {e}")
});
self
}
pub fn last_updated_after_filter<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.last_updated_after_filter = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for last_updated_after_filter: {e}"
)
});
self
}
pub fn last_updated_before_filter<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.last_updated_before_filter = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for last_updated_before_filter: {e}"
)
});
self
}
pub fn max_results<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::num::NonZeroU64>>,
T::Error: ::std::fmt::Display,
{
self.max_results = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for max_results: {e}")
});
self
}
pub fn max_tokens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::num::NonZeroU64>>,
T::Error: ::std::fmt::Display,
{
self.max_tokens = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for max_tokens: {e}")
});
self
}
pub fn max_tokens_per_page<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::num::NonZeroU64>>,
T::Error: ::std::fmt::Display,
{
self.max_tokens_per_page = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for max_tokens_per_page: {e}"
)
});
self
}
pub fn query<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::InputQuery>,
T::Error: ::std::fmt::Display,
{
self.query = value
.try_into()
.map_err(|e| format!("error converting supplied value for query: {e}"));
self
}
pub fn search_after_date_filter<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.search_after_date_filter = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for search_after_date_filter: {e}"
)
});
self
}
pub fn search_before_date_filter<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.search_before_date_filter = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for search_before_date_filter: {e}"
)
});
self
}
pub fn search_domain_filter<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.search_domain_filter = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for search_domain_filter: {e}"
)
});
self
}
pub fn search_language_filter<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.search_language_filter = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for search_language_filter: {e}"
)
});
self
}
pub fn search_recency_filter<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<super::InputSearchRecencyFilter>,
>,
T::Error: ::std::fmt::Display,
{
self.search_recency_filter = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for search_recency_filter: {e}"
)
});
self
}
}
impl ::std::convert::TryFrom<Input> for super::Input {
type Error = super::error::ConversionError;
fn try_from(
value: Input,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
country: value.country?,
last_updated_after_filter: value.last_updated_after_filter?,
last_updated_before_filter: value.last_updated_before_filter?,
max_results: value.max_results?,
max_tokens: value.max_tokens?,
max_tokens_per_page: value.max_tokens_per_page?,
query: value.query?,
search_after_date_filter: value.search_after_date_filter?,
search_before_date_filter: value.search_before_date_filter?,
search_domain_filter: value.search_domain_filter?,
search_language_filter: value.search_language_filter?,
search_recency_filter: value.search_recency_filter?,
})
}
}
impl ::std::convert::From<super::Input> for Input {
fn from(value: super::Input) -> Self {
Self {
country: Ok(value.country),
last_updated_after_filter: Ok(value.last_updated_after_filter),
last_updated_before_filter: Ok(value.last_updated_before_filter),
max_results: Ok(value.max_results),
max_tokens: Ok(value.max_tokens),
max_tokens_per_page: Ok(value.max_tokens_per_page),
query: Ok(value.query),
search_after_date_filter: Ok(value.search_after_date_filter),
search_before_date_filter: Ok(value.search_before_date_filter),
search_domain_filter: Ok(value.search_domain_filter),
search_language_filter: Ok(value.search_language_filter),
search_recency_filter: Ok(value.search_recency_filter),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
pub mod output {
///Response structure for web search, including success and validation error responses.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Output {
///Validation error details returned on 422 Client Error.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub detail: ::std::vec::Vec<OutputDetailItem>,
///Identifier for this search request/response.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub id: ::std::option::Option<::std::string::String>,
///Array of search results.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub results: ::std::vec::Vec<OutputResultsItem>,
///Server time (if provided).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub server_time: ::std::option::Option<::std::string::String>,
}
impl Output {
pub fn builder() -> builder::Output {
Default::default()
}
}
///`OutputDetailItem`
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct OutputDetailItem {
///Location of the validation error.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub loc: ::std::vec::Vec<::std::string::String>,
///Validation error message.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub msg: ::std::option::Option<::std::string::String>,
///Validation error type.
#[serde(rename = "type", skip_serializing_if = "::std::option::Option::is_none")]
pub type_: ::std::option::Option<::std::string::String>,
}
impl OutputDetailItem {
pub fn builder() -> builder::OutputDetailItem {
Default::default()
}
}
///`OutputResultsItem`
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct OutputResultsItem {
///Page date (if available).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub date: ::std::option::Option<::std::string::String>,
///Page last-updated timestamp (if available).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub last_updated: ::std::option::Option<::std::string::String>,
///Content snippet extracted from the page.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub snippet: ::std::option::Option<::std::string::String>,
///Title of the page.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub title: ::std::option::Option<::std::string::String>,
///URL of the page.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub url: ::std::option::Option<::std::string::String>,
}
impl OutputResultsItem {
pub fn builder() -> builder::OutputResultsItem {
Default::default()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Output {
detail: ::std::result::Result<
::std::vec::Vec<super::OutputDetailItem>,
::std::string::String,
>,
id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
results: ::std::result::Result<
::std::vec::Vec<super::OutputResultsItem>,
::std::string::String,
>,
server_time: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for Output {
fn default() -> Self {
Self {
detail: Ok(Default::default()),
id: Ok(Default::default()),
results: Ok(Default::default()),
server_time: Ok(Default::default()),
}
}
}
impl Output {
pub fn detail<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::OutputDetailItem>>,
T::Error: ::std::fmt::Display,
{
self.detail = value
.try_into()
.map_err(|e| format!("error converting supplied value for detail: {e}"));
self
}
pub fn id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.id = value
.try_into()
.map_err(|e| format!("error converting supplied value for id: {e}"));
self
}
pub fn results<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::OutputResultsItem>>,
T::Error: ::std::fmt::Display,
{
self.results = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for results: {e}")
});
self
}
pub fn server_time<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.server_time = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for server_time: {e}")
});
self
}
}
impl ::std::convert::TryFrom<Output> for super::Output {
type Error = super::error::ConversionError;
fn try_from(
value: Output,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
detail: value.detail?,
id: value.id?,
results: value.results?,
server_time: value.server_time?,
})
}
}
impl ::std::convert::From<super::Output> for Output {
fn from(value: super::Output) -> Self {
Self {
detail: Ok(value.detail),
id: Ok(value.id),
results: Ok(value.results),
server_time: Ok(value.server_time),
}
}
}
#[derive(Clone, Debug)]
pub struct OutputDetailItem {
loc: ::std::result::Result<
::std::vec::Vec<::std::string::String>,
::std::string::String,
>,
msg: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
type_: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for OutputDetailItem {
fn default() -> Self {
Self {
loc: Ok(Default::default()),
msg: Ok(Default::default()),
type_: Ok(Default::default()),
}
}
}
impl OutputDetailItem {
pub fn loc<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.loc = value
.try_into()
.map_err(|e| format!("error converting supplied value for loc: {e}"));
self
}
pub fn msg<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.msg = value
.try_into()
.map_err(|e| format!("error converting supplied value for msg: {e}"));
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
}
impl ::std::convert::TryFrom<OutputDetailItem> for super::OutputDetailItem {
type Error = super::error::ConversionError;
fn try_from(
value: OutputDetailItem,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
loc: value.loc?,
msg: value.msg?,
type_: value.type_?,
})
}
}
impl ::std::convert::From<super::OutputDetailItem> for OutputDetailItem {
fn from(value: super::OutputDetailItem) -> Self {
Self {
loc: Ok(value.loc),
msg: Ok(value.msg),
type_: Ok(value.type_),
}
}
}
#[derive(Clone, Debug)]
pub struct OutputResultsItem {
date: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
last_updated: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
snippet: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
title: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
url: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for OutputResultsItem {
fn default() -> Self {
Self {
date: Ok(Default::default()),
last_updated: Ok(Default::default()),
snippet: Ok(Default::default()),
title: Ok(Default::default()),
url: Ok(Default::default()),
}
}
}
impl OutputResultsItem {
pub fn date<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.date = value
.try_into()
.map_err(|e| format!("error converting supplied value for date: {e}"));
self
}
pub fn last_updated<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.last_updated = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for last_updated: {e}")
});
self
}
pub fn snippet<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.snippet = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for snippet: {e}")
});
self
}
pub fn title<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.title = value
.try_into()
.map_err(|e| format!("error converting supplied value for title: {e}"));
self
}
pub fn url<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.url = value
.try_into()
.map_err(|e| format!("error converting supplied value for url: {e}"));
self
}
}
impl ::std::convert::TryFrom<OutputResultsItem> for super::OutputResultsItem {
type Error = super::error::ConversionError;
fn try_from(
value: OutputResultsItem,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
date: value.date?,
last_updated: value.last_updated?,
snippet: value.snippet?,
title: value.title?,
url: value.url?,
})
}
}
impl ::std::convert::From<super::OutputResultsItem> for OutputResultsItem {
fn from(value: super::OutputResultsItem) -> Self {
Self {
date: Ok(value.date),
last_updated: Ok(value.last_updated),
snippet: Ok(value.snippet),
title: Ok(value.title),
url: Ok(value.url),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
}
/// Where each field of `Input` goes in the request.
pub const ROUTING: ::one::Routing = ::one::Routing { routes: &[::one::Route { field: "country", part: ::one::Part::Body, key: Some("country") }, ::one::Route { field: "last_updated_after_filter", part: ::one::Part::Body, key: Some("last_updated_after_filter") }, ::one::Route { field: "last_updated_before_filter", part: ::one::Part::Body, key: Some("last_updated_before_filter") }, ::one::Route { field: "max_results", part: ::one::Part::Body, key: Some("max_results") }, ::one::Route { field: "max_tokens", part: ::one::Part::Body, key: Some("max_tokens") }, ::one::Route { field: "max_tokens_per_page", part: ::one::Part::Body, key: Some("max_tokens_per_page") }, ::one::Route { field: "query", part: ::one::Part::Body, key: Some("query") }, ::one::Route { field: "search_after_date_filter", part: ::one::Part::Body, key: Some("search_after_date_filter") }, ::one::Route { field: "search_before_date_filter", part: ::one::Part::Body, key: Some("search_before_date_filter") }, ::one::Route { field: "search_domain_filter", part: ::one::Part::Body, key: Some("search_domain_filter") }, ::one::Route { field: "search_language_filter", part: ::one::Part::Body, key: Some("search_language_filter") }, ::one::Route { field: "search_recency_filter", part: ::one::Part::Body, key: Some("search_recency_filter") }], required_parts: &[::one::Part::Body] };
/// Builds the `search_web` action.
///
/// # Example input
/// ```json
/// {
/// "country": "US",
/// "last_updated_after_filter": "2025-01-01T00:00:00Z",
/// "last_updated_before_filter": "2025-12-31T23:59:59Z",
/// "max_results": 10,
/// "max_tokens": 10000,
/// "max_tokens_per_page": 4096,
/// "query": [
/// "site:who.int mpox guidance",
/// "CDC mpox vaccine recommendations"
/// ],
/// "search_after_date_filter": "2025-01-01",
/// "search_before_date_filter": "2025-12-31",
/// "search_domain_filter": [
/// "who.int",
/// "cdc.gov"
/// ],
/// "search_language_filter": [
/// "en"
/// ],
/// "search_recency_filter": "month"
/// }
/// ```
pub fn build(input: Input) -> ::std::result::Result<Operation<output::Output>, Error> {
::std::result::Result::Ok(Operation::action("conn_mod_def::GJ6CZpg0YYw::53LshJC5TNOM_Bv6M_ptHw", Method::POST, "/search").with_routed(&input, &ROUTING)?
.merge_headers(::serde_json::from_str("{\"Accept\":\"application/json\",\"Content-Type\":\"application/json\"}").map_err(Error::Decode)?).returns::<output::Output>())
}
impl IntoOperation for Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
build(self)
}
}
impl IntoOperation for builder::Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
Input::try_from(self).map_err(|error| Error::InvalidInput(::std::boxed::Box::new(error))).and_then(build)
}
}
}
/// Starts building the `search_web` action's input; pass the builder to `run`.
pub fn search_web() -> search_web::builder::Input {
search_web::builder::Input::default()
}
pub mod list_async_chat_completions_authenticated_user {
use ::one::{Error, IntoOperation, Method, Operation};
///Retrieves a list of all asynchronous chat completion requests for the current user, including each request’s timestamps, model, and processing status.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
#[serde(deny_unknown_fields)]
pub struct Input {}
impl Input {
pub fn builder() -> builder::Input {
Default::default()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Input {}
impl ::std::default::Default for Input {
fn default() -> Self {
Self {}
}
}
impl Input {}
impl ::std::convert::TryFrom<Input> for super::Input {
type Error = super::error::ConversionError;
fn try_from(
_value: Input,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {})
}
}
impl ::std::convert::From<super::Input> for Input {
fn from(_value: super::Input) -> Self {
Self {}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
pub mod output {
///An asynchronous chat completion request entry.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct AsyncChatCompletionRequest {
///Unix timestamp (seconds) when processing completed successfully, if completed.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub completed_at: ::std::option::Option<i64>,
///Unix timestamp (seconds) when the request was created.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub created_at: ::std::option::Option<i64>,
///Unix timestamp (seconds) when processing failed, if failed.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub failed_at: ::std::option::Option<i64>,
///Unique identifier for the async request.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub id: ::std::option::Option<::std::string::String>,
///Model used for the request.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub model: ::std::option::Option<::std::string::String>,
///Unix timestamp (seconds) when processing started, if started.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub started_at: ::std::option::Option<i64>,
///Current processing status of the async request (AsyncProcessingStatus enum; exact values not provided in scraped content).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub status: ::std::option::Option<::std::string::String>,
}
impl AsyncChatCompletionRequest {
pub fn builder() -> builder::AsyncChatCompletionRequest {
Default::default()
}
}
///Response returned when listing asynchronous chat completion requests for the authenticated user.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Output {
///Validation error details returned for an unprocessable request.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub detail: ::std::vec::Vec<ValidationErrorDetail>,
///Pagination token for retrieving the next page of results (if any).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub next_token: ::std::option::Option<::std::string::String>,
///List of asynchronous chat completion requests.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub requests: ::std::vec::Vec<AsyncChatCompletionRequest>,
}
impl Output {
pub fn builder() -> builder::Output {
Default::default()
}
}
///An individual validation error entry.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct ValidationErrorDetail {
///Location of the validation error.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub loc: ::std::vec::Vec<::std::string::String>,
///Validation error message.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub msg: ::std::option::Option<::std::string::String>,
///Validation error type.
#[serde(rename = "type", skip_serializing_if = "::std::option::Option::is_none")]
pub type_: ::std::option::Option<::std::string::String>,
}
impl ValidationErrorDetail {
pub fn builder() -> builder::ValidationErrorDetail {
Default::default()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct AsyncChatCompletionRequest {
completed_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
created_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
failed_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
model: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
started_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
status: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for AsyncChatCompletionRequest {
fn default() -> Self {
Self {
completed_at: Ok(Default::default()),
created_at: Ok(Default::default()),
failed_at: Ok(Default::default()),
id: Ok(Default::default()),
model: Ok(Default::default()),
started_at: Ok(Default::default()),
status: Ok(Default::default()),
}
}
}
impl AsyncChatCompletionRequest {
pub fn completed_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.completed_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for completed_at: {e}")
});
self
}
pub fn created_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.created_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for created_at: {e}")
});
self
}
pub fn failed_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.failed_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for failed_at: {e}")
});
self
}
pub fn id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.id = value
.try_into()
.map_err(|e| format!("error converting supplied value for id: {e}"));
self
}
pub fn model<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.model = value
.try_into()
.map_err(|e| format!("error converting supplied value for model: {e}"));
self
}
pub fn started_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.started_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for started_at: {e}")
});
self
}
pub fn status<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.status = value
.try_into()
.map_err(|e| format!("error converting supplied value for status: {e}"));
self
}
}
impl ::std::convert::TryFrom<AsyncChatCompletionRequest>
for super::AsyncChatCompletionRequest {
type Error = super::error::ConversionError;
fn try_from(
value: AsyncChatCompletionRequest,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
completed_at: value.completed_at?,
created_at: value.created_at?,
failed_at: value.failed_at?,
id: value.id?,
model: value.model?,
started_at: value.started_at?,
status: value.status?,
})
}
}
impl ::std::convert::From<super::AsyncChatCompletionRequest>
for AsyncChatCompletionRequest {
fn from(value: super::AsyncChatCompletionRequest) -> Self {
Self {
completed_at: Ok(value.completed_at),
created_at: Ok(value.created_at),
failed_at: Ok(value.failed_at),
id: Ok(value.id),
model: Ok(value.model),
started_at: Ok(value.started_at),
status: Ok(value.status),
}
}
}
#[derive(Clone, Debug)]
pub struct Output {
detail: ::std::result::Result<
::std::vec::Vec<super::ValidationErrorDetail>,
::std::string::String,
>,
next_token: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
requests: ::std::result::Result<
::std::vec::Vec<super::AsyncChatCompletionRequest>,
::std::string::String,
>,
}
impl ::std::default::Default for Output {
fn default() -> Self {
Self {
detail: Ok(Default::default()),
next_token: Ok(Default::default()),
requests: Ok(Default::default()),
}
}
}
impl Output {
pub fn detail<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::ValidationErrorDetail>>,
T::Error: ::std::fmt::Display,
{
self.detail = value
.try_into()
.map_err(|e| format!("error converting supplied value for detail: {e}"));
self
}
pub fn next_token<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.next_token = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for next_token: {e}")
});
self
}
pub fn requests<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::vec::Vec<super::AsyncChatCompletionRequest>,
>,
T::Error: ::std::fmt::Display,
{
self.requests = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for requests: {e}")
});
self
}
}
impl ::std::convert::TryFrom<Output> for super::Output {
type Error = super::error::ConversionError;
fn try_from(
value: Output,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
detail: value.detail?,
next_token: value.next_token?,
requests: value.requests?,
})
}
}
impl ::std::convert::From<super::Output> for Output {
fn from(value: super::Output) -> Self {
Self {
detail: Ok(value.detail),
next_token: Ok(value.next_token),
requests: Ok(value.requests),
}
}
}
#[derive(Clone, Debug)]
pub struct ValidationErrorDetail {
loc: ::std::result::Result<
::std::vec::Vec<::std::string::String>,
::std::string::String,
>,
msg: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
type_: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for ValidationErrorDetail {
fn default() -> Self {
Self {
loc: Ok(Default::default()),
msg: Ok(Default::default()),
type_: Ok(Default::default()),
}
}
}
impl ValidationErrorDetail {
pub fn loc<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.loc = value
.try_into()
.map_err(|e| format!("error converting supplied value for loc: {e}"));
self
}
pub fn msg<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.msg = value
.try_into()
.map_err(|e| format!("error converting supplied value for msg: {e}"));
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
}
impl ::std::convert::TryFrom<ValidationErrorDetail>
for super::ValidationErrorDetail {
type Error = super::error::ConversionError;
fn try_from(
value: ValidationErrorDetail,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
loc: value.loc?,
msg: value.msg?,
type_: value.type_?,
})
}
}
impl ::std::convert::From<super::ValidationErrorDetail> for ValidationErrorDetail {
fn from(value: super::ValidationErrorDetail) -> Self {
Self {
loc: Ok(value.loc),
msg: Ok(value.msg),
type_: Ok(value.type_),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
}
/// Where each field of `Input` goes in the request.
pub const ROUTING: ::one::Routing = ::one::Routing { routes: &[], required_parts: &[] };
/// Builds the `list_async_chat_completions_authenticated_user` action.
///
/// # Example input
/// ```json
/// {}
/// ```
pub fn build(input: Input) -> ::std::result::Result<Operation<output::Output>, Error> {
::std::result::Result::Ok(Operation::action("conn_mod_def::GJ6CZphdHPE::77KKEaKnSkmhEM2ynmq16A", Method::GET, "/v1/async/sonar").with_routed(&input, &ROUTING)?
.merge_headers(::serde_json::from_str("{\"Accept\":\"application/json\"}").map_err(Error::Decode)?).returns::<output::Output>())
}
impl IntoOperation for Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
build(self)
}
}
impl IntoOperation for builder::Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
Input::try_from(self).map_err(|error| Error::InvalidInput(::std::boxed::Box::new(error))).and_then(build)
}
}
}
/// Starts building the `list_async_chat_completions_authenticated_user` action's input; pass the builder to `run`.
pub fn list_async_chat_completions_authenticated_user() -> list_async_chat_completions_authenticated_user::builder::Input {
list_async_chat_completions_authenticated_user::builder::Input::default()
}
pub mod create_contextualized_embeddings {
use ::one::{Error, IntoOperation, Method, Operation};
///Generates contextualized embeddings for chunked documents. Chunks within the same document are embedded with document-level context awareness, improving retrieval quality for document-based applications.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct Input {
///Output embedding dimensionality (Matryoshka). Valid ranges depend on model: for pplx-embed-context-v1-0.6b → 128–1024; for pplx-embed-context-v1-4b → 128–2560. Defaults to full dimensions (1024 for 0.6b, 2560 for 4b).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub dimensions: ::std::option::Option<i64>,
///Output encoding format for embeddings. Default: base64_int8. base64_int8 decodes to signed int8 array (length = dimensions). base64_binary decodes to packed bits (length = dimensions / 8 bytes).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub encoding_format: ::std::option::Option<InputEncodingFormat>,
///Nested array of document chunks. Each inner array represents one document, containing chunk strings for that document. Constraints: max 512 documents; total chunks across all documents ≤ 16,000; total tokens per document ≤ 32K; all chunks in a request combined ≤ 120,000 tokens; empty strings not allowed.
pub input: ::std::vec::Vec<::std::vec::Vec<InputInputItemItem>>,
///Contextualized embedding model.
pub model: InputModel,
}
impl Input {
pub fn builder() -> builder::Input {
Default::default()
}
}
///Output encoding format for embeddings. Default: base64_int8. base64_int8 decodes to signed int8 array (length = dimensions). base64_binary decodes to packed bits (length = dimensions / 8 bytes).
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum InputEncodingFormat {
#[serde(rename = "base64_int8")]
Base64Int8,
#[serde(rename = "base64_binary")]
Base64Binary,
}
impl ::std::fmt::Display for InputEncodingFormat {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Base64Int8 => f.write_str("base64_int8"),
Self::Base64Binary => f.write_str("base64_binary"),
}
}
}
impl ::std::str::FromStr for InputEncodingFormat {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"base64_int8" => Ok(Self::Base64Int8),
"base64_binary" => Ok(Self::Base64Binary),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for InputEncodingFormat {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for InputEncodingFormat {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///A non-empty text chunk.
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct InputInputItemItem(::std::string::String);
impl ::std::ops::Deref for InputInputItemItem {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<InputInputItemItem> for ::std::string::String {
fn from(value: InputInputItemItem) -> Self {
value.0
}
}
impl ::std::str::FromStr for InputInputItemItem {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
::std::convert::TryFrom::try_from(value)
}
}
impl ::std::convert::TryFrom<&str> for InputInputItemItem {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<::std::string::String> for InputInputItemItem {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
::std::convert::TryFrom::try_from(value.as_str())
}
}
impl<'de> ::serde::Deserialize<'de> for InputInputItemItem {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::convert::TryFrom::try_from(
::std::string::String::deserialize(deserializer)?,
)
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///Contextualized embedding model.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum InputModel {
#[serde(rename = "pplx-embed-context-v1-0.6b")]
PplxEmbedContextV106b,
#[serde(rename = "pplx-embed-context-v1-4b")]
PplxEmbedContextV14b,
}
impl ::std::fmt::Display for InputModel {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::PplxEmbedContextV106b => f.write_str("pplx-embed-context-v1-0.6b"),
Self::PplxEmbedContextV14b => f.write_str("pplx-embed-context-v1-4b"),
}
}
}
impl ::std::str::FromStr for InputModel {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"pplx-embed-context-v1-0.6b" => Ok(Self::PplxEmbedContextV106b),
"pplx-embed-context-v1-4b" => Ok(Self::PplxEmbedContextV14b),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for InputModel {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for InputModel {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Input {
dimensions: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
encoding_format: ::std::result::Result<
::std::option::Option<super::InputEncodingFormat>,
::std::string::String,
>,
input: ::std::result::Result<
::std::vec::Vec<::std::vec::Vec<super::InputInputItemItem>>,
::std::string::String,
>,
model: ::std::result::Result<super::InputModel, ::std::string::String>,
}
impl ::std::default::Default for Input {
fn default() -> Self {
Self {
dimensions: Ok(Default::default()),
encoding_format: Ok(Default::default()),
input: Err("no value supplied for input".to_string()),
model: Err("no value supplied for model".to_string()),
}
}
}
impl Input {
pub fn dimensions<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.dimensions = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for dimensions: {e}")
});
self
}
pub fn encoding_format<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<super::InputEncodingFormat>,
>,
T::Error: ::std::fmt::Display,
{
self.encoding_format = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for encoding_format: {e}")
});
self
}
pub fn input<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::vec::Vec<::std::vec::Vec<super::InputInputItemItem>>,
>,
T::Error: ::std::fmt::Display,
{
self.input = value
.try_into()
.map_err(|e| format!("error converting supplied value for input: {e}"));
self
}
pub fn model<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::InputModel>,
T::Error: ::std::fmt::Display,
{
self.model = value
.try_into()
.map_err(|e| format!("error converting supplied value for model: {e}"));
self
}
}
impl ::std::convert::TryFrom<Input> for super::Input {
type Error = super::error::ConversionError;
fn try_from(
value: Input,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
dimensions: value.dimensions?,
encoding_format: value.encoding_format?,
input: value.input?,
model: value.model?,
})
}
}
impl ::std::convert::From<super::Input> for Input {
fn from(value: super::Input) -> Self {
Self {
dimensions: Ok(value.dimensions),
encoding_format: Ok(value.encoding_format),
input: Ok(value.input),
model: Ok(value.model),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
pub mod output {
///Document-level embedding container.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct ContextualizedEmbeddingResult {
///List of embedding objects for chunks in this document.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub data: ::std::vec::Vec<EmbeddingItem>,
///Index of the document this result corresponds to (matches the outer input array index).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub index: ::std::option::Option<i64>,
///Object type for the document-level embedding container.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub object: ::std::option::Option<::std::string::String>,
}
impl ContextualizedEmbeddingResult {
pub fn builder() -> builder::ContextualizedEmbeddingResult {
Default::default()
}
}
///Cost breakdown.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Cost {
///Currency for cost values. Allowed value shown: USD.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub currency: ::std::option::Option<CostCurrency>,
///Cost for input tokens (USD).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub input_cost: ::std::option::Option<f64>,
///Total cost for the request (USD).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub total_cost: ::std::option::Option<f64>,
}
impl Cost {
pub fn builder() -> builder::Cost {
Default::default()
}
}
///Currency for cost values. Allowed value shown: USD.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum CostCurrency {
#[serde(rename = "USD")]
Usd,
}
impl ::std::fmt::Display for CostCurrency {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Usd => f.write_str("USD"),
}
}
}
impl ::std::str::FromStr for CostCurrency {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"USD" => Ok(Self::Usd),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for CostCurrency {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for CostCurrency {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Embedding object for an individual chunk.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct EmbeddingItem {
///Base64-encoded embedding vector. Interpretation depends on encoding_format.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub embedding: ::std::option::Option<::std::string::String>,
///Index of the chunk within the document (matches the inner array index).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub index: ::std::option::Option<i64>,
///Object type for an embedding item.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub object: ::std::option::Option<::std::string::String>,
}
impl EmbeddingItem {
pub fn builder() -> builder::EmbeddingItem {
Default::default()
}
}
///Response for contextualized embeddings creation, including successful embedding results or validation errors.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Output {
///List of contextualized embedding results, one per input document.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub data: ::std::vec::Vec<ContextualizedEmbeddingResult>,
///Validation error details for 422 Unprocessable Entity responses.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub detail: ::std::vec::Vec<ValidationErrorDetail>,
///Model used to generate embeddings.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub model: ::std::option::Option<::std::string::String>,
///Top-level object type. Example: "list".
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub object: ::std::option::Option<::std::string::String>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub usage: ::std::option::Option<Usage>,
}
impl Output {
pub fn builder() -> builder::Output {
Default::default()
}
}
///Token usage and cost details.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Usage {
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub cost: ::std::option::Option<Cost>,
///Number of tokens in the input texts.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub prompt_tokens: ::std::option::Option<i64>,
///Total tokens processed.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub total_tokens: ::std::option::Option<i64>,
}
impl Usage {
pub fn builder() -> builder::Usage {
Default::default()
}
}
///An individual validation issue.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct ValidationErrorDetail {
///Location of the validation issue.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub loc: ::std::vec::Vec<ValidationErrorDetailLocItem>,
///Validation error message.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub msg: ::std::option::Option<::std::string::String>,
///Validation error type.
#[serde(rename = "type", skip_serializing_if = "::std::option::Option::is_none")]
pub type_: ::std::option::Option<::std::string::String>,
}
impl ValidationErrorDetail {
pub fn builder() -> builder::ValidationErrorDetail {
Default::default()
}
}
///`ValidationErrorDetailLocItem`
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(untagged)]
pub enum ValidationErrorDetailLocItem {
String(::std::string::String),
Integer(i64),
}
impl ::std::fmt::Display for ValidationErrorDetailLocItem {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
Self::String(x) => x.fmt(f),
Self::Integer(x) => x.fmt(f),
}
}
}
impl ::std::convert::From<i64> for ValidationErrorDetailLocItem {
fn from(value: i64) -> Self {
Self::Integer(value)
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct ContextualizedEmbeddingResult {
data: ::std::result::Result<
::std::vec::Vec<super::EmbeddingItem>,
::std::string::String,
>,
index: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
object: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for ContextualizedEmbeddingResult {
fn default() -> Self {
Self {
data: Ok(Default::default()),
index: Ok(Default::default()),
object: Ok(Default::default()),
}
}
}
impl ContextualizedEmbeddingResult {
pub fn data<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::EmbeddingItem>>,
T::Error: ::std::fmt::Display,
{
self.data = value
.try_into()
.map_err(|e| format!("error converting supplied value for data: {e}"));
self
}
pub fn index<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.index = value
.try_into()
.map_err(|e| format!("error converting supplied value for index: {e}"));
self
}
pub fn object<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.object = value
.try_into()
.map_err(|e| format!("error converting supplied value for object: {e}"));
self
}
}
impl ::std::convert::TryFrom<ContextualizedEmbeddingResult>
for super::ContextualizedEmbeddingResult {
type Error = super::error::ConversionError;
fn try_from(
value: ContextualizedEmbeddingResult,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
data: value.data?,
index: value.index?,
object: value.object?,
})
}
}
impl ::std::convert::From<super::ContextualizedEmbeddingResult>
for ContextualizedEmbeddingResult {
fn from(value: super::ContextualizedEmbeddingResult) -> Self {
Self {
data: Ok(value.data),
index: Ok(value.index),
object: Ok(value.object),
}
}
}
#[derive(Clone, Debug)]
pub struct Cost {
currency: ::std::result::Result<
::std::option::Option<super::CostCurrency>,
::std::string::String,
>,
input_cost: ::std::result::Result<
::std::option::Option<f64>,
::std::string::String,
>,
total_cost: ::std::result::Result<
::std::option::Option<f64>,
::std::string::String,
>,
}
impl ::std::default::Default for Cost {
fn default() -> Self {
Self {
currency: Ok(Default::default()),
input_cost: Ok(Default::default()),
total_cost: Ok(Default::default()),
}
}
}
impl Cost {
pub fn currency<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::CostCurrency>>,
T::Error: ::std::fmt::Display,
{
self.currency = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for currency: {e}")
});
self
}
pub fn input_cost<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<f64>>,
T::Error: ::std::fmt::Display,
{
self.input_cost = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for input_cost: {e}")
});
self
}
pub fn total_cost<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<f64>>,
T::Error: ::std::fmt::Display,
{
self.total_cost = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for total_cost: {e}")
});
self
}
}
impl ::std::convert::TryFrom<Cost> for super::Cost {
type Error = super::error::ConversionError;
fn try_from(
value: Cost,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
currency: value.currency?,
input_cost: value.input_cost?,
total_cost: value.total_cost?,
})
}
}
impl ::std::convert::From<super::Cost> for Cost {
fn from(value: super::Cost) -> Self {
Self {
currency: Ok(value.currency),
input_cost: Ok(value.input_cost),
total_cost: Ok(value.total_cost),
}
}
}
#[derive(Clone, Debug)]
pub struct EmbeddingItem {
embedding: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
index: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
object: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for EmbeddingItem {
fn default() -> Self {
Self {
embedding: Ok(Default::default()),
index: Ok(Default::default()),
object: Ok(Default::default()),
}
}
}
impl EmbeddingItem {
pub fn embedding<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.embedding = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for embedding: {e}")
});
self
}
pub fn index<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.index = value
.try_into()
.map_err(|e| format!("error converting supplied value for index: {e}"));
self
}
pub fn object<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.object = value
.try_into()
.map_err(|e| format!("error converting supplied value for object: {e}"));
self
}
}
impl ::std::convert::TryFrom<EmbeddingItem> for super::EmbeddingItem {
type Error = super::error::ConversionError;
fn try_from(
value: EmbeddingItem,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
embedding: value.embedding?,
index: value.index?,
object: value.object?,
})
}
}
impl ::std::convert::From<super::EmbeddingItem> for EmbeddingItem {
fn from(value: super::EmbeddingItem) -> Self {
Self {
embedding: Ok(value.embedding),
index: Ok(value.index),
object: Ok(value.object),
}
}
}
#[derive(Clone, Debug)]
pub struct Output {
data: ::std::result::Result<
::std::vec::Vec<super::ContextualizedEmbeddingResult>,
::std::string::String,
>,
detail: ::std::result::Result<
::std::vec::Vec<super::ValidationErrorDetail>,
::std::string::String,
>,
model: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
object: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
usage: ::std::result::Result<
::std::option::Option<super::Usage>,
::std::string::String,
>,
}
impl ::std::default::Default for Output {
fn default() -> Self {
Self {
data: Ok(Default::default()),
detail: Ok(Default::default()),
model: Ok(Default::default()),
object: Ok(Default::default()),
usage: Ok(Default::default()),
}
}
}
impl Output {
pub fn data<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::vec::Vec<super::ContextualizedEmbeddingResult>,
>,
T::Error: ::std::fmt::Display,
{
self.data = value
.try_into()
.map_err(|e| format!("error converting supplied value for data: {e}"));
self
}
pub fn detail<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::ValidationErrorDetail>>,
T::Error: ::std::fmt::Display,
{
self.detail = value
.try_into()
.map_err(|e| format!("error converting supplied value for detail: {e}"));
self
}
pub fn model<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.model = value
.try_into()
.map_err(|e| format!("error converting supplied value for model: {e}"));
self
}
pub fn object<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.object = value
.try_into()
.map_err(|e| format!("error converting supplied value for object: {e}"));
self
}
pub fn usage<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Usage>>,
T::Error: ::std::fmt::Display,
{
self.usage = value
.try_into()
.map_err(|e| format!("error converting supplied value for usage: {e}"));
self
}
}
impl ::std::convert::TryFrom<Output> for super::Output {
type Error = super::error::ConversionError;
fn try_from(
value: Output,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
data: value.data?,
detail: value.detail?,
model: value.model?,
object: value.object?,
usage: value.usage?,
})
}
}
impl ::std::convert::From<super::Output> for Output {
fn from(value: super::Output) -> Self {
Self {
data: Ok(value.data),
detail: Ok(value.detail),
model: Ok(value.model),
object: Ok(value.object),
usage: Ok(value.usage),
}
}
}
#[derive(Clone, Debug)]
pub struct Usage {
cost: ::std::result::Result<
::std::option::Option<super::Cost>,
::std::string::String,
>,
prompt_tokens: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
total_tokens: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
}
impl ::std::default::Default for Usage {
fn default() -> Self {
Self {
cost: Ok(Default::default()),
prompt_tokens: Ok(Default::default()),
total_tokens: Ok(Default::default()),
}
}
}
impl Usage {
pub fn cost<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Cost>>,
T::Error: ::std::fmt::Display,
{
self.cost = value
.try_into()
.map_err(|e| format!("error converting supplied value for cost: {e}"));
self
}
pub fn prompt_tokens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.prompt_tokens = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for prompt_tokens: {e}")
});
self
}
pub fn total_tokens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.total_tokens = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for total_tokens: {e}")
});
self
}
}
impl ::std::convert::TryFrom<Usage> for super::Usage {
type Error = super::error::ConversionError;
fn try_from(
value: Usage,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
cost: value.cost?,
prompt_tokens: value.prompt_tokens?,
total_tokens: value.total_tokens?,
})
}
}
impl ::std::convert::From<super::Usage> for Usage {
fn from(value: super::Usage) -> Self {
Self {
cost: Ok(value.cost),
prompt_tokens: Ok(value.prompt_tokens),
total_tokens: Ok(value.total_tokens),
}
}
}
#[derive(Clone, Debug)]
pub struct ValidationErrorDetail {
loc: ::std::result::Result<
::std::vec::Vec<super::ValidationErrorDetailLocItem>,
::std::string::String,
>,
msg: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
type_: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for ValidationErrorDetail {
fn default() -> Self {
Self {
loc: Ok(Default::default()),
msg: Ok(Default::default()),
type_: Ok(Default::default()),
}
}
}
impl ValidationErrorDetail {
pub fn loc<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::vec::Vec<super::ValidationErrorDetailLocItem>,
>,
T::Error: ::std::fmt::Display,
{
self.loc = value
.try_into()
.map_err(|e| format!("error converting supplied value for loc: {e}"));
self
}
pub fn msg<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.msg = value
.try_into()
.map_err(|e| format!("error converting supplied value for msg: {e}"));
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
}
impl ::std::convert::TryFrom<ValidationErrorDetail>
for super::ValidationErrorDetail {
type Error = super::error::ConversionError;
fn try_from(
value: ValidationErrorDetail,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
loc: value.loc?,
msg: value.msg?,
type_: value.type_?,
})
}
}
impl ::std::convert::From<super::ValidationErrorDetail> for ValidationErrorDetail {
fn from(value: super::ValidationErrorDetail) -> Self {
Self {
loc: Ok(value.loc),
msg: Ok(value.msg),
type_: Ok(value.type_),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
}
/// Where each field of `Input` goes in the request.
pub const ROUTING: ::one::Routing = ::one::Routing { routes: &[::one::Route { field: "dimensions", part: ::one::Part::Body, key: Some("dimensions") }, ::one::Route { field: "encoding_format", part: ::one::Part::Body, key: Some("encoding_format") }, ::one::Route { field: "input", part: ::one::Part::Body, key: Some("input") }, ::one::Route { field: "model", part: ::one::Part::Body, key: Some("model") }], required_parts: &[::one::Part::Body] };
/// Builds the `create_contextualized_embeddings` action.
///
/// # Example input
/// ```json
/// {
/// "dimensions": 2560,
/// "encoding_format": "base64_int8",
/// "input": [
/// [
/// "Chunk 1 from document A",
/// "Chunk 2 from document A"
/// ],
/// [
/// "Chunk 1 from document B"
/// ]
/// ],
/// "model": "pplx-embed-context-v1-4b"
/// }
/// ```
pub fn build(input: Input) -> ::std::result::Result<Operation<output::Output>, Error> {
::std::result::Result::Ok(Operation::action("conn_mod_def::GJ6CZg7PP6o::SZxilv2RT0GHpYxYECfmgQ", Method::POST, "/v1/contextualizedembeddings").with_routed(&input, &ROUTING)?
.merge_headers(::serde_json::from_str("{\"Accept\":\"application/json\",\"Content-Type\":\"application/json\"}").map_err(Error::Decode)?).returns::<output::Output>())
}
impl IntoOperation for Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
build(self)
}
}
impl IntoOperation for builder::Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
Input::try_from(self).map_err(|error| Error::InvalidInput(::std::boxed::Box::new(error))).and_then(build)
}
}
}
/// Starts building the `create_contextualized_embeddings` action's input; pass the builder to `run`.
pub fn create_contextualized_embeddings() -> create_contextualized_embeddings::builder::Input {
create_contextualized_embeddings::builder::Input::default()
}
pub mod create_agent_response {
use ::one::{Error, IntoOperation, Method, Operation};
///JSON request body for creating an agent response.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(untagged, deny_unknown_fields)]
pub enum Body {
Variant0 {
///The input to generate a response for. May be a plain string, or an array of typed items.
input: BodyVariant0Input,
///System instructions for the model.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
instructions: ::std::option::Option<::std::string::String>,
///ISO 639-1 language code for the response language.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
language_preference: ::std::option::Option<::std::string::String>,
///Maximum tokens to generate. Minimum: 1.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
max_output_tokens: ::std::option::Option<::std::num::NonZeroU64>,
///Maximum number of research loop steps. Overrides the preset’s `max_steps` if provided.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
max_steps: ::std::option::Option<::std::num::NonZeroU64>,
///Model ID in `provider/model` format. Required if neither `models` nor `preset` is provided. Ignored if `models` is provided.
model: ::std::string::String,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
reasoning: ::std::option::Option<ReasoningConfiguration>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
response_format: ::std::option::Option<ResponseFormatConfiguration>,
///If `true`, returns an SSE stream (`text/event-stream`) instead of JSON. Default: `false`.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
stream: ::std::option::Option<bool>,
///Tools available to the model. Items may be one of: WebSearchTool, FetchUrlTool, FunctionTool.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
tools: ::std::vec::Vec<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
},
Variant1 {
///The input to generate a response for. May be a plain string, or an array of typed items.
input: BodyVariant1Input,
///System instructions for the model.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
instructions: ::std::option::Option<::std::string::String>,
///ISO 639-1 language code for the response language.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
language_preference: ::std::option::Option<::std::string::String>,
///Maximum tokens to generate. Minimum: 1.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
max_output_tokens: ::std::option::Option<::std::num::NonZeroU64>,
///Maximum number of research loop steps. Overrides the preset’s `max_steps` if provided.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
max_steps: ::std::option::Option<::std::num::NonZeroU64>,
///Model fallback chain, each in `provider/model` format. Tried in order until one succeeds. Max 5 models. Takes precedence over `model` if set.
models: ::std::vec::Vec<::std::string::String>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
reasoning: ::std::option::Option<ReasoningConfiguration>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
response_format: ::std::option::Option<ResponseFormatConfiguration>,
///If `true`, returns an SSE stream (`text/event-stream`) instead of JSON. Default: `false`.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
stream: ::std::option::Option<bool>,
///Tools available to the model. Items may be one of: WebSearchTool, FetchUrlTool, FunctionTool.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
tools: ::std::vec::Vec<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
},
Variant2 {
///The input to generate a response for. May be a plain string, or an array of typed items.
input: BodyVariant2Input,
///System instructions for the model.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
instructions: ::std::option::Option<::std::string::String>,
///ISO 639-1 language code for the response language.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
language_preference: ::std::option::Option<::std::string::String>,
///Maximum tokens to generate. Minimum: 1.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
max_output_tokens: ::std::option::Option<::std::num::NonZeroU64>,
///Maximum number of research loop steps. Overrides the preset’s `max_steps` if provided.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
max_steps: ::std::option::Option<::std::num::NonZeroU64>,
///Preset configuration name. Required if `model` is not provided.
preset: ::std::string::String,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
reasoning: ::std::option::Option<ReasoningConfiguration>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
response_format: ::std::option::Option<ResponseFormatConfiguration>,
///If `true`, returns an SSE stream (`text/event-stream`) instead of JSON. Default: `false`.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
stream: ::std::option::Option<bool>,
///Tools available to the model. Items may be one of: WebSearchTool, FetchUrlTool, FunctionTool.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
tools: ::std::vec::Vec<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
},
}
///The input to generate a response for. May be a plain string, or an array of typed items.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(untagged)]
pub enum BodyVariant0Input {
String(::std::string::String),
Array(
::std::vec::Vec<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
),
}
impl ::std::convert::From<
::std::vec::Vec<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
> for BodyVariant0Input {
fn from(
value: ::std::vec::Vec<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
) -> Self {
Self::Array(value)
}
}
///The input to generate a response for. May be a plain string, or an array of typed items.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(untagged)]
pub enum BodyVariant1Input {
String(::std::string::String),
Array(
::std::vec::Vec<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
),
}
impl ::std::convert::From<
::std::vec::Vec<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
> for BodyVariant1Input {
fn from(
value: ::std::vec::Vec<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
) -> Self {
Self::Array(value)
}
}
///The input to generate a response for. May be a plain string, or an array of typed items.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(untagged)]
pub enum BodyVariant2Input {
String(::std::string::String),
Array(
::std::vec::Vec<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
),
}
impl ::std::convert::From<
::std::vec::Vec<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
> for BodyVariant2Input {
fn from(
value: ::std::vec::Vec<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
) -> Self {
Self::Array(value)
}
}
///`Headers`
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
pub struct Headers {
///Accepted response content type. Use `application/json` for JSON responses or `text/event-stream` for SSE streaming.
#[serde(rename = "Accept")]
pub accept: ::std::string::String,
}
impl Headers {
pub fn builder() -> builder::Headers {
Default::default()
}
}
///Generates a response for the provided input, with optional web search, tool usage, and configurable reasoning. Returns either a JSON response (default) or an SSE stream when `stream` is `true`.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct Input {
pub body: Body,
pub headers: Headers,
}
impl Input {
pub fn builder() -> builder::Input {
Default::default()
}
}
///Reasoning configuration.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
#[serde(deny_unknown_fields)]
pub struct ReasoningConfiguration {
///How much effort to spend on reasoning.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub effort: ::std::option::Option<ReasoningConfigurationEffort>,
}
impl ReasoningConfiguration {
pub fn builder() -> builder::ReasoningConfiguration {
Default::default()
}
}
///How much effort to spend on reasoning.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum ReasoningConfigurationEffort {
#[serde(rename = "low")]
Low,
#[serde(rename = "medium")]
Medium,
#[serde(rename = "high")]
High,
}
impl ::std::fmt::Display for ReasoningConfigurationEffort {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Low => f.write_str("low"),
Self::Medium => f.write_str("medium"),
Self::High => f.write_str("high"),
}
}
}
impl ::std::str::FromStr for ReasoningConfigurationEffort {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"low" => Ok(Self::Low),
"medium" => Ok(Self::Medium),
"high" => Ok(Self::High),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for ReasoningConfigurationEffort {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ReasoningConfigurationEffort {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Structured output configuration.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct ResponseFormatConfiguration {
///A JSONSchemaFormat object (schema definition as documented by the API).
#[serde(default, skip_serializing_if = "::serde_json::Map::is_empty")]
pub json_schema: ::serde_json::Map<::std::string::String, ::serde_json::Value>,
///Required if `response_format` is provided.
#[serde(rename = "type")]
pub type_: ResponseFormatConfigurationType,
}
impl ResponseFormatConfiguration {
pub fn builder() -> builder::ResponseFormatConfiguration {
Default::default()
}
}
///Required if `response_format` is provided.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum ResponseFormatConfigurationType {
#[serde(rename = "json_schema")]
JsonSchema,
}
impl ::std::fmt::Display for ResponseFormatConfigurationType {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::JsonSchema => f.write_str("json_schema"),
}
}
}
impl ::std::str::FromStr for ResponseFormatConfigurationType {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"json_schema" => Ok(Self::JsonSchema),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for ResponseFormatConfigurationType {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ResponseFormatConfigurationType {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Headers {
accept: ::std::result::Result<::std::string::String, ::std::string::String>,
}
impl ::std::default::Default for Headers {
fn default() -> Self {
Self {
accept: Err("no value supplied for accept".to_string()),
}
}
}
impl Headers {
pub fn accept<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::string::String>,
T::Error: ::std::fmt::Display,
{
self.accept = value
.try_into()
.map_err(|e| format!("error converting supplied value for accept: {e}"));
self
}
}
impl ::std::convert::TryFrom<Headers> for super::Headers {
type Error = super::error::ConversionError;
fn try_from(
value: Headers,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self { accept: value.accept? })
}
}
impl ::std::convert::From<super::Headers> for Headers {
fn from(value: super::Headers) -> Self {
Self { accept: Ok(value.accept) }
}
}
#[derive(Clone, Debug)]
pub struct Input {
body: ::std::result::Result<super::Body, ::std::string::String>,
headers: ::std::result::Result<super::Headers, ::std::string::String>,
}
impl ::std::default::Default for Input {
fn default() -> Self {
Self {
body: Err("no value supplied for body".to_string()),
headers: Err("no value supplied for headers".to_string()),
}
}
}
impl Input {
pub fn body<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::Body>,
T::Error: ::std::fmt::Display,
{
self.body = value
.try_into()
.map_err(|e| format!("error converting supplied value for body: {e}"));
self
}
pub fn headers<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::Headers>,
T::Error: ::std::fmt::Display,
{
self.headers = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for headers: {e}")
});
self
}
}
impl ::std::convert::TryFrom<Input> for super::Input {
type Error = super::error::ConversionError;
fn try_from(
value: Input,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
body: value.body?,
headers: value.headers?,
})
}
}
impl ::std::convert::From<super::Input> for Input {
fn from(value: super::Input) -> Self {
Self {
body: Ok(value.body),
headers: Ok(value.headers),
}
}
}
#[derive(Clone, Debug)]
pub struct ReasoningConfiguration {
effort: ::std::result::Result<
::std::option::Option<super::ReasoningConfigurationEffort>,
::std::string::String,
>,
}
impl ::std::default::Default for ReasoningConfiguration {
fn default() -> Self {
Self {
effort: Ok(Default::default()),
}
}
}
impl ReasoningConfiguration {
pub fn effort<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<super::ReasoningConfigurationEffort>,
>,
T::Error: ::std::fmt::Display,
{
self.effort = value
.try_into()
.map_err(|e| format!("error converting supplied value for effort: {e}"));
self
}
}
impl ::std::convert::TryFrom<ReasoningConfiguration>
for super::ReasoningConfiguration {
type Error = super::error::ConversionError;
fn try_from(
value: ReasoningConfiguration,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self { effort: value.effort? })
}
}
impl ::std::convert::From<super::ReasoningConfiguration> for ReasoningConfiguration {
fn from(value: super::ReasoningConfiguration) -> Self {
Self { effort: Ok(value.effort) }
}
}
#[derive(Clone, Debug)]
pub struct ResponseFormatConfiguration {
json_schema: ::std::result::Result<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
::std::string::String,
>,
type_: ::std::result::Result<
super::ResponseFormatConfigurationType,
::std::string::String,
>,
}
impl ::std::default::Default for ResponseFormatConfiguration {
fn default() -> Self {
Self {
json_schema: Ok(Default::default()),
type_: Err("no value supplied for type_".to_string()),
}
}
}
impl ResponseFormatConfiguration {
pub fn json_schema<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
T::Error: ::std::fmt::Display,
{
self.json_schema = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for json_schema: {e}")
});
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ResponseFormatConfigurationType>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
}
impl ::std::convert::TryFrom<ResponseFormatConfiguration>
for super::ResponseFormatConfiguration {
type Error = super::error::ConversionError;
fn try_from(
value: ResponseFormatConfiguration,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
json_schema: value.json_schema?,
type_: value.type_?,
})
}
}
impl ::std::convert::From<super::ResponseFormatConfiguration>
for ResponseFormatConfiguration {
fn from(value: super::ResponseFormatConfiguration) -> Self {
Self {
json_schema: Ok(value.json_schema),
type_: Ok(value.type_),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
pub mod output {
///Error information (present when an error occurs).
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct JsonResponseError {
///Error code.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub code: ::std::option::Option<::std::string::String>,
///Human-readable error message.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub message: ::std::option::Option<::std::string::String>,
///Error type category.
#[serde(rename = "type", skip_serializing_if = "::std::option::Option::is_none")]
pub type_: ::std::option::Option<::std::string::String>,
}
impl JsonResponseError {
pub fn builder() -> builder::JsonResponseError {
Default::default()
}
}
///Object type.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum JsonResponseObject {
#[serde(rename = "response")]
Response,
}
impl ::std::fmt::Display for JsonResponseObject {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Response => f.write_str("response"),
}
}
}
impl ::std::str::FromStr for JsonResponseObject {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"response" => Ok(Self::Response),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for JsonResponseObject {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for JsonResponseObject {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Response status.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum JsonResponseStatus {
#[serde(rename = "completed")]
Completed,
#[serde(rename = "failed")]
Failed,
#[serde(rename = "in_progress")]
InProgress,
#[serde(rename = "requires_action")]
RequiresAction,
}
impl ::std::fmt::Display for JsonResponseStatus {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Completed => f.write_str("completed"),
Self::Failed => f.write_str("failed"),
Self::InProgress => f.write_str("in_progress"),
Self::RequiresAction => f.write_str("requires_action"),
}
}
}
impl ::std::str::FromStr for JsonResponseStatus {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"completed" => Ok(Self::Completed),
"failed" => Ok(Self::Failed),
"in_progress" => Ok(Self::InProgress),
"requires_action" => Ok(Self::RequiresAction),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for JsonResponseStatus {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for JsonResponseStatus {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Token usage and cost metadata.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct JsonResponseUsage {
///A ResponsesCost object (shape not specified in scraped content).
#[serde(default, skip_serializing_if = "::serde_json::Map::is_empty")]
pub cost: ::serde_json::Map<::std::string::String, ::serde_json::Value>,
///Number of input tokens used.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub input_tokens: ::std::option::Option<i64>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub input_tokens_details: ::std::option::Option<JsonResponseUsageInputTokensDetails>,
///Number of output tokens generated.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub output_tokens: ::std::option::Option<i64>,
///Map of tool call details keyed by string. Values are ToolCallDetails (shape not specified in scraped content).
#[serde(default, skip_serializing_if = "::serde_json::Map::is_empty")]
pub tool_calls_details: ::serde_json::Map<
::std::string::String,
::serde_json::Value,
>,
///Total tokens used (`input + output`).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub total_tokens: ::std::option::Option<i64>,
}
impl JsonResponseUsage {
pub fn builder() -> builder::JsonResponseUsage {
Default::default()
}
}
///Input token breakdown.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct JsonResponseUsageInputTokensDetails {
///Tokens used for cache creation.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub cache_creation_input_tokens: ::std::option::Option<i64>,
///Tokens read from cache.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub cache_read_input_tokens: ::std::option::Option<i64>,
}
impl JsonResponseUsageInputTokensDetails {
pub fn builder() -> builder::JsonResponseUsageInputTokensDetails {
Default::default()
}
}
///Successful response structure from the Perplexity Agent API. Returns either a JSON response or an SSE stream depending on the `stream` setting.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Output {
///Response payload, either a JSON response object or an SSE event stream represented as an array of event objects.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub body: ::std::option::Option<OutputBody>,
///Response content type depends on `stream`: `application/json` for non-streaming responses, `text/event-stream` for SSE streaming.
#[serde(
rename = "contentType",
skip_serializing_if = "::std::option::Option::is_none"
)]
pub content_type: ::std::option::Option<OutputContentType>,
}
impl Output {
pub fn builder() -> builder::Output {
Default::default()
}
}
///Response payload, either a JSON response object or an SSE event stream represented as an array of event objects.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(untagged)]
pub enum OutputBody {
JsonResponse {
///Unix timestamp when the response was created.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
created_at: ::std::option::Option<i64>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
error: ::std::option::Option<JsonResponseError>,
///Unique identifier for the response.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
id: ::std::option::Option<::std::string::String>,
///Model used for generation.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
model: ::std::option::Option<::std::string::String>,
///Object type.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
object: ::std::option::Option<JsonResponseObject>,
///Array of output items (messages, search results, tool calls).
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
output: ::std::vec::Vec<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
///Response status.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
status: ::std::option::Option<JsonResponseStatus>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
usage: ::std::option::Option<JsonResponseUsage>,
},
SseEventStream(::std::vec::Vec<SseEventStreamItem>),
}
impl ::std::convert::From<::std::vec::Vec<SseEventStreamItem>> for OutputBody {
fn from(value: ::std::vec::Vec<SseEventStreamItem>) -> Self {
Self::SseEventStream(value)
}
}
///Response content type depends on `stream`: `application/json` for non-streaming responses, `text/event-stream` for SSE streaming.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum OutputContentType {
#[serde(rename = "application/json")]
ApplicationJson,
#[serde(rename = "text/event-stream")]
TextEventStream,
}
impl ::std::fmt::Display for OutputContentType {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::ApplicationJson => f.write_str("application/json"),
Self::TextEventStream => f.write_str("text/event-stream"),
}
}
}
impl ::std::str::FromStr for OutputContentType {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"application/json" => Ok(Self::ApplicationJson),
"text/event-stream" => Ok(Self::TextEventStream),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for OutputContentType {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for OutputContentType {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///`SseEventStreamItem`
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct SseEventStreamItem {
///Fetched contents included in some events.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub contents: ::std::vec::Vec<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
///Delta payload for streaming events.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub delta: ::std::option::Option<SseEventStreamItemDelta>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub error: ::std::option::Option<SseEventStreamItemError>,
///Output item included in some events.
#[serde(default, skip_serializing_if = "::serde_json::Map::is_empty")]
pub item: ::serde_json::Map<::std::string::String, ::serde_json::Value>,
///Output item index for item/delta events.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub output_index: ::std::option::Option<i64>,
///Search-related queries included in some events.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub queries: ::std::vec::Vec<::std::string::String>,
///Response object included in some events.
#[serde(default, skip_serializing_if = "::serde_json::Map::is_empty")]
pub response: ::serde_json::Map<::std::string::String, ::serde_json::Value>,
///Search or fetch results included in some events.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub results: ::std::vec::Vec<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
///Sequence number for event ordering.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub sequence_number: ::std::option::Option<i64>,
///Event type.
#[serde(rename = "type", skip_serializing_if = "::std::option::Option::is_none")]
pub type_: ::std::option::Option<::std::string::String>,
///URLs included in some fetch-related events.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub urls: ::std::vec::Vec<::std::string::String>,
}
impl SseEventStreamItem {
pub fn builder() -> builder::SseEventStreamItem {
Default::default()
}
}
///Delta payload for streaming events.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(untagged)]
pub enum SseEventStreamItemDelta {
String(::std::string::String),
Object(::serde_json::Map<::std::string::String, ::serde_json::Value>),
}
impl ::std::convert::From<::serde_json::Map<::std::string::String, ::serde_json::Value>>
for SseEventStreamItemDelta {
fn from(
value: ::serde_json::Map<::std::string::String, ::serde_json::Value>,
) -> Self {
Self::Object(value)
}
}
///Error payload for error events.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct SseEventStreamItemError {
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub code: ::std::option::Option<::std::string::String>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub message: ::std::option::Option<::std::string::String>,
#[serde(rename = "type", skip_serializing_if = "::std::option::Option::is_none")]
pub type_: ::std::option::Option<::std::string::String>,
}
impl SseEventStreamItemError {
pub fn builder() -> builder::SseEventStreamItemError {
Default::default()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct JsonResponseError {
code: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
message: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
type_: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for JsonResponseError {
fn default() -> Self {
Self {
code: Ok(Default::default()),
message: Ok(Default::default()),
type_: Ok(Default::default()),
}
}
}
impl JsonResponseError {
pub fn code<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.code = value
.try_into()
.map_err(|e| format!("error converting supplied value for code: {e}"));
self
}
pub fn message<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.message = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for message: {e}")
});
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
}
impl ::std::convert::TryFrom<JsonResponseError> for super::JsonResponseError {
type Error = super::error::ConversionError;
fn try_from(
value: JsonResponseError,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
code: value.code?,
message: value.message?,
type_: value.type_?,
})
}
}
impl ::std::convert::From<super::JsonResponseError> for JsonResponseError {
fn from(value: super::JsonResponseError) -> Self {
Self {
code: Ok(value.code),
message: Ok(value.message),
type_: Ok(value.type_),
}
}
}
#[derive(Clone, Debug)]
pub struct JsonResponseUsage {
cost: ::std::result::Result<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
::std::string::String,
>,
input_tokens: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
input_tokens_details: ::std::result::Result<
::std::option::Option<super::JsonResponseUsageInputTokensDetails>,
::std::string::String,
>,
output_tokens: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
tool_calls_details: ::std::result::Result<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
::std::string::String,
>,
total_tokens: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
}
impl ::std::default::Default for JsonResponseUsage {
fn default() -> Self {
Self {
cost: Ok(Default::default()),
input_tokens: Ok(Default::default()),
input_tokens_details: Ok(Default::default()),
output_tokens: Ok(Default::default()),
tool_calls_details: Ok(Default::default()),
total_tokens: Ok(Default::default()),
}
}
}
impl JsonResponseUsage {
pub fn cost<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
T::Error: ::std::fmt::Display,
{
self.cost = value
.try_into()
.map_err(|e| format!("error converting supplied value for cost: {e}"));
self
}
pub fn input_tokens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.input_tokens = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for input_tokens: {e}")
});
self
}
pub fn input_tokens_details<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<super::JsonResponseUsageInputTokensDetails>,
>,
T::Error: ::std::fmt::Display,
{
self.input_tokens_details = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for input_tokens_details: {e}"
)
});
self
}
pub fn output_tokens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.output_tokens = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for output_tokens: {e}")
});
self
}
pub fn tool_calls_details<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
T::Error: ::std::fmt::Display,
{
self.tool_calls_details = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for tool_calls_details: {e}"
)
});
self
}
pub fn total_tokens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.total_tokens = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for total_tokens: {e}")
});
self
}
}
impl ::std::convert::TryFrom<JsonResponseUsage> for super::JsonResponseUsage {
type Error = super::error::ConversionError;
fn try_from(
value: JsonResponseUsage,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
cost: value.cost?,
input_tokens: value.input_tokens?,
input_tokens_details: value.input_tokens_details?,
output_tokens: value.output_tokens?,
tool_calls_details: value.tool_calls_details?,
total_tokens: value.total_tokens?,
})
}
}
impl ::std::convert::From<super::JsonResponseUsage> for JsonResponseUsage {
fn from(value: super::JsonResponseUsage) -> Self {
Self {
cost: Ok(value.cost),
input_tokens: Ok(value.input_tokens),
input_tokens_details: Ok(value.input_tokens_details),
output_tokens: Ok(value.output_tokens),
tool_calls_details: Ok(value.tool_calls_details),
total_tokens: Ok(value.total_tokens),
}
}
}
#[derive(Clone, Debug)]
pub struct JsonResponseUsageInputTokensDetails {
cache_creation_input_tokens: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
cache_read_input_tokens: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
}
impl ::std::default::Default for JsonResponseUsageInputTokensDetails {
fn default() -> Self {
Self {
cache_creation_input_tokens: Ok(Default::default()),
cache_read_input_tokens: Ok(Default::default()),
}
}
}
impl JsonResponseUsageInputTokensDetails {
pub fn cache_creation_input_tokens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.cache_creation_input_tokens = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for cache_creation_input_tokens: {e}"
)
});
self
}
pub fn cache_read_input_tokens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.cache_read_input_tokens = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for cache_read_input_tokens: {e}"
)
});
self
}
}
impl ::std::convert::TryFrom<JsonResponseUsageInputTokensDetails>
for super::JsonResponseUsageInputTokensDetails {
type Error = super::error::ConversionError;
fn try_from(
value: JsonResponseUsageInputTokensDetails,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
cache_creation_input_tokens: value.cache_creation_input_tokens?,
cache_read_input_tokens: value.cache_read_input_tokens?,
})
}
}
impl ::std::convert::From<super::JsonResponseUsageInputTokensDetails>
for JsonResponseUsageInputTokensDetails {
fn from(value: super::JsonResponseUsageInputTokensDetails) -> Self {
Self {
cache_creation_input_tokens: Ok(value.cache_creation_input_tokens),
cache_read_input_tokens: Ok(value.cache_read_input_tokens),
}
}
}
#[derive(Clone, Debug)]
pub struct Output {
body: ::std::result::Result<
::std::option::Option<super::OutputBody>,
::std::string::String,
>,
content_type: ::std::result::Result<
::std::option::Option<super::OutputContentType>,
::std::string::String,
>,
}
impl ::std::default::Default for Output {
fn default() -> Self {
Self {
body: Ok(Default::default()),
content_type: Ok(Default::default()),
}
}
}
impl Output {
pub fn body<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::OutputBody>>,
T::Error: ::std::fmt::Display,
{
self.body = value
.try_into()
.map_err(|e| format!("error converting supplied value for body: {e}"));
self
}
pub fn content_type<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::OutputContentType>>,
T::Error: ::std::fmt::Display,
{
self.content_type = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for content_type: {e}")
});
self
}
}
impl ::std::convert::TryFrom<Output> for super::Output {
type Error = super::error::ConversionError;
fn try_from(
value: Output,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
body: value.body?,
content_type: value.content_type?,
})
}
}
impl ::std::convert::From<super::Output> for Output {
fn from(value: super::Output) -> Self {
Self {
body: Ok(value.body),
content_type: Ok(value.content_type),
}
}
}
#[derive(Clone, Debug)]
pub struct SseEventStreamItem {
contents: ::std::result::Result<
::std::vec::Vec<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
::std::string::String,
>,
delta: ::std::result::Result<
::std::option::Option<super::SseEventStreamItemDelta>,
::std::string::String,
>,
error: ::std::result::Result<
::std::option::Option<super::SseEventStreamItemError>,
::std::string::String,
>,
item: ::std::result::Result<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
::std::string::String,
>,
output_index: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
queries: ::std::result::Result<
::std::vec::Vec<::std::string::String>,
::std::string::String,
>,
response: ::std::result::Result<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
::std::string::String,
>,
results: ::std::result::Result<
::std::vec::Vec<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
::std::string::String,
>,
sequence_number: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
type_: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
urls: ::std::result::Result<
::std::vec::Vec<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for SseEventStreamItem {
fn default() -> Self {
Self {
contents: Ok(Default::default()),
delta: Ok(Default::default()),
error: Ok(Default::default()),
item: Ok(Default::default()),
output_index: Ok(Default::default()),
queries: Ok(Default::default()),
response: Ok(Default::default()),
results: Ok(Default::default()),
sequence_number: Ok(Default::default()),
type_: Ok(Default::default()),
urls: Ok(Default::default()),
}
}
}
impl SseEventStreamItem {
pub fn contents<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::vec::Vec<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
>,
T::Error: ::std::fmt::Display,
{
self.contents = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for contents: {e}")
});
self
}
pub fn delta<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<super::SseEventStreamItemDelta>,
>,
T::Error: ::std::fmt::Display,
{
self.delta = value
.try_into()
.map_err(|e| format!("error converting supplied value for delta: {e}"));
self
}
pub fn error<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<super::SseEventStreamItemError>,
>,
T::Error: ::std::fmt::Display,
{
self.error = value
.try_into()
.map_err(|e| format!("error converting supplied value for error: {e}"));
self
}
pub fn item<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
T::Error: ::std::fmt::Display,
{
self.item = value
.try_into()
.map_err(|e| format!("error converting supplied value for item: {e}"));
self
}
pub fn output_index<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.output_index = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for output_index: {e}")
});
self
}
pub fn queries<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.queries = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for queries: {e}")
});
self
}
pub fn response<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
T::Error: ::std::fmt::Display,
{
self.response = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for response: {e}")
});
self
}
pub fn results<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::vec::Vec<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
>,
T::Error: ::std::fmt::Display,
{
self.results = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for results: {e}")
});
self
}
pub fn sequence_number<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.sequence_number = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for sequence_number: {e}")
});
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
pub fn urls<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.urls = value
.try_into()
.map_err(|e| format!("error converting supplied value for urls: {e}"));
self
}
}
impl ::std::convert::TryFrom<SseEventStreamItem> for super::SseEventStreamItem {
type Error = super::error::ConversionError;
fn try_from(
value: SseEventStreamItem,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
contents: value.contents?,
delta: value.delta?,
error: value.error?,
item: value.item?,
output_index: value.output_index?,
queries: value.queries?,
response: value.response?,
results: value.results?,
sequence_number: value.sequence_number?,
type_: value.type_?,
urls: value.urls?,
})
}
}
impl ::std::convert::From<super::SseEventStreamItem> for SseEventStreamItem {
fn from(value: super::SseEventStreamItem) -> Self {
Self {
contents: Ok(value.contents),
delta: Ok(value.delta),
error: Ok(value.error),
item: Ok(value.item),
output_index: Ok(value.output_index),
queries: Ok(value.queries),
response: Ok(value.response),
results: Ok(value.results),
sequence_number: Ok(value.sequence_number),
type_: Ok(value.type_),
urls: Ok(value.urls),
}
}
}
#[derive(Clone, Debug)]
pub struct SseEventStreamItemError {
code: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
message: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
type_: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for SseEventStreamItemError {
fn default() -> Self {
Self {
code: Ok(Default::default()),
message: Ok(Default::default()),
type_: Ok(Default::default()),
}
}
}
impl SseEventStreamItemError {
pub fn code<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.code = value
.try_into()
.map_err(|e| format!("error converting supplied value for code: {e}"));
self
}
pub fn message<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.message = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for message: {e}")
});
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
}
impl ::std::convert::TryFrom<SseEventStreamItemError>
for super::SseEventStreamItemError {
type Error = super::error::ConversionError;
fn try_from(
value: SseEventStreamItemError,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
code: value.code?,
message: value.message?,
type_: value.type_?,
})
}
}
impl ::std::convert::From<super::SseEventStreamItemError>
for SseEventStreamItemError {
fn from(value: super::SseEventStreamItemError) -> Self {
Self {
code: Ok(value.code),
message: Ok(value.message),
type_: Ok(value.type_),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
}
/// Where each field of `Input` goes in the request.
pub const ROUTING: ::one::Routing = ::one::Routing { routes: &[::one::Route { field: "body", part: ::one::Part::Body, key: None }, ::one::Route { field: "headers", part: ::one::Part::Headers, key: None }], required_parts: &[] };
/// Builds the `create_agent_response` action.
///
/// # Example input
/// ```json
/// {
/// "body": {
/// "input": "Summarize the main points of the latest AI safety discussions.",
/// "instructions": "Provide a concise summary with bullet points.",
/// "language_preference": "en",
/// "max_output_tokens": 300,
/// "max_steps": 3,
/// "model": "openai/gpt-4o",
/// "models": [
/// "openai/gpt-4o",
/// "xai/grok-4-1"
/// ],
/// "preset": "fast-search",
/// "reasoning": {
/// "effort": "medium"
/// },
/// "response_format": {
/// "json_schema": {
/// "name": "summary_response",
/// "schema": {
/// "properties": {
/// "summary": {
/// "type": "string"
/// }
/// },
/// "type": "object"
/// }
/// },
/// "type": "json_schema"
/// },
/// "stream": false,
/// "tools": [
/// {
/// "type": "web_search"
/// },
/// {
/// "type": "fetch_url"
/// },
/// {
/// "name": "lookup_fact",
/// "type": "function"
/// }
/// ]
/// },
/// "headers": {
/// "Accept": "application/json",
/// "Content-Type": "application/json"
/// }
/// }
/// ```
pub fn build(input: Input) -> ::std::result::Result<Operation<output::Output>, Error> {
::std::result::Result::Ok(Operation::action("conn_mod_def::GJ6CZd-ZY-8::3LNxtXrfQAqRFKo2zDUT5A", Method::POST, "/v1/agent").with_routed(&input, &ROUTING)?
.merge_headers(::serde_json::from_str("{\"Content-Type\":\"application/json\"}").map_err(Error::Decode)?).returns::<output::Output>())
}
impl IntoOperation for Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
build(self)
}
}
impl IntoOperation for builder::Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
Input::try_from(self).map_err(|error| Error::InvalidInput(::std::boxed::Box::new(error))).and_then(build)
}
}
impl ::std::convert::TryFrom<builder::Headers> for ::std::option::Option<Headers> {
type Error = <Headers as ::std::convert::TryFrom<builder::Headers>>::Error;
fn try_from(value: builder::Headers) -> ::std::result::Result<Self, Self::Error> {
Headers::try_from(value).map(Some)
}
}
impl ::std::convert::TryFrom<builder::ReasoningConfiguration> for ::std::option::Option<ReasoningConfiguration> {
type Error = <ReasoningConfiguration as ::std::convert::TryFrom<builder::ReasoningConfiguration>>::Error;
fn try_from(value: builder::ReasoningConfiguration) -> ::std::result::Result<Self, Self::Error> {
ReasoningConfiguration::try_from(value).map(Some)
}
}
impl ::std::convert::TryFrom<builder::ResponseFormatConfiguration> for ::std::option::Option<ResponseFormatConfiguration> {
type Error = <ResponseFormatConfiguration as ::std::convert::TryFrom<builder::ResponseFormatConfiguration>>::Error;
fn try_from(value: builder::ResponseFormatConfiguration) -> ::std::result::Result<Self, Self::Error> {
ResponseFormatConfiguration::try_from(value).map(Some)
}
}
}
/// Starts building the `create_agent_response` action's input; pass the builder to `run`.
pub fn create_agent_response() -> create_agent_response::builder::Input {
create_agent_response::builder::Input::default()
}
pub mod create_chat_completion {
use ::one::{Error, IntoOperation, Method, Operation};
///Generates a chat completion response for a provided conversation history (`messages`). Supports optional streaming, response formatting (plain text or JSON schema), and web search configuration.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct Input {
///Disable search.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub disable_search: ::std::option::Option<bool>,
///Enable search classifier.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub enable_search_classifier: ::std::option::Option<bool>,
///Image domain filter list.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub image_domain_filter: ::std::option::Option<
::std::vec::Vec<::std::string::String>,
>,
///Image format filter list.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub image_format_filter: ::std::option::Option<
::std::vec::Vec<::std::string::String>,
>,
///Language preference (string format not specified).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub language_preference: ::std::option::Option<::std::string::String>,
///Last-updated-after filter (string format not specified).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub last_updated_after_filter: ::std::option::Option<::std::string::String>,
///Last-updated-before filter (string format not specified).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub last_updated_before_filter: ::std::option::Option<::std::string::String>,
///Maximum tokens to generate.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub max_tokens: ::std::option::Option<i64>,
///Array of messages forming the conversation history.
pub messages: ::std::vec::Vec<Message>,
///Model to use. Supported values for sync: `sonar`, `sonar-pro`, `sonar-reasoning-pro`. Do NOT use `sonar-deep-research` on this endpoint because it will timeout with 502 Bad Gateway.
pub model: InputModel,
///Reasoning effort.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub reasoning_effort: ::std::option::Option<InputReasoningEffort>,
///Response formatting control. One of: `{ "type": "text" }` or `{ "type": "json_schema", "json_schema": <JSONSchema> }` or `null`.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub response_format: ::std::option::Option<ResponseFormat>,
///Whether to return images.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub return_images: ::std::option::Option<bool>,
///Whether to return related questions.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub return_related_questions: ::std::option::Option<bool>,
///Search after date filter (string format not specified).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub search_after_date_filter: ::std::option::Option<::std::string::String>,
///Search before date filter (string format not specified).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub search_before_date_filter: ::std::option::Option<::std::string::String>,
///Domain filter list.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub search_domain_filter: ::std::option::Option<
::std::vec::Vec<::std::string::String>,
>,
///Language filter list.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub search_language_filter: ::std::option::Option<
::std::vec::Vec<::std::string::String>,
>,
///Search mode.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub search_mode: ::std::option::Option<InputSearchMode>,
///Search recency filter.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub search_recency_filter: ::std::option::Option<InputSearchRecencyFilter>,
///Stop sequence(s).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub stop: ::std::option::Option<InputStop>,
///Whether to stream the response.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub stream: ::std::option::Option<bool>,
///Streaming event format mode. Default: `full`.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub stream_mode: ::std::option::Option<InputStreamMode>,
///Sampling temperature.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub temperature: ::std::option::Option<f64>,
///Nucleus sampling parameter.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub top_p: ::std::option::Option<f64>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub web_search_options: ::std::option::Option<WebSearchOptions>,
}
impl Input {
pub fn builder() -> builder::Input {
Default::default()
}
}
///Model to use. Supported values for sync: `sonar`, `sonar-pro`, `sonar-reasoning-pro`. Do NOT use `sonar-deep-research` on this endpoint because it will timeout with 502 Bad Gateway.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum InputModel {
#[serde(rename = "sonar")]
Sonar,
#[serde(rename = "sonar-pro")]
SonarPro,
#[serde(rename = "sonar-deep-research")]
SonarDeepResearch,
#[serde(rename = "sonar-reasoning-pro")]
SonarReasoningPro,
}
impl ::std::fmt::Display for InputModel {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Sonar => f.write_str("sonar"),
Self::SonarPro => f.write_str("sonar-pro"),
Self::SonarDeepResearch => f.write_str("sonar-deep-research"),
Self::SonarReasoningPro => f.write_str("sonar-reasoning-pro"),
}
}
}
impl ::std::str::FromStr for InputModel {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"sonar" => Ok(Self::Sonar),
"sonar-pro" => Ok(Self::SonarPro),
"sonar-deep-research" => Ok(Self::SonarDeepResearch),
"sonar-reasoning-pro" => Ok(Self::SonarReasoningPro),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for InputModel {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for InputModel {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Reasoning effort.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum InputReasoningEffort {
#[serde(rename = "minimal")]
Minimal,
#[serde(rename = "low")]
Low,
#[serde(rename = "medium")]
Medium,
#[serde(rename = "high")]
High,
}
impl ::std::fmt::Display for InputReasoningEffort {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Minimal => f.write_str("minimal"),
Self::Low => f.write_str("low"),
Self::Medium => f.write_str("medium"),
Self::High => f.write_str("high"),
}
}
}
impl ::std::str::FromStr for InputReasoningEffort {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"minimal" => Ok(Self::Minimal),
"low" => Ok(Self::Low),
"medium" => Ok(Self::Medium),
"high" => Ok(Self::High),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for InputReasoningEffort {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for InputReasoningEffort {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Search mode.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum InputSearchMode {
#[serde(rename = "web")]
Web,
#[serde(rename = "academic")]
Academic,
#[serde(rename = "sec")]
Sec,
}
impl ::std::fmt::Display for InputSearchMode {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Web => f.write_str("web"),
Self::Academic => f.write_str("academic"),
Self::Sec => f.write_str("sec"),
}
}
}
impl ::std::str::FromStr for InputSearchMode {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"web" => Ok(Self::Web),
"academic" => Ok(Self::Academic),
"sec" => Ok(Self::Sec),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for InputSearchMode {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for InputSearchMode {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Search recency filter.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum InputSearchRecencyFilter {
#[serde(rename = "hour")]
Hour,
#[serde(rename = "day")]
Day,
#[serde(rename = "week")]
Week,
#[serde(rename = "month")]
Month,
#[serde(rename = "year")]
Year,
}
impl ::std::fmt::Display for InputSearchRecencyFilter {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Hour => f.write_str("hour"),
Self::Day => f.write_str("day"),
Self::Week => f.write_str("week"),
Self::Month => f.write_str("month"),
Self::Year => f.write_str("year"),
}
}
}
impl ::std::str::FromStr for InputSearchRecencyFilter {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"hour" => Ok(Self::Hour),
"day" => Ok(Self::Day),
"week" => Ok(Self::Week),
"month" => Ok(Self::Month),
"year" => Ok(Self::Year),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for InputSearchRecencyFilter {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for InputSearchRecencyFilter {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Stop sequence(s).
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(untagged)]
pub enum InputStop {
String(::std::string::String),
Array(::std::vec::Vec<::std::string::String>),
Null,
}
impl ::std::convert::From<::std::vec::Vec<::std::string::String>> for InputStop {
fn from(value: ::std::vec::Vec<::std::string::String>) -> Self {
Self::Array(value)
}
}
///Streaming event format mode. Default: `full`.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum InputStreamMode {
#[serde(rename = "full")]
Full,
#[serde(rename = "concise")]
Concise,
}
impl ::std::fmt::Display for InputStreamMode {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Full => f.write_str("full"),
Self::Concise => f.write_str("concise"),
}
}
}
impl ::std::str::FromStr for InputStreamMode {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"full" => Ok(Self::Full),
"concise" => Ok(Self::Concise),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for InputStreamMode {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for InputStreamMode {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///A message in the conversation history.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
#[serde(deny_unknown_fields)]
pub struct Message {
///Message content. Can be a string, or an array of chunks (text/image/file/pdf/video chunk types), or null.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub content: ::std::option::Option<MessageContent>,
///Role for the message (exact enum values not provided in scraped content).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub role: ::std::option::Option<::std::string::String>,
}
impl Message {
pub fn builder() -> builder::Message {
Default::default()
}
}
///Message content. Can be a string, or an array of chunks (text/image/file/pdf/video chunk types), or null.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(untagged)]
pub enum MessageContent {
String(::std::string::String),
Array(
::std::vec::Vec<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
),
Null,
}
impl ::std::convert::From<
::std::vec::Vec<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
> for MessageContent {
fn from(
value: ::std::vec::Vec<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
) -> Self {
Self::Array(value)
}
}
///`ResponseFormat`
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct ResponseFormat {
///JSON Schema to use when `type` is `json_schema`.
#[serde(default, skip_serializing_if = "::serde_json::Map::is_empty")]
pub json_schema: ::serde_json::Map<::std::string::String, ::serde_json::Value>,
///Response format type.
#[serde(rename = "type")]
pub type_: ResponseFormatType,
}
impl ResponseFormat {
pub fn builder() -> builder::ResponseFormat {
Default::default()
}
}
///Response format type.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum ResponseFormatType {
#[serde(rename = "text")]
Text,
#[serde(rename = "json_schema")]
JsonSchema,
}
impl ::std::fmt::Display for ResponseFormatType {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Text => f.write_str("text"),
Self::JsonSchema => f.write_str("json_schema"),
}
}
}
impl ::std::str::FromStr for ResponseFormatType {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"text" => Ok(Self::Text),
"json_schema" => Ok(Self::JsonSchema),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for ResponseFormatType {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ResponseFormatType {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Web search configuration object.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
#[serde(deny_unknown_fields)]
pub struct WebSearchOptions {
///When `true`, applies enhanced relevance filtering to image results. Default: `false`.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub image_results_enhanced_relevance: ::std::option::Option<bool>,
///Amount of search context to include. Default: `low`.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub search_context_size: ::std::option::Option<WebSearchOptionsSearchContextSize>,
///Search type.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub search_type: ::std::option::Option<WebSearchOptionsSearchType>,
///User location object (schema not expanded in scraped content).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub user_location: ::std::option::Option<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
}
impl WebSearchOptions {
pub fn builder() -> builder::WebSearchOptions {
Default::default()
}
}
///Amount of search context to include. Default: `low`.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum WebSearchOptionsSearchContextSize {
#[serde(rename = "low")]
Low,
#[serde(rename = "medium")]
Medium,
#[serde(rename = "high")]
High,
}
impl ::std::fmt::Display for WebSearchOptionsSearchContextSize {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Low => f.write_str("low"),
Self::Medium => f.write_str("medium"),
Self::High => f.write_str("high"),
}
}
}
impl ::std::str::FromStr for WebSearchOptionsSearchContextSize {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"low" => Ok(Self::Low),
"medium" => Ok(Self::Medium),
"high" => Ok(Self::High),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for WebSearchOptionsSearchContextSize {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String>
for WebSearchOptionsSearchContextSize {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Search type.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum WebSearchOptionsSearchType {
#[serde(rename = "fast")]
Fast,
#[serde(rename = "pro")]
Pro,
#[serde(rename = "auto")]
Auto,
}
impl ::std::fmt::Display for WebSearchOptionsSearchType {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Fast => f.write_str("fast"),
Self::Pro => f.write_str("pro"),
Self::Auto => f.write_str("auto"),
}
}
}
impl ::std::str::FromStr for WebSearchOptionsSearchType {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"fast" => Ok(Self::Fast),
"pro" => Ok(Self::Pro),
"auto" => Ok(Self::Auto),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for WebSearchOptionsSearchType {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for WebSearchOptionsSearchType {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Input {
disable_search: ::std::result::Result<
::std::option::Option<bool>,
::std::string::String,
>,
enable_search_classifier: ::std::result::Result<
::std::option::Option<bool>,
::std::string::String,
>,
image_domain_filter: ::std::result::Result<
::std::option::Option<::std::vec::Vec<::std::string::String>>,
::std::string::String,
>,
image_format_filter: ::std::result::Result<
::std::option::Option<::std::vec::Vec<::std::string::String>>,
::std::string::String,
>,
language_preference: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
last_updated_after_filter: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
last_updated_before_filter: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
max_tokens: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
messages: ::std::result::Result<
::std::vec::Vec<super::Message>,
::std::string::String,
>,
model: ::std::result::Result<super::InputModel, ::std::string::String>,
reasoning_effort: ::std::result::Result<
::std::option::Option<super::InputReasoningEffort>,
::std::string::String,
>,
response_format: ::std::result::Result<
::std::option::Option<super::ResponseFormat>,
::std::string::String,
>,
return_images: ::std::result::Result<
::std::option::Option<bool>,
::std::string::String,
>,
return_related_questions: ::std::result::Result<
::std::option::Option<bool>,
::std::string::String,
>,
search_after_date_filter: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
search_before_date_filter: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
search_domain_filter: ::std::result::Result<
::std::option::Option<::std::vec::Vec<::std::string::String>>,
::std::string::String,
>,
search_language_filter: ::std::result::Result<
::std::option::Option<::std::vec::Vec<::std::string::String>>,
::std::string::String,
>,
search_mode: ::std::result::Result<
::std::option::Option<super::InputSearchMode>,
::std::string::String,
>,
search_recency_filter: ::std::result::Result<
::std::option::Option<super::InputSearchRecencyFilter>,
::std::string::String,
>,
stop: ::std::result::Result<
::std::option::Option<super::InputStop>,
::std::string::String,
>,
stream: ::std::result::Result<
::std::option::Option<bool>,
::std::string::String,
>,
stream_mode: ::std::result::Result<
::std::option::Option<super::InputStreamMode>,
::std::string::String,
>,
temperature: ::std::result::Result<
::std::option::Option<f64>,
::std::string::String,
>,
top_p: ::std::result::Result<::std::option::Option<f64>, ::std::string::String>,
web_search_options: ::std::result::Result<
::std::option::Option<super::WebSearchOptions>,
::std::string::String,
>,
}
impl ::std::default::Default for Input {
fn default() -> Self {
Self {
disable_search: Ok(Default::default()),
enable_search_classifier: Ok(Default::default()),
image_domain_filter: Ok(Default::default()),
image_format_filter: Ok(Default::default()),
language_preference: Ok(Default::default()),
last_updated_after_filter: Ok(Default::default()),
last_updated_before_filter: Ok(Default::default()),
max_tokens: Ok(Default::default()),
messages: Err("no value supplied for messages".to_string()),
model: Err("no value supplied for model".to_string()),
reasoning_effort: Ok(Default::default()),
response_format: Ok(Default::default()),
return_images: Ok(Default::default()),
return_related_questions: Ok(Default::default()),
search_after_date_filter: Ok(Default::default()),
search_before_date_filter: Ok(Default::default()),
search_domain_filter: Ok(Default::default()),
search_language_filter: Ok(Default::default()),
search_mode: Ok(Default::default()),
search_recency_filter: Ok(Default::default()),
stop: Ok(Default::default()),
stream: Ok(Default::default()),
stream_mode: Ok(Default::default()),
temperature: Ok(Default::default()),
top_p: Ok(Default::default()),
web_search_options: Ok(Default::default()),
}
}
}
impl Input {
pub fn disable_search<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<bool>>,
T::Error: ::std::fmt::Display,
{
self.disable_search = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for disable_search: {e}")
});
self
}
pub fn enable_search_classifier<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<bool>>,
T::Error: ::std::fmt::Display,
{
self.enable_search_classifier = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for enable_search_classifier: {e}"
)
});
self
}
pub fn image_domain_filter<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<::std::vec::Vec<::std::string::String>>,
>,
T::Error: ::std::fmt::Display,
{
self.image_domain_filter = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for image_domain_filter: {e}"
)
});
self
}
pub fn image_format_filter<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<::std::vec::Vec<::std::string::String>>,
>,
T::Error: ::std::fmt::Display,
{
self.image_format_filter = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for image_format_filter: {e}"
)
});
self
}
pub fn language_preference<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.language_preference = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for language_preference: {e}"
)
});
self
}
pub fn last_updated_after_filter<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.last_updated_after_filter = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for last_updated_after_filter: {e}"
)
});
self
}
pub fn last_updated_before_filter<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.last_updated_before_filter = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for last_updated_before_filter: {e}"
)
});
self
}
pub fn max_tokens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.max_tokens = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for max_tokens: {e}")
});
self
}
pub fn messages<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::Message>>,
T::Error: ::std::fmt::Display,
{
self.messages = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for messages: {e}")
});
self
}
pub fn model<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::InputModel>,
T::Error: ::std::fmt::Display,
{
self.model = value
.try_into()
.map_err(|e| format!("error converting supplied value for model: {e}"));
self
}
pub fn reasoning_effort<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<super::InputReasoningEffort>,
>,
T::Error: ::std::fmt::Display,
{
self.reasoning_effort = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for reasoning_effort: {e}")
});
self
}
pub fn response_format<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ResponseFormat>>,
T::Error: ::std::fmt::Display,
{
self.response_format = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for response_format: {e}")
});
self
}
pub fn return_images<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<bool>>,
T::Error: ::std::fmt::Display,
{
self.return_images = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for return_images: {e}")
});
self
}
pub fn return_related_questions<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<bool>>,
T::Error: ::std::fmt::Display,
{
self.return_related_questions = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for return_related_questions: {e}"
)
});
self
}
pub fn search_after_date_filter<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.search_after_date_filter = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for search_after_date_filter: {e}"
)
});
self
}
pub fn search_before_date_filter<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.search_before_date_filter = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for search_before_date_filter: {e}"
)
});
self
}
pub fn search_domain_filter<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<::std::vec::Vec<::std::string::String>>,
>,
T::Error: ::std::fmt::Display,
{
self.search_domain_filter = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for search_domain_filter: {e}"
)
});
self
}
pub fn search_language_filter<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<::std::vec::Vec<::std::string::String>>,
>,
T::Error: ::std::fmt::Display,
{
self.search_language_filter = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for search_language_filter: {e}"
)
});
self
}
pub fn search_mode<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::InputSearchMode>>,
T::Error: ::std::fmt::Display,
{
self.search_mode = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for search_mode: {e}")
});
self
}
pub fn search_recency_filter<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<super::InputSearchRecencyFilter>,
>,
T::Error: ::std::fmt::Display,
{
self.search_recency_filter = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for search_recency_filter: {e}"
)
});
self
}
pub fn stop<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::InputStop>>,
T::Error: ::std::fmt::Display,
{
self.stop = value
.try_into()
.map_err(|e| format!("error converting supplied value for stop: {e}"));
self
}
pub fn stream<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<bool>>,
T::Error: ::std::fmt::Display,
{
self.stream = value
.try_into()
.map_err(|e| format!("error converting supplied value for stream: {e}"));
self
}
pub fn stream_mode<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::InputStreamMode>>,
T::Error: ::std::fmt::Display,
{
self.stream_mode = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for stream_mode: {e}")
});
self
}
pub fn temperature<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<f64>>,
T::Error: ::std::fmt::Display,
{
self.temperature = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for temperature: {e}")
});
self
}
pub fn top_p<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<f64>>,
T::Error: ::std::fmt::Display,
{
self.top_p = value
.try_into()
.map_err(|e| format!("error converting supplied value for top_p: {e}"));
self
}
pub fn web_search_options<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::WebSearchOptions>>,
T::Error: ::std::fmt::Display,
{
self.web_search_options = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for web_search_options: {e}"
)
});
self
}
}
impl ::std::convert::TryFrom<Input> for super::Input {
type Error = super::error::ConversionError;
fn try_from(
value: Input,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
disable_search: value.disable_search?,
enable_search_classifier: value.enable_search_classifier?,
image_domain_filter: value.image_domain_filter?,
image_format_filter: value.image_format_filter?,
language_preference: value.language_preference?,
last_updated_after_filter: value.last_updated_after_filter?,
last_updated_before_filter: value.last_updated_before_filter?,
max_tokens: value.max_tokens?,
messages: value.messages?,
model: value.model?,
reasoning_effort: value.reasoning_effort?,
response_format: value.response_format?,
return_images: value.return_images?,
return_related_questions: value.return_related_questions?,
search_after_date_filter: value.search_after_date_filter?,
search_before_date_filter: value.search_before_date_filter?,
search_domain_filter: value.search_domain_filter?,
search_language_filter: value.search_language_filter?,
search_mode: value.search_mode?,
search_recency_filter: value.search_recency_filter?,
stop: value.stop?,
stream: value.stream?,
stream_mode: value.stream_mode?,
temperature: value.temperature?,
top_p: value.top_p?,
web_search_options: value.web_search_options?,
})
}
}
impl ::std::convert::From<super::Input> for Input {
fn from(value: super::Input) -> Self {
Self {
disable_search: Ok(value.disable_search),
enable_search_classifier: Ok(value.enable_search_classifier),
image_domain_filter: Ok(value.image_domain_filter),
image_format_filter: Ok(value.image_format_filter),
language_preference: Ok(value.language_preference),
last_updated_after_filter: Ok(value.last_updated_after_filter),
last_updated_before_filter: Ok(value.last_updated_before_filter),
max_tokens: Ok(value.max_tokens),
messages: Ok(value.messages),
model: Ok(value.model),
reasoning_effort: Ok(value.reasoning_effort),
response_format: Ok(value.response_format),
return_images: Ok(value.return_images),
return_related_questions: Ok(value.return_related_questions),
search_after_date_filter: Ok(value.search_after_date_filter),
search_before_date_filter: Ok(value.search_before_date_filter),
search_domain_filter: Ok(value.search_domain_filter),
search_language_filter: Ok(value.search_language_filter),
search_mode: Ok(value.search_mode),
search_recency_filter: Ok(value.search_recency_filter),
stop: Ok(value.stop),
stream: Ok(value.stream),
stream_mode: Ok(value.stream_mode),
temperature: Ok(value.temperature),
top_p: Ok(value.top_p),
web_search_options: Ok(value.web_search_options),
}
}
}
#[derive(Clone, Debug)]
pub struct Message {
content: ::std::result::Result<
::std::option::Option<super::MessageContent>,
::std::string::String,
>,
role: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for Message {
fn default() -> Self {
Self {
content: Ok(Default::default()),
role: Ok(Default::default()),
}
}
}
impl Message {
pub fn content<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::MessageContent>>,
T::Error: ::std::fmt::Display,
{
self.content = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for content: {e}")
});
self
}
pub fn role<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.role = value
.try_into()
.map_err(|e| format!("error converting supplied value for role: {e}"));
self
}
}
impl ::std::convert::TryFrom<Message> for super::Message {
type Error = super::error::ConversionError;
fn try_from(
value: Message,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
content: value.content?,
role: value.role?,
})
}
}
impl ::std::convert::From<super::Message> for Message {
fn from(value: super::Message) -> Self {
Self {
content: Ok(value.content),
role: Ok(value.role),
}
}
}
#[derive(Clone, Debug)]
pub struct ResponseFormat {
json_schema: ::std::result::Result<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
::std::string::String,
>,
type_: ::std::result::Result<super::ResponseFormatType, ::std::string::String>,
}
impl ::std::default::Default for ResponseFormat {
fn default() -> Self {
Self {
json_schema: Ok(Default::default()),
type_: Err("no value supplied for type_".to_string()),
}
}
}
impl ResponseFormat {
pub fn json_schema<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
T::Error: ::std::fmt::Display,
{
self.json_schema = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for json_schema: {e}")
});
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ResponseFormatType>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
}
impl ::std::convert::TryFrom<ResponseFormat> for super::ResponseFormat {
type Error = super::error::ConversionError;
fn try_from(
value: ResponseFormat,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
json_schema: value.json_schema?,
type_: value.type_?,
})
}
}
impl ::std::convert::From<super::ResponseFormat> for ResponseFormat {
fn from(value: super::ResponseFormat) -> Self {
Self {
json_schema: Ok(value.json_schema),
type_: Ok(value.type_),
}
}
}
#[derive(Clone, Debug)]
pub struct WebSearchOptions {
image_results_enhanced_relevance: ::std::result::Result<
::std::option::Option<bool>,
::std::string::String,
>,
search_context_size: ::std::result::Result<
::std::option::Option<super::WebSearchOptionsSearchContextSize>,
::std::string::String,
>,
search_type: ::std::result::Result<
::std::option::Option<super::WebSearchOptionsSearchType>,
::std::string::String,
>,
user_location: ::std::result::Result<
::std::option::Option<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
::std::string::String,
>,
}
impl ::std::default::Default for WebSearchOptions {
fn default() -> Self {
Self {
image_results_enhanced_relevance: Ok(Default::default()),
search_context_size: Ok(Default::default()),
search_type: Ok(Default::default()),
user_location: Ok(Default::default()),
}
}
}
impl WebSearchOptions {
pub fn image_results_enhanced_relevance<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<bool>>,
T::Error: ::std::fmt::Display,
{
self.image_results_enhanced_relevance = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for image_results_enhanced_relevance: {e}"
)
});
self
}
pub fn search_context_size<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<super::WebSearchOptionsSearchContextSize>,
>,
T::Error: ::std::fmt::Display,
{
self.search_context_size = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for search_context_size: {e}"
)
});
self
}
pub fn search_type<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<super::WebSearchOptionsSearchType>,
>,
T::Error: ::std::fmt::Display,
{
self.search_type = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for search_type: {e}")
});
self
}
pub fn user_location<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
>,
T::Error: ::std::fmt::Display,
{
self.user_location = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for user_location: {e}")
});
self
}
}
impl ::std::convert::TryFrom<WebSearchOptions> for super::WebSearchOptions {
type Error = super::error::ConversionError;
fn try_from(
value: WebSearchOptions,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
image_results_enhanced_relevance: value
.image_results_enhanced_relevance?,
search_context_size: value.search_context_size?,
search_type: value.search_type?,
user_location: value.user_location?,
})
}
}
impl ::std::convert::From<super::WebSearchOptions> for WebSearchOptions {
fn from(value: super::WebSearchOptions) -> Self {
Self {
image_results_enhanced_relevance: Ok(
value.image_results_enhanced_relevance,
),
search_context_size: Ok(value.search_context_size),
search_type: Ok(value.search_type),
user_location: Ok(value.user_location),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
pub mod output {
///Response structure for chat completion creation, including success and validation error shapes.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Output {
///Array of completion choices.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub choices: ::std::vec::Vec<OutputChoicesItem>,
///Citations (if any).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub citations: ::std::option::Option<::std::vec::Vec<::std::string::String>>,
///Unix timestamp when the completion was created.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub created: ::std::option::Option<i64>,
///Validation error details for 422 Unprocessable Entity responses.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub detail: ::std::vec::Vec<OutputDetailItem>,
///Unique identifier for the completion.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub id: ::std::option::Option<::std::string::String>,
///Images (if any).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub images: ::std::option::Option<::std::vec::Vec<OutputImagesItem>>,
///Model used for generation.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub model: ::std::option::Option<::std::string::String>,
///Object type identifier. Default: `chat.completion`.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub object: ::std::option::Option<::std::string::String>,
///Related questions (if any).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub related_questions: ::std::option::Option<::std::vec::Vec<::std::string::String>>,
///Search results (if any).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub search_results: ::std::option::Option<::std::vec::Vec<OutputSearchResultsItem>>,
///Usage object (token counts and cost).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub usage: ::std::option::Option<OutputUsage>,
}
impl Output {
pub fn builder() -> builder::Output {
Default::default()
}
}
///`OutputChoicesItem`
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct OutputChoicesItem {
///Streaming delta object (schema not provided in scraped content).
#[serde(default, skip_serializing_if = "::serde_json::Map::is_empty")]
pub delta: ::serde_json::Map<::std::string::String, ::serde_json::Value>,
///Why generation stopped.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub finish_reason: ::std::option::Option<OutputChoicesItemFinishReason>,
///Index of the choice in the array.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub index: ::std::option::Option<i64>,
///Output message object (schema not provided in scraped content).
#[serde(default, skip_serializing_if = "::serde_json::Map::is_empty")]
pub message: ::serde_json::Map<::std::string::String, ::serde_json::Value>,
}
impl OutputChoicesItem {
pub fn builder() -> builder::OutputChoicesItem {
Default::default()
}
}
///Why generation stopped.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum OutputChoicesItemFinishReason {
#[serde(rename = "stop")]
Stop,
#[serde(rename = "length")]
Length,
}
impl ::std::fmt::Display for OutputChoicesItemFinishReason {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Stop => f.write_str("stop"),
Self::Length => f.write_str("length"),
}
}
}
impl ::std::str::FromStr for OutputChoicesItemFinishReason {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"stop" => Ok(Self::Stop),
"length" => Ok(Self::Length),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for OutputChoicesItemFinishReason {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for OutputChoicesItemFinishReason {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///`OutputDetailItem`
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct OutputDetailItem {
///Error location.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub loc: ::std::vec::Vec<::std::string::String>,
///Error message.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub msg: ::std::option::Option<::std::string::String>,
///Error type.
#[serde(rename = "type", skip_serializing_if = "::std::option::Option::is_none")]
pub type_: ::std::option::Option<::std::string::String>,
}
impl OutputDetailItem {
pub fn builder() -> builder::OutputDetailItem {
Default::default()
}
}
///`OutputImagesItem`
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct OutputImagesItem {
///Height in pixels.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub height: ::std::option::Option<i64>,
///URL of the image.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub image_url: ::std::option::Option<::std::string::String>,
///Original URL where the image was found.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub origin_url: ::std::option::Option<::std::string::String>,
///Title/description of the image.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub title: ::std::option::Option<::std::string::String>,
///Width in pixels.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub width: ::std::option::Option<i64>,
}
impl OutputImagesItem {
pub fn builder() -> builder::OutputImagesItem {
Default::default()
}
}
///`OutputSearchResultsItem`
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct OutputSearchResultsItem {
///Date (format not specified).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub date: ::std::option::Option<::std::string::String>,
///Last updated timestamp/date (format not specified).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub last_updated: ::std::option::Option<::std::string::String>,
///Text snippet from the search result. Default: `""`.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub snippet: ::std::option::Option<::std::string::String>,
///Source type. Default: `web`.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub source: ::std::option::Option<OutputSearchResultsItemSource>,
///Title of the search result page.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub title: ::std::option::Option<::std::string::String>,
///URL of the search result page.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub url: ::std::option::Option<::std::string::String>,
}
impl OutputSearchResultsItem {
pub fn builder() -> builder::OutputSearchResultsItem {
Default::default()
}
}
///Source type. Default: `web`.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum OutputSearchResultsItemSource {
#[serde(rename = "web")]
Web,
#[serde(rename = "attachment")]
Attachment,
}
impl ::std::fmt::Display for OutputSearchResultsItemSource {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Web => f.write_str("web"),
Self::Attachment => f.write_str("attachment"),
}
}
}
impl ::std::str::FromStr for OutputSearchResultsItemSource {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"web" => Ok(Self::Web),
"attachment" => Ok(Self::Attachment),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for OutputSearchResultsItemSource {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for OutputSearchResultsItemSource {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///`OutputUsage`
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct OutputUsage {
///Citation tokens (if applicable).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub citation_tokens: ::std::option::Option<i64>,
///Number of tokens in the completion/output.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub completion_tokens: ::std::option::Option<i64>,
///Cost object (schema not provided in scraped content).
#[serde(default, skip_serializing_if = "::serde_json::Map::is_empty")]
pub cost: ::serde_json::Map<::std::string::String, ::serde_json::Value>,
///Number of search queries performed (if applicable).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub num_search_queries: ::std::option::Option<i64>,
///Number of tokens in the prompt/input.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub prompt_tokens: ::std::option::Option<i64>,
///Reasoning tokens (if applicable).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub reasoning_tokens: ::std::option::Option<i64>,
///Search context size used (if applicable).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub search_context_size: ::std::option::Option<::std::string::String>,
///Total tokens used (prompt + completion).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub total_tokens: ::std::option::Option<i64>,
}
impl OutputUsage {
pub fn builder() -> builder::OutputUsage {
Default::default()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Output {
choices: ::std::result::Result<
::std::vec::Vec<super::OutputChoicesItem>,
::std::string::String,
>,
citations: ::std::result::Result<
::std::option::Option<::std::vec::Vec<::std::string::String>>,
::std::string::String,
>,
created: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
detail: ::std::result::Result<
::std::vec::Vec<super::OutputDetailItem>,
::std::string::String,
>,
id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
images: ::std::result::Result<
::std::option::Option<::std::vec::Vec<super::OutputImagesItem>>,
::std::string::String,
>,
model: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
object: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
related_questions: ::std::result::Result<
::std::option::Option<::std::vec::Vec<::std::string::String>>,
::std::string::String,
>,
search_results: ::std::result::Result<
::std::option::Option<::std::vec::Vec<super::OutputSearchResultsItem>>,
::std::string::String,
>,
usage: ::std::result::Result<
::std::option::Option<super::OutputUsage>,
::std::string::String,
>,
}
impl ::std::default::Default for Output {
fn default() -> Self {
Self {
choices: Ok(Default::default()),
citations: Ok(Default::default()),
created: Ok(Default::default()),
detail: Ok(Default::default()),
id: Ok(Default::default()),
images: Ok(Default::default()),
model: Ok(Default::default()),
object: Ok(Default::default()),
related_questions: Ok(Default::default()),
search_results: Ok(Default::default()),
usage: Ok(Default::default()),
}
}
}
impl Output {
pub fn choices<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::OutputChoicesItem>>,
T::Error: ::std::fmt::Display,
{
self.choices = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for choices: {e}")
});
self
}
pub fn citations<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<::std::vec::Vec<::std::string::String>>,
>,
T::Error: ::std::fmt::Display,
{
self.citations = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for citations: {e}")
});
self
}
pub fn created<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.created = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for created: {e}")
});
self
}
pub fn detail<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::OutputDetailItem>>,
T::Error: ::std::fmt::Display,
{
self.detail = value
.try_into()
.map_err(|e| format!("error converting supplied value for detail: {e}"));
self
}
pub fn id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.id = value
.try_into()
.map_err(|e| format!("error converting supplied value for id: {e}"));
self
}
pub fn images<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<::std::vec::Vec<super::OutputImagesItem>>,
>,
T::Error: ::std::fmt::Display,
{
self.images = value
.try_into()
.map_err(|e| format!("error converting supplied value for images: {e}"));
self
}
pub fn model<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.model = value
.try_into()
.map_err(|e| format!("error converting supplied value for model: {e}"));
self
}
pub fn object<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.object = value
.try_into()
.map_err(|e| format!("error converting supplied value for object: {e}"));
self
}
pub fn related_questions<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<::std::vec::Vec<::std::string::String>>,
>,
T::Error: ::std::fmt::Display,
{
self.related_questions = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for related_questions: {e}")
});
self
}
pub fn search_results<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<::std::vec::Vec<super::OutputSearchResultsItem>>,
>,
T::Error: ::std::fmt::Display,
{
self.search_results = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for search_results: {e}")
});
self
}
pub fn usage<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::OutputUsage>>,
T::Error: ::std::fmt::Display,
{
self.usage = value
.try_into()
.map_err(|e| format!("error converting supplied value for usage: {e}"));
self
}
}
impl ::std::convert::TryFrom<Output> for super::Output {
type Error = super::error::ConversionError;
fn try_from(
value: Output,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
choices: value.choices?,
citations: value.citations?,
created: value.created?,
detail: value.detail?,
id: value.id?,
images: value.images?,
model: value.model?,
object: value.object?,
related_questions: value.related_questions?,
search_results: value.search_results?,
usage: value.usage?,
})
}
}
impl ::std::convert::From<super::Output> for Output {
fn from(value: super::Output) -> Self {
Self {
choices: Ok(value.choices),
citations: Ok(value.citations),
created: Ok(value.created),
detail: Ok(value.detail),
id: Ok(value.id),
images: Ok(value.images),
model: Ok(value.model),
object: Ok(value.object),
related_questions: Ok(value.related_questions),
search_results: Ok(value.search_results),
usage: Ok(value.usage),
}
}
}
#[derive(Clone, Debug)]
pub struct OutputChoicesItem {
delta: ::std::result::Result<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
::std::string::String,
>,
finish_reason: ::std::result::Result<
::std::option::Option<super::OutputChoicesItemFinishReason>,
::std::string::String,
>,
index: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
message: ::std::result::Result<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
::std::string::String,
>,
}
impl ::std::default::Default for OutputChoicesItem {
fn default() -> Self {
Self {
delta: Ok(Default::default()),
finish_reason: Ok(Default::default()),
index: Ok(Default::default()),
message: Ok(Default::default()),
}
}
}
impl OutputChoicesItem {
pub fn delta<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
T::Error: ::std::fmt::Display,
{
self.delta = value
.try_into()
.map_err(|e| format!("error converting supplied value for delta: {e}"));
self
}
pub fn finish_reason<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<super::OutputChoicesItemFinishReason>,
>,
T::Error: ::std::fmt::Display,
{
self.finish_reason = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for finish_reason: {e}")
});
self
}
pub fn index<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.index = value
.try_into()
.map_err(|e| format!("error converting supplied value for index: {e}"));
self
}
pub fn message<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
T::Error: ::std::fmt::Display,
{
self.message = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for message: {e}")
});
self
}
}
impl ::std::convert::TryFrom<OutputChoicesItem> for super::OutputChoicesItem {
type Error = super::error::ConversionError;
fn try_from(
value: OutputChoicesItem,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
delta: value.delta?,
finish_reason: value.finish_reason?,
index: value.index?,
message: value.message?,
})
}
}
impl ::std::convert::From<super::OutputChoicesItem> for OutputChoicesItem {
fn from(value: super::OutputChoicesItem) -> Self {
Self {
delta: Ok(value.delta),
finish_reason: Ok(value.finish_reason),
index: Ok(value.index),
message: Ok(value.message),
}
}
}
#[derive(Clone, Debug)]
pub struct OutputDetailItem {
loc: ::std::result::Result<
::std::vec::Vec<::std::string::String>,
::std::string::String,
>,
msg: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
type_: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for OutputDetailItem {
fn default() -> Self {
Self {
loc: Ok(Default::default()),
msg: Ok(Default::default()),
type_: Ok(Default::default()),
}
}
}
impl OutputDetailItem {
pub fn loc<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.loc = value
.try_into()
.map_err(|e| format!("error converting supplied value for loc: {e}"));
self
}
pub fn msg<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.msg = value
.try_into()
.map_err(|e| format!("error converting supplied value for msg: {e}"));
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
}
impl ::std::convert::TryFrom<OutputDetailItem> for super::OutputDetailItem {
type Error = super::error::ConversionError;
fn try_from(
value: OutputDetailItem,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
loc: value.loc?,
msg: value.msg?,
type_: value.type_?,
})
}
}
impl ::std::convert::From<super::OutputDetailItem> for OutputDetailItem {
fn from(value: super::OutputDetailItem) -> Self {
Self {
loc: Ok(value.loc),
msg: Ok(value.msg),
type_: Ok(value.type_),
}
}
}
#[derive(Clone, Debug)]
pub struct OutputImagesItem {
height: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
image_url: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
origin_url: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
title: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
width: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
}
impl ::std::default::Default for OutputImagesItem {
fn default() -> Self {
Self {
height: Ok(Default::default()),
image_url: Ok(Default::default()),
origin_url: Ok(Default::default()),
title: Ok(Default::default()),
width: Ok(Default::default()),
}
}
}
impl OutputImagesItem {
pub fn height<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.height = value
.try_into()
.map_err(|e| format!("error converting supplied value for height: {e}"));
self
}
pub fn image_url<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.image_url = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for image_url: {e}")
});
self
}
pub fn origin_url<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.origin_url = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for origin_url: {e}")
});
self
}
pub fn title<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.title = value
.try_into()
.map_err(|e| format!("error converting supplied value for title: {e}"));
self
}
pub fn width<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.width = value
.try_into()
.map_err(|e| format!("error converting supplied value for width: {e}"));
self
}
}
impl ::std::convert::TryFrom<OutputImagesItem> for super::OutputImagesItem {
type Error = super::error::ConversionError;
fn try_from(
value: OutputImagesItem,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
height: value.height?,
image_url: value.image_url?,
origin_url: value.origin_url?,
title: value.title?,
width: value.width?,
})
}
}
impl ::std::convert::From<super::OutputImagesItem> for OutputImagesItem {
fn from(value: super::OutputImagesItem) -> Self {
Self {
height: Ok(value.height),
image_url: Ok(value.image_url),
origin_url: Ok(value.origin_url),
title: Ok(value.title),
width: Ok(value.width),
}
}
}
#[derive(Clone, Debug)]
pub struct OutputSearchResultsItem {
date: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
last_updated: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
snippet: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
source: ::std::result::Result<
::std::option::Option<super::OutputSearchResultsItemSource>,
::std::string::String,
>,
title: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
url: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for OutputSearchResultsItem {
fn default() -> Self {
Self {
date: Ok(Default::default()),
last_updated: Ok(Default::default()),
snippet: Ok(Default::default()),
source: Ok(Default::default()),
title: Ok(Default::default()),
url: Ok(Default::default()),
}
}
}
impl OutputSearchResultsItem {
pub fn date<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.date = value
.try_into()
.map_err(|e| format!("error converting supplied value for date: {e}"));
self
}
pub fn last_updated<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.last_updated = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for last_updated: {e}")
});
self
}
pub fn snippet<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.snippet = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for snippet: {e}")
});
self
}
pub fn source<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<super::OutputSearchResultsItemSource>,
>,
T::Error: ::std::fmt::Display,
{
self.source = value
.try_into()
.map_err(|e| format!("error converting supplied value for source: {e}"));
self
}
pub fn title<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.title = value
.try_into()
.map_err(|e| format!("error converting supplied value for title: {e}"));
self
}
pub fn url<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.url = value
.try_into()
.map_err(|e| format!("error converting supplied value for url: {e}"));
self
}
}
impl ::std::convert::TryFrom<OutputSearchResultsItem>
for super::OutputSearchResultsItem {
type Error = super::error::ConversionError;
fn try_from(
value: OutputSearchResultsItem,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
date: value.date?,
last_updated: value.last_updated?,
snippet: value.snippet?,
source: value.source?,
title: value.title?,
url: value.url?,
})
}
}
impl ::std::convert::From<super::OutputSearchResultsItem>
for OutputSearchResultsItem {
fn from(value: super::OutputSearchResultsItem) -> Self {
Self {
date: Ok(value.date),
last_updated: Ok(value.last_updated),
snippet: Ok(value.snippet),
source: Ok(value.source),
title: Ok(value.title),
url: Ok(value.url),
}
}
}
#[derive(Clone, Debug)]
pub struct OutputUsage {
citation_tokens: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
completion_tokens: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
cost: ::std::result::Result<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
::std::string::String,
>,
num_search_queries: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
prompt_tokens: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
reasoning_tokens: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
search_context_size: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
total_tokens: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
}
impl ::std::default::Default for OutputUsage {
fn default() -> Self {
Self {
citation_tokens: Ok(Default::default()),
completion_tokens: Ok(Default::default()),
cost: Ok(Default::default()),
num_search_queries: Ok(Default::default()),
prompt_tokens: Ok(Default::default()),
reasoning_tokens: Ok(Default::default()),
search_context_size: Ok(Default::default()),
total_tokens: Ok(Default::default()),
}
}
}
impl OutputUsage {
pub fn citation_tokens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.citation_tokens = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for citation_tokens: {e}")
});
self
}
pub fn completion_tokens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.completion_tokens = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for completion_tokens: {e}")
});
self
}
pub fn cost<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
T::Error: ::std::fmt::Display,
{
self.cost = value
.try_into()
.map_err(|e| format!("error converting supplied value for cost: {e}"));
self
}
pub fn num_search_queries<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.num_search_queries = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for num_search_queries: {e}"
)
});
self
}
pub fn prompt_tokens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.prompt_tokens = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for prompt_tokens: {e}")
});
self
}
pub fn reasoning_tokens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.reasoning_tokens = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for reasoning_tokens: {e}")
});
self
}
pub fn search_context_size<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.search_context_size = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for search_context_size: {e}"
)
});
self
}
pub fn total_tokens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.total_tokens = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for total_tokens: {e}")
});
self
}
}
impl ::std::convert::TryFrom<OutputUsage> for super::OutputUsage {
type Error = super::error::ConversionError;
fn try_from(
value: OutputUsage,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
citation_tokens: value.citation_tokens?,
completion_tokens: value.completion_tokens?,
cost: value.cost?,
num_search_queries: value.num_search_queries?,
prompt_tokens: value.prompt_tokens?,
reasoning_tokens: value.reasoning_tokens?,
search_context_size: value.search_context_size?,
total_tokens: value.total_tokens?,
})
}
}
impl ::std::convert::From<super::OutputUsage> for OutputUsage {
fn from(value: super::OutputUsage) -> Self {
Self {
citation_tokens: Ok(value.citation_tokens),
completion_tokens: Ok(value.completion_tokens),
cost: Ok(value.cost),
num_search_queries: Ok(value.num_search_queries),
prompt_tokens: Ok(value.prompt_tokens),
reasoning_tokens: Ok(value.reasoning_tokens),
search_context_size: Ok(value.search_context_size),
total_tokens: Ok(value.total_tokens),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
}
/// Where each field of `Input` goes in the request.
pub const ROUTING: ::one::Routing = ::one::Routing { routes: &[::one::Route { field: "disable_search", part: ::one::Part::Body, key: Some("disable_search") }, ::one::Route { field: "enable_search_classifier", part: ::one::Part::Body, key: Some("enable_search_classifier") }, ::one::Route { field: "image_domain_filter", part: ::one::Part::Body, key: Some("image_domain_filter") }, ::one::Route { field: "image_format_filter", part: ::one::Part::Body, key: Some("image_format_filter") }, ::one::Route { field: "language_preference", part: ::one::Part::Body, key: Some("language_preference") }, ::one::Route { field: "last_updated_after_filter", part: ::one::Part::Body, key: Some("last_updated_after_filter") }, ::one::Route { field: "last_updated_before_filter", part: ::one::Part::Body, key: Some("last_updated_before_filter") }, ::one::Route { field: "max_tokens", part: ::one::Part::Body, key: Some("max_tokens") }, ::one::Route { field: "messages", part: ::one::Part::Body, key: Some("messages") }, ::one::Route { field: "model", part: ::one::Part::Body, key: Some("model") }, ::one::Route { field: "reasoning_effort", part: ::one::Part::Body, key: Some("reasoning_effort") }, ::one::Route { field: "response_format", part: ::one::Part::Body, key: Some("response_format") }, ::one::Route { field: "return_images", part: ::one::Part::Body, key: Some("return_images") }, ::one::Route { field: "return_related_questions", part: ::one::Part::Body, key: Some("return_related_questions") }, ::one::Route { field: "search_after_date_filter", part: ::one::Part::Body, key: Some("search_after_date_filter") }, ::one::Route { field: "search_before_date_filter", part: ::one::Part::Body, key: Some("search_before_date_filter") }, ::one::Route { field: "search_domain_filter", part: ::one::Part::Body, key: Some("search_domain_filter") }, ::one::Route { field: "search_language_filter", part: ::one::Part::Body, key: Some("search_language_filter") }, ::one::Route { field: "search_mode", part: ::one::Part::Body, key: Some("search_mode") }, ::one::Route { field: "search_recency_filter", part: ::one::Part::Body, key: Some("search_recency_filter") }, ::one::Route { field: "stop", part: ::one::Part::Body, key: Some("stop") }, ::one::Route { field: "stream", part: ::one::Part::Body, key: Some("stream") }, ::one::Route { field: "stream_mode", part: ::one::Part::Body, key: Some("stream_mode") }, ::one::Route { field: "temperature", part: ::one::Part::Body, key: Some("temperature") }, ::one::Route { field: "top_p", part: ::one::Part::Body, key: Some("top_p") }, ::one::Route { field: "web_search_options", part: ::one::Part::Body, key: Some("web_search_options") }], required_parts: &[::one::Part::Body] };
/// Builds the `create_chat_completion` action.
///
/// # Example input
/// ```json
/// {
/// "disable_search": false,
/// "enable_search_classifier": true,
/// "image_domain_filter": [
/// "images.example.com"
/// ],
/// "image_format_filter": [
/// "jpg",
/// "png"
/// ],
/// "language_preference": "en-US",
/// "last_updated_after_filter": "2024-01-01",
/// "last_updated_before_filter": "2024-12-31",
/// "max_tokens": 300,
/// "messages": [
/// {
/// "content": "Explain what a chat completion API does.",
/// "role": "user"
/// }
/// ],
/// "model": "sonar-pro",
/// "reasoning_effort": "medium",
/// "response_format": {
/// "json_schema": {
/// "properties": {
/// "summary": {
/// "type": "string"
/// }
/// },
/// "required": [
/// "summary"
/// ],
/// "type": "object"
/// },
/// "type": "json_schema"
/// },
/// "return_images": false,
/// "return_related_questions": true,
/// "search_after_date_filter": "2024-01-01",
/// "search_before_date_filter": "2024-12-31",
/// "search_domain_filter": [
/// "example.com"
/// ],
/// "search_language_filter": [
/// "en"
/// ],
/// "search_mode": "web",
/// "search_recency_filter": "week",
/// "stop": [
/// "END"
/// ],
/// "stream": false,
/// "stream_mode": "full",
/// "temperature": 0.2,
/// "top_p": 0.9,
/// "web_search_options": {
/// "image_results_enhanced_relevance": false,
/// "search_context_size": "high",
/// "search_type": "auto",
/// "user_location": {
/// "city": "San Francisco",
/// "country": "US",
/// "region": "CA"
/// }
/// }
/// }
/// ```
pub fn build(input: Input) -> ::std::result::Result<Operation<output::Output>, Error> {
::std::result::Result::Ok(Operation::action("conn_mod_def::GJ6CZeTvPJc::zmkwnSM8S6egtsvqG96MKQ", Method::POST, "/v1/sonar").with_routed(&input, &ROUTING)?
.merge_headers(::serde_json::from_str("{\"Accept\":\"application/json\",\"Content-Type\":\"application/json\"}").map_err(Error::Decode)?).returns::<output::Output>())
}
impl IntoOperation for Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
build(self)
}
}
impl IntoOperation for builder::Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
Input::try_from(self).map_err(|error| Error::InvalidInput(::std::boxed::Box::new(error))).and_then(build)
}
}
impl ::std::convert::TryFrom<builder::Message> for ::std::option::Option<Message> {
type Error = <Message as ::std::convert::TryFrom<builder::Message>>::Error;
fn try_from(value: builder::Message) -> ::std::result::Result<Self, Self::Error> {
Message::try_from(value).map(Some)
}
}
impl ::std::convert::TryFrom<builder::ResponseFormat> for ::std::option::Option<ResponseFormat> {
type Error = <ResponseFormat as ::std::convert::TryFrom<builder::ResponseFormat>>::Error;
fn try_from(value: builder::ResponseFormat) -> ::std::result::Result<Self, Self::Error> {
ResponseFormat::try_from(value).map(Some)
}
}
impl ::std::convert::TryFrom<builder::WebSearchOptions> for ::std::option::Option<WebSearchOptions> {
type Error = <WebSearchOptions as ::std::convert::TryFrom<builder::WebSearchOptions>>::Error;
fn try_from(value: builder::WebSearchOptions) -> ::std::result::Result<Self, Self::Error> {
WebSearchOptions::try_from(value).map(Some)
}
}
}
/// Starts building the `create_chat_completion` action's input; pass the builder to `run`.
pub fn create_chat_completion() -> create_chat_completion::builder::Input {
create_chat_completion::builder::Input::default()
}
pub mod create_async_chat_completion_sonar {
use ::one::{Error, IntoOperation, Method, Operation};
///Submits an asynchronous chat completion request to a Sonar model. The API returns an async request object with an `id` and `status`, and may include a `response` object when completed.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct Input {
///Optional idempotency key.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub idempotency_key: ::std::option::Option<::std::string::String>,
pub request: RequestPayload,
}
impl Input {
pub fn builder() -> builder::Input {
Default::default()
}
}
///Chat message object.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct Message {
///Message content. Can be a string, or an array of content chunks, or `null`.
pub content: MessageContent,
///Chat message role (`<ChatMessageRole>`).
pub role: ::std::string::String,
}
impl Message {
pub fn builder() -> builder::Message {
Default::default()
}
}
///Message content. Can be a string, or an array of content chunks, or `null`.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(untagged)]
pub enum MessageContent {
String(::std::string::String),
Array(
::std::vec::Vec<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
),
Null,
}
impl ::std::convert::From<
::std::vec::Vec<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
> for MessageContent {
fn from(
value: ::std::vec::Vec<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
) -> Self {
Self::Array(value)
}
}
///Request payload container.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct RequestPayload {
///Disable search.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub disable_search: ::std::option::Option<bool>,
///Enable search classifier.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub enable_search_classifier: ::std::option::Option<bool>,
///Image domain filter list.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub image_domain_filter: ::std::option::Option<
::std::vec::Vec<::std::string::String>,
>,
///Image format filter list.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub image_format_filter: ::std::option::Option<
::std::vec::Vec<::std::string::String>,
>,
///Language preference.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub language_preference: ::std::option::Option<::std::string::String>,
///Last-updated-after filter (string).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub last_updated_after_filter: ::std::option::Option<::std::string::String>,
///Last-updated-before filter (string).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub last_updated_before_filter: ::std::option::Option<::std::string::String>,
///Maximum tokens to generate.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub max_tokens: ::std::option::Option<i64>,
///Array of messages forming the conversation history.
pub messages: ::std::vec::Vec<Message>,
///Model to use. Must be `sonar-deep-research`. This is the only model supported for async processing.
pub model: RequestPayloadModel,
///Reasoning effort.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub reasoning_effort: ::std::option::Option<RequestPayloadReasoningEffort>,
///Response format. One of `<ResponseFormatText>`, `<ResponseFormatJSONSchema>`, or `null`.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub response_format: ::std::option::Option<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
///Whether to return images.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub return_images: ::std::option::Option<bool>,
///Whether to return related questions.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub return_related_questions: ::std::option::Option<bool>,
///After date filter (string).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub search_after_date_filter: ::std::option::Option<::std::string::String>,
///Before date filter (string).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub search_before_date_filter: ::std::option::Option<::std::string::String>,
///Domain filter list.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub search_domain_filter: ::std::option::Option<
::std::vec::Vec<::std::string::String>,
>,
///Language filter list.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub search_language_filter: ::std::option::Option<
::std::vec::Vec<::std::string::String>,
>,
///Search mode.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub search_mode: ::std::option::Option<RequestPayloadSearchMode>,
///Recency filter.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub search_recency_filter: ::std::option::Option<RequestPayloadSearchRecencyFilter>,
///Stop sequence(s).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub stop: ::std::option::Option<RequestPayloadStop>,
///Whether to stream output.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub stream: ::std::option::Option<bool>,
///Streaming event format. Allowed values: `full`, `concise`. Default: `full`.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub stream_mode: ::std::option::Option<RequestPayloadStreamMode>,
///Sampling temperature.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub temperature: ::std::option::Option<f64>,
///Nucleus sampling parameter.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub top_p: ::std::option::Option<f64>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub web_search_options: ::std::option::Option<RequestPayloadWebSearchOptions>,
}
impl RequestPayload {
pub fn builder() -> builder::RequestPayload {
Default::default()
}
}
///Model to use. Must be `sonar-deep-research`. This is the only model supported for async processing.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum RequestPayloadModel {
#[serde(rename = "sonar-deep-research")]
SonarDeepResearch,
}
impl ::std::fmt::Display for RequestPayloadModel {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::SonarDeepResearch => f.write_str("sonar-deep-research"),
}
}
}
impl ::std::str::FromStr for RequestPayloadModel {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"sonar-deep-research" => Ok(Self::SonarDeepResearch),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for RequestPayloadModel {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for RequestPayloadModel {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Reasoning effort.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum RequestPayloadReasoningEffort {
#[serde(rename = "minimal")]
Minimal,
#[serde(rename = "low")]
Low,
#[serde(rename = "medium")]
Medium,
#[serde(rename = "high")]
High,
}
impl ::std::fmt::Display for RequestPayloadReasoningEffort {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Minimal => f.write_str("minimal"),
Self::Low => f.write_str("low"),
Self::Medium => f.write_str("medium"),
Self::High => f.write_str("high"),
}
}
}
impl ::std::str::FromStr for RequestPayloadReasoningEffort {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"minimal" => Ok(Self::Minimal),
"low" => Ok(Self::Low),
"medium" => Ok(Self::Medium),
"high" => Ok(Self::High),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for RequestPayloadReasoningEffort {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for RequestPayloadReasoningEffort {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Search mode.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum RequestPayloadSearchMode {
#[serde(rename = "web")]
Web,
#[serde(rename = "academic")]
Academic,
#[serde(rename = "sec")]
Sec,
}
impl ::std::fmt::Display for RequestPayloadSearchMode {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Web => f.write_str("web"),
Self::Academic => f.write_str("academic"),
Self::Sec => f.write_str("sec"),
}
}
}
impl ::std::str::FromStr for RequestPayloadSearchMode {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"web" => Ok(Self::Web),
"academic" => Ok(Self::Academic),
"sec" => Ok(Self::Sec),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for RequestPayloadSearchMode {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for RequestPayloadSearchMode {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Recency filter.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum RequestPayloadSearchRecencyFilter {
#[serde(rename = "hour")]
Hour,
#[serde(rename = "day")]
Day,
#[serde(rename = "week")]
Week,
#[serde(rename = "month")]
Month,
#[serde(rename = "year")]
Year,
}
impl ::std::fmt::Display for RequestPayloadSearchRecencyFilter {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Hour => f.write_str("hour"),
Self::Day => f.write_str("day"),
Self::Week => f.write_str("week"),
Self::Month => f.write_str("month"),
Self::Year => f.write_str("year"),
}
}
}
impl ::std::str::FromStr for RequestPayloadSearchRecencyFilter {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"hour" => Ok(Self::Hour),
"day" => Ok(Self::Day),
"week" => Ok(Self::Week),
"month" => Ok(Self::Month),
"year" => Ok(Self::Year),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for RequestPayloadSearchRecencyFilter {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String>
for RequestPayloadSearchRecencyFilter {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Stop sequence(s).
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(untagged)]
pub enum RequestPayloadStop {
String(::std::string::String),
Array(::std::vec::Vec<::std::string::String>),
Null,
}
impl ::std::convert::From<::std::vec::Vec<::std::string::String>>
for RequestPayloadStop {
fn from(value: ::std::vec::Vec<::std::string::String>) -> Self {
Self::Array(value)
}
}
///Streaming event format. Allowed values: `full`, `concise`. Default: `full`.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum RequestPayloadStreamMode {
#[serde(rename = "full")]
Full,
#[serde(rename = "concise")]
Concise,
}
impl ::std::fmt::Display for RequestPayloadStreamMode {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Full => f.write_str("full"),
Self::Concise => f.write_str("concise"),
}
}
}
impl ::std::str::FromStr for RequestPayloadStreamMode {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"full" => Ok(Self::Full),
"concise" => Ok(Self::Concise),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for RequestPayloadStreamMode {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for RequestPayloadStreamMode {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Web search options (`<WebSearchOptions>`).
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
#[serde(deny_unknown_fields)]
pub struct RequestPayloadWebSearchOptions {}
impl RequestPayloadWebSearchOptions {
pub fn builder() -> builder::RequestPayloadWebSearchOptions {
Default::default()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Input {
idempotency_key: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
request: ::std::result::Result<super::RequestPayload, ::std::string::String>,
}
impl ::std::default::Default for Input {
fn default() -> Self {
Self {
idempotency_key: Ok(Default::default()),
request: Err("no value supplied for request".to_string()),
}
}
}
impl Input {
pub fn idempotency_key<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.idempotency_key = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for idempotency_key: {e}")
});
self
}
pub fn request<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::RequestPayload>,
T::Error: ::std::fmt::Display,
{
self.request = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for request: {e}")
});
self
}
}
impl ::std::convert::TryFrom<Input> for super::Input {
type Error = super::error::ConversionError;
fn try_from(
value: Input,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
idempotency_key: value.idempotency_key?,
request: value.request?,
})
}
}
impl ::std::convert::From<super::Input> for Input {
fn from(value: super::Input) -> Self {
Self {
idempotency_key: Ok(value.idempotency_key),
request: Ok(value.request),
}
}
}
#[derive(Clone, Debug)]
pub struct Message {
content: ::std::result::Result<super::MessageContent, ::std::string::String>,
role: ::std::result::Result<::std::string::String, ::std::string::String>,
}
impl ::std::default::Default for Message {
fn default() -> Self {
Self {
content: Err("no value supplied for content".to_string()),
role: Err("no value supplied for role".to_string()),
}
}
}
impl Message {
pub fn content<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::MessageContent>,
T::Error: ::std::fmt::Display,
{
self.content = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for content: {e}")
});
self
}
pub fn role<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::string::String>,
T::Error: ::std::fmt::Display,
{
self.role = value
.try_into()
.map_err(|e| format!("error converting supplied value for role: {e}"));
self
}
}
impl ::std::convert::TryFrom<Message> for super::Message {
type Error = super::error::ConversionError;
fn try_from(
value: Message,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
content: value.content?,
role: value.role?,
})
}
}
impl ::std::convert::From<super::Message> for Message {
fn from(value: super::Message) -> Self {
Self {
content: Ok(value.content),
role: Ok(value.role),
}
}
}
#[derive(Clone, Debug)]
pub struct RequestPayload {
disable_search: ::std::result::Result<
::std::option::Option<bool>,
::std::string::String,
>,
enable_search_classifier: ::std::result::Result<
::std::option::Option<bool>,
::std::string::String,
>,
image_domain_filter: ::std::result::Result<
::std::option::Option<::std::vec::Vec<::std::string::String>>,
::std::string::String,
>,
image_format_filter: ::std::result::Result<
::std::option::Option<::std::vec::Vec<::std::string::String>>,
::std::string::String,
>,
language_preference: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
last_updated_after_filter: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
last_updated_before_filter: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
max_tokens: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
messages: ::std::result::Result<
::std::vec::Vec<super::Message>,
::std::string::String,
>,
model: ::std::result::Result<super::RequestPayloadModel, ::std::string::String>,
reasoning_effort: ::std::result::Result<
::std::option::Option<super::RequestPayloadReasoningEffort>,
::std::string::String,
>,
response_format: ::std::result::Result<
::std::option::Option<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
::std::string::String,
>,
return_images: ::std::result::Result<
::std::option::Option<bool>,
::std::string::String,
>,
return_related_questions: ::std::result::Result<
::std::option::Option<bool>,
::std::string::String,
>,
search_after_date_filter: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
search_before_date_filter: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
search_domain_filter: ::std::result::Result<
::std::option::Option<::std::vec::Vec<::std::string::String>>,
::std::string::String,
>,
search_language_filter: ::std::result::Result<
::std::option::Option<::std::vec::Vec<::std::string::String>>,
::std::string::String,
>,
search_mode: ::std::result::Result<
::std::option::Option<super::RequestPayloadSearchMode>,
::std::string::String,
>,
search_recency_filter: ::std::result::Result<
::std::option::Option<super::RequestPayloadSearchRecencyFilter>,
::std::string::String,
>,
stop: ::std::result::Result<
::std::option::Option<super::RequestPayloadStop>,
::std::string::String,
>,
stream: ::std::result::Result<
::std::option::Option<bool>,
::std::string::String,
>,
stream_mode: ::std::result::Result<
::std::option::Option<super::RequestPayloadStreamMode>,
::std::string::String,
>,
temperature: ::std::result::Result<
::std::option::Option<f64>,
::std::string::String,
>,
top_p: ::std::result::Result<::std::option::Option<f64>, ::std::string::String>,
web_search_options: ::std::result::Result<
::std::option::Option<super::RequestPayloadWebSearchOptions>,
::std::string::String,
>,
}
impl ::std::default::Default for RequestPayload {
fn default() -> Self {
Self {
disable_search: Ok(Default::default()),
enable_search_classifier: Ok(Default::default()),
image_domain_filter: Ok(Default::default()),
image_format_filter: Ok(Default::default()),
language_preference: Ok(Default::default()),
last_updated_after_filter: Ok(Default::default()),
last_updated_before_filter: Ok(Default::default()),
max_tokens: Ok(Default::default()),
messages: Err("no value supplied for messages".to_string()),
model: Err("no value supplied for model".to_string()),
reasoning_effort: Ok(Default::default()),
response_format: Ok(Default::default()),
return_images: Ok(Default::default()),
return_related_questions: Ok(Default::default()),
search_after_date_filter: Ok(Default::default()),
search_before_date_filter: Ok(Default::default()),
search_domain_filter: Ok(Default::default()),
search_language_filter: Ok(Default::default()),
search_mode: Ok(Default::default()),
search_recency_filter: Ok(Default::default()),
stop: Ok(Default::default()),
stream: Ok(Default::default()),
stream_mode: Ok(Default::default()),
temperature: Ok(Default::default()),
top_p: Ok(Default::default()),
web_search_options: Ok(Default::default()),
}
}
}
impl RequestPayload {
pub fn disable_search<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<bool>>,
T::Error: ::std::fmt::Display,
{
self.disable_search = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for disable_search: {e}")
});
self
}
pub fn enable_search_classifier<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<bool>>,
T::Error: ::std::fmt::Display,
{
self.enable_search_classifier = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for enable_search_classifier: {e}"
)
});
self
}
pub fn image_domain_filter<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<::std::vec::Vec<::std::string::String>>,
>,
T::Error: ::std::fmt::Display,
{
self.image_domain_filter = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for image_domain_filter: {e}"
)
});
self
}
pub fn image_format_filter<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<::std::vec::Vec<::std::string::String>>,
>,
T::Error: ::std::fmt::Display,
{
self.image_format_filter = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for image_format_filter: {e}"
)
});
self
}
pub fn language_preference<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.language_preference = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for language_preference: {e}"
)
});
self
}
pub fn last_updated_after_filter<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.last_updated_after_filter = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for last_updated_after_filter: {e}"
)
});
self
}
pub fn last_updated_before_filter<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.last_updated_before_filter = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for last_updated_before_filter: {e}"
)
});
self
}
pub fn max_tokens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.max_tokens = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for max_tokens: {e}")
});
self
}
pub fn messages<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::Message>>,
T::Error: ::std::fmt::Display,
{
self.messages = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for messages: {e}")
});
self
}
pub fn model<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::RequestPayloadModel>,
T::Error: ::std::fmt::Display,
{
self.model = value
.try_into()
.map_err(|e| format!("error converting supplied value for model: {e}"));
self
}
pub fn reasoning_effort<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<super::RequestPayloadReasoningEffort>,
>,
T::Error: ::std::fmt::Display,
{
self.reasoning_effort = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for reasoning_effort: {e}")
});
self
}
pub fn response_format<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
>,
T::Error: ::std::fmt::Display,
{
self.response_format = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for response_format: {e}")
});
self
}
pub fn return_images<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<bool>>,
T::Error: ::std::fmt::Display,
{
self.return_images = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for return_images: {e}")
});
self
}
pub fn return_related_questions<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<bool>>,
T::Error: ::std::fmt::Display,
{
self.return_related_questions = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for return_related_questions: {e}"
)
});
self
}
pub fn search_after_date_filter<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.search_after_date_filter = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for search_after_date_filter: {e}"
)
});
self
}
pub fn search_before_date_filter<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.search_before_date_filter = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for search_before_date_filter: {e}"
)
});
self
}
pub fn search_domain_filter<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<::std::vec::Vec<::std::string::String>>,
>,
T::Error: ::std::fmt::Display,
{
self.search_domain_filter = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for search_domain_filter: {e}"
)
});
self
}
pub fn search_language_filter<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<::std::vec::Vec<::std::string::String>>,
>,
T::Error: ::std::fmt::Display,
{
self.search_language_filter = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for search_language_filter: {e}"
)
});
self
}
pub fn search_mode<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<super::RequestPayloadSearchMode>,
>,
T::Error: ::std::fmt::Display,
{
self.search_mode = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for search_mode: {e}")
});
self
}
pub fn search_recency_filter<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<super::RequestPayloadSearchRecencyFilter>,
>,
T::Error: ::std::fmt::Display,
{
self.search_recency_filter = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for search_recency_filter: {e}"
)
});
self
}
pub fn stop<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::RequestPayloadStop>>,
T::Error: ::std::fmt::Display,
{
self.stop = value
.try_into()
.map_err(|e| format!("error converting supplied value for stop: {e}"));
self
}
pub fn stream<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<bool>>,
T::Error: ::std::fmt::Display,
{
self.stream = value
.try_into()
.map_err(|e| format!("error converting supplied value for stream: {e}"));
self
}
pub fn stream_mode<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<super::RequestPayloadStreamMode>,
>,
T::Error: ::std::fmt::Display,
{
self.stream_mode = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for stream_mode: {e}")
});
self
}
pub fn temperature<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<f64>>,
T::Error: ::std::fmt::Display,
{
self.temperature = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for temperature: {e}")
});
self
}
pub fn top_p<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<f64>>,
T::Error: ::std::fmt::Display,
{
self.top_p = value
.try_into()
.map_err(|e| format!("error converting supplied value for top_p: {e}"));
self
}
pub fn web_search_options<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<super::RequestPayloadWebSearchOptions>,
>,
T::Error: ::std::fmt::Display,
{
self.web_search_options = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for web_search_options: {e}"
)
});
self
}
}
impl ::std::convert::TryFrom<RequestPayload> for super::RequestPayload {
type Error = super::error::ConversionError;
fn try_from(
value: RequestPayload,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
disable_search: value.disable_search?,
enable_search_classifier: value.enable_search_classifier?,
image_domain_filter: value.image_domain_filter?,
image_format_filter: value.image_format_filter?,
language_preference: value.language_preference?,
last_updated_after_filter: value.last_updated_after_filter?,
last_updated_before_filter: value.last_updated_before_filter?,
max_tokens: value.max_tokens?,
messages: value.messages?,
model: value.model?,
reasoning_effort: value.reasoning_effort?,
response_format: value.response_format?,
return_images: value.return_images?,
return_related_questions: value.return_related_questions?,
search_after_date_filter: value.search_after_date_filter?,
search_before_date_filter: value.search_before_date_filter?,
search_domain_filter: value.search_domain_filter?,
search_language_filter: value.search_language_filter?,
search_mode: value.search_mode?,
search_recency_filter: value.search_recency_filter?,
stop: value.stop?,
stream: value.stream?,
stream_mode: value.stream_mode?,
temperature: value.temperature?,
top_p: value.top_p?,
web_search_options: value.web_search_options?,
})
}
}
impl ::std::convert::From<super::RequestPayload> for RequestPayload {
fn from(value: super::RequestPayload) -> Self {
Self {
disable_search: Ok(value.disable_search),
enable_search_classifier: Ok(value.enable_search_classifier),
image_domain_filter: Ok(value.image_domain_filter),
image_format_filter: Ok(value.image_format_filter),
language_preference: Ok(value.language_preference),
last_updated_after_filter: Ok(value.last_updated_after_filter),
last_updated_before_filter: Ok(value.last_updated_before_filter),
max_tokens: Ok(value.max_tokens),
messages: Ok(value.messages),
model: Ok(value.model),
reasoning_effort: Ok(value.reasoning_effort),
response_format: Ok(value.response_format),
return_images: Ok(value.return_images),
return_related_questions: Ok(value.return_related_questions),
search_after_date_filter: Ok(value.search_after_date_filter),
search_before_date_filter: Ok(value.search_before_date_filter),
search_domain_filter: Ok(value.search_domain_filter),
search_language_filter: Ok(value.search_language_filter),
search_mode: Ok(value.search_mode),
search_recency_filter: Ok(value.search_recency_filter),
stop: Ok(value.stop),
stream: Ok(value.stream),
stream_mode: Ok(value.stream_mode),
temperature: Ok(value.temperature),
top_p: Ok(value.top_p),
web_search_options: Ok(value.web_search_options),
}
}
}
#[derive(Clone, Debug)]
pub struct RequestPayloadWebSearchOptions {}
impl ::std::default::Default for RequestPayloadWebSearchOptions {
fn default() -> Self {
Self {}
}
}
impl RequestPayloadWebSearchOptions {}
impl ::std::convert::TryFrom<RequestPayloadWebSearchOptions>
for super::RequestPayloadWebSearchOptions {
type Error = super::error::ConversionError;
fn try_from(
_value: RequestPayloadWebSearchOptions,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {})
}
}
impl ::std::convert::From<super::RequestPayloadWebSearchOptions>
for RequestPayloadWebSearchOptions {
fn from(_value: super::RequestPayloadWebSearchOptions) -> Self {
Self {}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
pub mod output {
///Completion response object (present when available).
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct CompletionResponse {
///Array of completion choices.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub choices: ::std::vec::Vec<CompletionResponseChoicesItem>,
///Citations, if any.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub citations: ::std::option::Option<::std::vec::Vec<::std::string::String>>,
///Unix timestamp when the completion was created.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub created: ::std::option::Option<i64>,
///Unique identifier for the completion.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub id: ::std::option::Option<::std::string::String>,
///Images, if any.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub images: ::std::option::Option<::std::vec::Vec<CompletionResponseImagesItem>>,
///Model used for generation.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub model: ::std::option::Option<::std::string::String>,
///Object type identifier. Default: `chat.completion`.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub object: ::std::option::Option<::std::string::String>,
///Related questions, if any.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub related_questions: ::std::option::Option<::std::vec::Vec<::std::string::String>>,
///Search results, if any.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub search_results: ::std::option::Option<
::std::vec::Vec<CompletionResponseSearchResultsItem>,
>,
///Usage info (`<UsageInfo>`).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub usage: ::std::option::Option<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
}
impl CompletionResponse {
pub fn builder() -> builder::CompletionResponse {
Default::default()
}
}
///`CompletionResponseChoicesItem`
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct CompletionResponseChoicesItem {
///Output delta message (`<ChatMessage-Output>`).
#[serde(default, skip_serializing_if = "::serde_json::Map::is_empty")]
pub delta: ::serde_json::Map<::std::string::String, ::serde_json::Value>,
///Finish reason.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub finish_reason: ::std::option::Option<CompletionResponseChoicesItemFinishReason>,
///Index of the choice in the array.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub index: ::std::option::Option<i64>,
///Output chat message (`<ChatMessage-Output>`).
#[serde(default, skip_serializing_if = "::serde_json::Map::is_empty")]
pub message: ::serde_json::Map<::std::string::String, ::serde_json::Value>,
}
impl CompletionResponseChoicesItem {
pub fn builder() -> builder::CompletionResponseChoicesItem {
Default::default()
}
}
///Finish reason.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum CompletionResponseChoicesItemFinishReason {
#[serde(rename = "stop")]
Stop,
#[serde(rename = "length")]
Length,
}
impl ::std::fmt::Display for CompletionResponseChoicesItemFinishReason {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Stop => f.write_str("stop"),
Self::Length => f.write_str("length"),
}
}
}
impl ::std::str::FromStr for CompletionResponseChoicesItemFinishReason {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"stop" => Ok(Self::Stop),
"length" => Ok(Self::Length),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for CompletionResponseChoicesItemFinishReason {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String>
for CompletionResponseChoicesItemFinishReason {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///`CompletionResponseImagesItem`
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct CompletionResponseImagesItem {
///Image height in pixels.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub height: ::std::option::Option<i64>,
///URL of the image.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub image_url: ::std::option::Option<::std::string::String>,
///Original URL where the image was found.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub origin_url: ::std::option::Option<::std::string::String>,
///Title/description of the image.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub title: ::std::option::Option<::std::string::String>,
///Image width in pixels.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub width: ::std::option::Option<i64>,
}
impl CompletionResponseImagesItem {
pub fn builder() -> builder::CompletionResponseImagesItem {
Default::default()
}
}
///`CompletionResponseSearchResultsItem`
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct CompletionResponseSearchResultsItem {
///Date associated with the result.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub date: ::std::option::Option<::std::string::String>,
///Last updated timestamp, if provided.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub last_updated: ::std::option::Option<::std::string::String>,
///Text snippet. Default: `""`.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub snippet: ::std::option::Option<::std::string::String>,
///Source type. Allowed values: `web`, `attachment`. Default: `web`.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub source: ::std::option::Option<CompletionResponseSearchResultsItemSource>,
///Title of the search result page.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub title: ::std::option::Option<::std::string::String>,
///URL of the search result page.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub url: ::std::option::Option<::std::string::String>,
}
impl CompletionResponseSearchResultsItem {
pub fn builder() -> builder::CompletionResponseSearchResultsItem {
Default::default()
}
}
///Source type. Allowed values: `web`, `attachment`. Default: `web`.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum CompletionResponseSearchResultsItemSource {
#[serde(rename = "web")]
Web,
#[serde(rename = "attachment")]
Attachment,
}
impl ::std::fmt::Display for CompletionResponseSearchResultsItemSource {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Web => f.write_str("web"),
Self::Attachment => f.write_str("attachment"),
}
}
}
impl ::std::str::FromStr for CompletionResponseSearchResultsItemSource {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"web" => Ok(Self::Web),
"attachment" => Ok(Self::Attachment),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for CompletionResponseSearchResultsItemSource {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String>
for CompletionResponseSearchResultsItemSource {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Response structure for creating an async Sonar chat completion, including success and documented error variants.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Output {
///Unix timestamp when processing completed.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub completed_at: ::std::option::Option<i64>,
///Unix timestamp when the request was created.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub created_at: ::std::option::Option<i64>,
///Validation error details returned for 422 Unprocessable Entity responses.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub detail: ::std::vec::Vec<OutputDetailItem>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub error: ::std::option::Option<OutputError>,
///Error message if failed.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub error_message: ::std::option::Option<::std::string::String>,
///Unix timestamp when the request failed.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub failed_at: ::std::option::Option<i64>,
///Unique identifier for the async request.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub id: ::std::option::Option<::std::string::String>,
///Model used for the request.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub model: ::std::option::Option<::std::string::String>,
///Completion response object (present when available).
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub response: ::std::option::Option<CompletionResponse>,
///Unix timestamp when processing started.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub started_at: ::std::option::Option<i64>,
///Request status.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub status: ::std::option::Option<OutputStatus>,
}
impl Output {
pub fn builder() -> builder::Output {
Default::default()
}
}
///`OutputDetailItem`
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct OutputDetailItem {
///Location of the validation error.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub loc: ::std::vec::Vec<::std::string::String>,
///Validation error message.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub msg: ::std::option::Option<::std::string::String>,
///Validation error type.
#[serde(rename = "type", skip_serializing_if = "::std::option::Option::is_none")]
pub type_: ::std::option::Option<::std::string::String>,
}
impl OutputDetailItem {
pub fn builder() -> builder::OutputDetailItem {
Default::default()
}
}
///Error object returned for invalid model usage.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct OutputError {
///Error code.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub code: ::std::option::Option<i64>,
///Error message.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub message: ::std::option::Option<::std::string::String>,
///Error type.
#[serde(rename = "type", skip_serializing_if = "::std::option::Option::is_none")]
pub type_: ::std::option::Option<::std::string::String>,
}
impl OutputError {
pub fn builder() -> builder::OutputError {
Default::default()
}
}
///Request status.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum OutputStatus {
#[serde(rename = "CREATED")]
Created,
#[serde(rename = "IN_PROGRESS")]
InProgress,
#[serde(rename = "COMPLETED")]
Completed,
#[serde(rename = "FAILED")]
Failed,
}
impl ::std::fmt::Display for OutputStatus {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Created => f.write_str("CREATED"),
Self::InProgress => f.write_str("IN_PROGRESS"),
Self::Completed => f.write_str("COMPLETED"),
Self::Failed => f.write_str("FAILED"),
}
}
}
impl ::std::str::FromStr for OutputStatus {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"CREATED" => Ok(Self::Created),
"IN_PROGRESS" => Ok(Self::InProgress),
"COMPLETED" => Ok(Self::Completed),
"FAILED" => Ok(Self::Failed),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for OutputStatus {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for OutputStatus {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct CompletionResponse {
choices: ::std::result::Result<
::std::vec::Vec<super::CompletionResponseChoicesItem>,
::std::string::String,
>,
citations: ::std::result::Result<
::std::option::Option<::std::vec::Vec<::std::string::String>>,
::std::string::String,
>,
created: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
images: ::std::result::Result<
::std::option::Option<::std::vec::Vec<super::CompletionResponseImagesItem>>,
::std::string::String,
>,
model: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
object: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
related_questions: ::std::result::Result<
::std::option::Option<::std::vec::Vec<::std::string::String>>,
::std::string::String,
>,
search_results: ::std::result::Result<
::std::option::Option<
::std::vec::Vec<super::CompletionResponseSearchResultsItem>,
>,
::std::string::String,
>,
usage: ::std::result::Result<
::std::option::Option<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
::std::string::String,
>,
}
impl ::std::default::Default for CompletionResponse {
fn default() -> Self {
Self {
choices: Ok(Default::default()),
citations: Ok(Default::default()),
created: Ok(Default::default()),
id: Ok(Default::default()),
images: Ok(Default::default()),
model: Ok(Default::default()),
object: Ok(Default::default()),
related_questions: Ok(Default::default()),
search_results: Ok(Default::default()),
usage: Ok(Default::default()),
}
}
}
impl CompletionResponse {
pub fn choices<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::vec::Vec<super::CompletionResponseChoicesItem>,
>,
T::Error: ::std::fmt::Display,
{
self.choices = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for choices: {e}")
});
self
}
pub fn citations<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<::std::vec::Vec<::std::string::String>>,
>,
T::Error: ::std::fmt::Display,
{
self.citations = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for citations: {e}")
});
self
}
pub fn created<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.created = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for created: {e}")
});
self
}
pub fn id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.id = value
.try_into()
.map_err(|e| format!("error converting supplied value for id: {e}"));
self
}
pub fn images<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<
::std::vec::Vec<super::CompletionResponseImagesItem>,
>,
>,
T::Error: ::std::fmt::Display,
{
self.images = value
.try_into()
.map_err(|e| format!("error converting supplied value for images: {e}"));
self
}
pub fn model<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.model = value
.try_into()
.map_err(|e| format!("error converting supplied value for model: {e}"));
self
}
pub fn object<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.object = value
.try_into()
.map_err(|e| format!("error converting supplied value for object: {e}"));
self
}
pub fn related_questions<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<::std::vec::Vec<::std::string::String>>,
>,
T::Error: ::std::fmt::Display,
{
self.related_questions = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for related_questions: {e}")
});
self
}
pub fn search_results<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<
::std::vec::Vec<super::CompletionResponseSearchResultsItem>,
>,
>,
T::Error: ::std::fmt::Display,
{
self.search_results = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for search_results: {e}")
});
self
}
pub fn usage<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
>,
T::Error: ::std::fmt::Display,
{
self.usage = value
.try_into()
.map_err(|e| format!("error converting supplied value for usage: {e}"));
self
}
}
impl ::std::convert::TryFrom<CompletionResponse> for super::CompletionResponse {
type Error = super::error::ConversionError;
fn try_from(
value: CompletionResponse,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
choices: value.choices?,
citations: value.citations?,
created: value.created?,
id: value.id?,
images: value.images?,
model: value.model?,
object: value.object?,
related_questions: value.related_questions?,
search_results: value.search_results?,
usage: value.usage?,
})
}
}
impl ::std::convert::From<super::CompletionResponse> for CompletionResponse {
fn from(value: super::CompletionResponse) -> Self {
Self {
choices: Ok(value.choices),
citations: Ok(value.citations),
created: Ok(value.created),
id: Ok(value.id),
images: Ok(value.images),
model: Ok(value.model),
object: Ok(value.object),
related_questions: Ok(value.related_questions),
search_results: Ok(value.search_results),
usage: Ok(value.usage),
}
}
}
#[derive(Clone, Debug)]
pub struct CompletionResponseChoicesItem {
delta: ::std::result::Result<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
::std::string::String,
>,
finish_reason: ::std::result::Result<
::std::option::Option<super::CompletionResponseChoicesItemFinishReason>,
::std::string::String,
>,
index: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
message: ::std::result::Result<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
::std::string::String,
>,
}
impl ::std::default::Default for CompletionResponseChoicesItem {
fn default() -> Self {
Self {
delta: Ok(Default::default()),
finish_reason: Ok(Default::default()),
index: Ok(Default::default()),
message: Ok(Default::default()),
}
}
}
impl CompletionResponseChoicesItem {
pub fn delta<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
T::Error: ::std::fmt::Display,
{
self.delta = value
.try_into()
.map_err(|e| format!("error converting supplied value for delta: {e}"));
self
}
pub fn finish_reason<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<super::CompletionResponseChoicesItemFinishReason>,
>,
T::Error: ::std::fmt::Display,
{
self.finish_reason = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for finish_reason: {e}")
});
self
}
pub fn index<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.index = value
.try_into()
.map_err(|e| format!("error converting supplied value for index: {e}"));
self
}
pub fn message<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
T::Error: ::std::fmt::Display,
{
self.message = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for message: {e}")
});
self
}
}
impl ::std::convert::TryFrom<CompletionResponseChoicesItem>
for super::CompletionResponseChoicesItem {
type Error = super::error::ConversionError;
fn try_from(
value: CompletionResponseChoicesItem,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
delta: value.delta?,
finish_reason: value.finish_reason?,
index: value.index?,
message: value.message?,
})
}
}
impl ::std::convert::From<super::CompletionResponseChoicesItem>
for CompletionResponseChoicesItem {
fn from(value: super::CompletionResponseChoicesItem) -> Self {
Self {
delta: Ok(value.delta),
finish_reason: Ok(value.finish_reason),
index: Ok(value.index),
message: Ok(value.message),
}
}
}
#[derive(Clone, Debug)]
pub struct CompletionResponseImagesItem {
height: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
image_url: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
origin_url: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
title: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
width: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
}
impl ::std::default::Default for CompletionResponseImagesItem {
fn default() -> Self {
Self {
height: Ok(Default::default()),
image_url: Ok(Default::default()),
origin_url: Ok(Default::default()),
title: Ok(Default::default()),
width: Ok(Default::default()),
}
}
}
impl CompletionResponseImagesItem {
pub fn height<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.height = value
.try_into()
.map_err(|e| format!("error converting supplied value for height: {e}"));
self
}
pub fn image_url<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.image_url = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for image_url: {e}")
});
self
}
pub fn origin_url<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.origin_url = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for origin_url: {e}")
});
self
}
pub fn title<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.title = value
.try_into()
.map_err(|e| format!("error converting supplied value for title: {e}"));
self
}
pub fn width<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.width = value
.try_into()
.map_err(|e| format!("error converting supplied value for width: {e}"));
self
}
}
impl ::std::convert::TryFrom<CompletionResponseImagesItem>
for super::CompletionResponseImagesItem {
type Error = super::error::ConversionError;
fn try_from(
value: CompletionResponseImagesItem,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
height: value.height?,
image_url: value.image_url?,
origin_url: value.origin_url?,
title: value.title?,
width: value.width?,
})
}
}
impl ::std::convert::From<super::CompletionResponseImagesItem>
for CompletionResponseImagesItem {
fn from(value: super::CompletionResponseImagesItem) -> Self {
Self {
height: Ok(value.height),
image_url: Ok(value.image_url),
origin_url: Ok(value.origin_url),
title: Ok(value.title),
width: Ok(value.width),
}
}
}
#[derive(Clone, Debug)]
pub struct CompletionResponseSearchResultsItem {
date: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
last_updated: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
snippet: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
source: ::std::result::Result<
::std::option::Option<super::CompletionResponseSearchResultsItemSource>,
::std::string::String,
>,
title: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
url: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for CompletionResponseSearchResultsItem {
fn default() -> Self {
Self {
date: Ok(Default::default()),
last_updated: Ok(Default::default()),
snippet: Ok(Default::default()),
source: Ok(Default::default()),
title: Ok(Default::default()),
url: Ok(Default::default()),
}
}
}
impl CompletionResponseSearchResultsItem {
pub fn date<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.date = value
.try_into()
.map_err(|e| format!("error converting supplied value for date: {e}"));
self
}
pub fn last_updated<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.last_updated = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for last_updated: {e}")
});
self
}
pub fn snippet<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.snippet = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for snippet: {e}")
});
self
}
pub fn source<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<super::CompletionResponseSearchResultsItemSource>,
>,
T::Error: ::std::fmt::Display,
{
self.source = value
.try_into()
.map_err(|e| format!("error converting supplied value for source: {e}"));
self
}
pub fn title<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.title = value
.try_into()
.map_err(|e| format!("error converting supplied value for title: {e}"));
self
}
pub fn url<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.url = value
.try_into()
.map_err(|e| format!("error converting supplied value for url: {e}"));
self
}
}
impl ::std::convert::TryFrom<CompletionResponseSearchResultsItem>
for super::CompletionResponseSearchResultsItem {
type Error = super::error::ConversionError;
fn try_from(
value: CompletionResponseSearchResultsItem,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
date: value.date?,
last_updated: value.last_updated?,
snippet: value.snippet?,
source: value.source?,
title: value.title?,
url: value.url?,
})
}
}
impl ::std::convert::From<super::CompletionResponseSearchResultsItem>
for CompletionResponseSearchResultsItem {
fn from(value: super::CompletionResponseSearchResultsItem) -> Self {
Self {
date: Ok(value.date),
last_updated: Ok(value.last_updated),
snippet: Ok(value.snippet),
source: Ok(value.source),
title: Ok(value.title),
url: Ok(value.url),
}
}
}
#[derive(Clone, Debug)]
pub struct Output {
completed_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
created_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
detail: ::std::result::Result<
::std::vec::Vec<super::OutputDetailItem>,
::std::string::String,
>,
error: ::std::result::Result<
::std::option::Option<super::OutputError>,
::std::string::String,
>,
error_message: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
failed_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
model: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
response: ::std::result::Result<
::std::option::Option<super::CompletionResponse>,
::std::string::String,
>,
started_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
status: ::std::result::Result<
::std::option::Option<super::OutputStatus>,
::std::string::String,
>,
}
impl ::std::default::Default for Output {
fn default() -> Self {
Self {
completed_at: Ok(Default::default()),
created_at: Ok(Default::default()),
detail: Ok(Default::default()),
error: Ok(Default::default()),
error_message: Ok(Default::default()),
failed_at: Ok(Default::default()),
id: Ok(Default::default()),
model: Ok(Default::default()),
response: Ok(Default::default()),
started_at: Ok(Default::default()),
status: Ok(Default::default()),
}
}
}
impl Output {
pub fn completed_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.completed_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for completed_at: {e}")
});
self
}
pub fn created_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.created_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for created_at: {e}")
});
self
}
pub fn detail<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::OutputDetailItem>>,
T::Error: ::std::fmt::Display,
{
self.detail = value
.try_into()
.map_err(|e| format!("error converting supplied value for detail: {e}"));
self
}
pub fn error<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::OutputError>>,
T::Error: ::std::fmt::Display,
{
self.error = value
.try_into()
.map_err(|e| format!("error converting supplied value for error: {e}"));
self
}
pub fn error_message<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.error_message = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for error_message: {e}")
});
self
}
pub fn failed_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.failed_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for failed_at: {e}")
});
self
}
pub fn id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.id = value
.try_into()
.map_err(|e| format!("error converting supplied value for id: {e}"));
self
}
pub fn model<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.model = value
.try_into()
.map_err(|e| format!("error converting supplied value for model: {e}"));
self
}
pub fn response<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::CompletionResponse>>,
T::Error: ::std::fmt::Display,
{
self.response = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for response: {e}")
});
self
}
pub fn started_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.started_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for started_at: {e}")
});
self
}
pub fn status<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::OutputStatus>>,
T::Error: ::std::fmt::Display,
{
self.status = value
.try_into()
.map_err(|e| format!("error converting supplied value for status: {e}"));
self
}
}
impl ::std::convert::TryFrom<Output> for super::Output {
type Error = super::error::ConversionError;
fn try_from(
value: Output,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
completed_at: value.completed_at?,
created_at: value.created_at?,
detail: value.detail?,
error: value.error?,
error_message: value.error_message?,
failed_at: value.failed_at?,
id: value.id?,
model: value.model?,
response: value.response?,
started_at: value.started_at?,
status: value.status?,
})
}
}
impl ::std::convert::From<super::Output> for Output {
fn from(value: super::Output) -> Self {
Self {
completed_at: Ok(value.completed_at),
created_at: Ok(value.created_at),
detail: Ok(value.detail),
error: Ok(value.error),
error_message: Ok(value.error_message),
failed_at: Ok(value.failed_at),
id: Ok(value.id),
model: Ok(value.model),
response: Ok(value.response),
started_at: Ok(value.started_at),
status: Ok(value.status),
}
}
}
#[derive(Clone, Debug)]
pub struct OutputDetailItem {
loc: ::std::result::Result<
::std::vec::Vec<::std::string::String>,
::std::string::String,
>,
msg: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
type_: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for OutputDetailItem {
fn default() -> Self {
Self {
loc: Ok(Default::default()),
msg: Ok(Default::default()),
type_: Ok(Default::default()),
}
}
}
impl OutputDetailItem {
pub fn loc<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.loc = value
.try_into()
.map_err(|e| format!("error converting supplied value for loc: {e}"));
self
}
pub fn msg<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.msg = value
.try_into()
.map_err(|e| format!("error converting supplied value for msg: {e}"));
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
}
impl ::std::convert::TryFrom<OutputDetailItem> for super::OutputDetailItem {
type Error = super::error::ConversionError;
fn try_from(
value: OutputDetailItem,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
loc: value.loc?,
msg: value.msg?,
type_: value.type_?,
})
}
}
impl ::std::convert::From<super::OutputDetailItem> for OutputDetailItem {
fn from(value: super::OutputDetailItem) -> Self {
Self {
loc: Ok(value.loc),
msg: Ok(value.msg),
type_: Ok(value.type_),
}
}
}
#[derive(Clone, Debug)]
pub struct OutputError {
code: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
message: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
type_: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for OutputError {
fn default() -> Self {
Self {
code: Ok(Default::default()),
message: Ok(Default::default()),
type_: Ok(Default::default()),
}
}
}
impl OutputError {
pub fn code<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.code = value
.try_into()
.map_err(|e| format!("error converting supplied value for code: {e}"));
self
}
pub fn message<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.message = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for message: {e}")
});
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
}
impl ::std::convert::TryFrom<OutputError> for super::OutputError {
type Error = super::error::ConversionError;
fn try_from(
value: OutputError,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
code: value.code?,
message: value.message?,
type_: value.type_?,
})
}
}
impl ::std::convert::From<super::OutputError> for OutputError {
fn from(value: super::OutputError) -> Self {
Self {
code: Ok(value.code),
message: Ok(value.message),
type_: Ok(value.type_),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
}
/// Where each field of `Input` goes in the request.
pub const ROUTING: ::one::Routing = ::one::Routing { routes: &[::one::Route { field: "idempotency_key", part: ::one::Part::Body, key: Some("idempotency_key") }, ::one::Route { field: "request", part: ::one::Part::Body, key: Some("request") }], required_parts: &[::one::Part::Body] };
/// Builds the `create_async_chat_completion_sonar` action.
///
/// # Example input
/// ```json
/// {
/// "idempotency_key": "idem_12345",
/// "request": {
/// "disable_search": false,
/// "enable_search_classifier": false,
/// "image_domain_filter": [
/// "example.com",
/// "images.example.org"
/// ],
/// "image_format_filter": [
/// "jpg",
/// "png"
/// ],
/// "language_preference": "en-US",
/// "last_updated_after_filter": "2024-01-01T00:00:00Z",
/// "last_updated_before_filter": "2024-12-31T23:59:59Z",
/// "max_tokens": 1024,
/// "messages": [
/// {
/// "content": "Summarize the latest research on battery recycling.",
/// "role": "user"
/// },
/// {
/// "content": [
/// {
/// "text": "Here is a partial summary so far.",
/// "type": "text"
/// }
/// ],
/// "role": "assistant"
/// },
/// {
/// "content": null,
/// "role": "user"
/// }
/// ],
/// "model": "sonar-deep-research",
/// "reasoning_effort": "medium",
/// "response_format": {
/// "json_schema": {
/// "name": "summary_response"
/// },
/// "type": "json_schema"
/// },
/// "return_images": true,
/// "return_related_questions": true,
/// "search_after_date_filter": "2024-01-01",
/// "search_before_date_filter": "2024-12-31",
/// "search_domain_filter": [
/// "nature.com",
/// "science.org"
/// ],
/// "search_language_filter": [
/// "en",
/// "es"
/// ],
/// "search_mode": "academic",
/// "search_recency_filter": "month",
/// "stop": [
/// "END",
/// "STOP"
/// ],
/// "stream": true,
/// "stream_mode": "concise",
/// "temperature": 0.7,
/// "top_p": 0.9,
/// "web_search_options": {}
/// }
/// }
/// ```
pub fn build(input: Input) -> ::std::result::Result<Operation<output::Output>, Error> {
::std::result::Result::Ok(Operation::action("conn_mod_def::GJ6CZhlw03k::e46CEqjNTEqKVz-hX2SWUQ", Method::POST, "/async/sonar").with_routed(&input, &ROUTING)?
.merge_headers(::serde_json::from_str("{\"Accept\":\"application/json\",\"Content-Type\":\"application/json\"}").map_err(Error::Decode)?).returns::<output::Output>())
}
impl IntoOperation for Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
build(self)
}
}
impl IntoOperation for builder::Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
Input::try_from(self).map_err(|error| Error::InvalidInput(::std::boxed::Box::new(error))).and_then(build)
}
}
impl ::std::convert::TryFrom<builder::Message> for ::std::option::Option<Message> {
type Error = <Message as ::std::convert::TryFrom<builder::Message>>::Error;
fn try_from(value: builder::Message) -> ::std::result::Result<Self, Self::Error> {
Message::try_from(value).map(Some)
}
}
impl ::std::convert::TryFrom<builder::RequestPayload> for ::std::option::Option<RequestPayload> {
type Error = <RequestPayload as ::std::convert::TryFrom<builder::RequestPayload>>::Error;
fn try_from(value: builder::RequestPayload) -> ::std::result::Result<Self, Self::Error> {
RequestPayload::try_from(value).map(Some)
}
}
impl ::std::convert::TryFrom<builder::RequestPayloadWebSearchOptions> for ::std::option::Option<RequestPayloadWebSearchOptions> {
type Error = <RequestPayloadWebSearchOptions as ::std::convert::TryFrom<builder::RequestPayloadWebSearchOptions>>::Error;
fn try_from(value: builder::RequestPayloadWebSearchOptions) -> ::std::result::Result<Self, Self::Error> {
RequestPayloadWebSearchOptions::try_from(value).map(Some)
}
}
}
/// Starts building the `create_async_chat_completion_sonar` action's input; pass the builder to `run`.
pub fn create_async_chat_completion_sonar() -> create_async_chat_completion_sonar::builder::Input {
create_async_chat_completion_sonar::builder::Input::default()
}
pub mod download_file_content {
use ::one::{Error, IntoOperation, Method, Operation};
///Streams the raw byte content of an input, output, or error file identified by its file ID.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct Input {
///File identifier to download. Expected format: `file_...`. Send this value in the URL path.
#[serde(rename = "fileId")]
pub file_id: InputFileId,
}
impl Input {
pub fn builder() -> builder::Input {
Default::default()
}
}
///File identifier to download. Expected format: `file_...`. Send this value in the URL path.
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct InputFileId(::std::string::String);
impl ::std::ops::Deref for InputFileId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<InputFileId> for ::std::string::String {
fn from(value: InputFileId) -> Self {
value.0
}
}
impl ::std::str::FromStr for InputFileId {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
::std::convert::TryFrom::try_from(value)
}
}
impl ::std::convert::TryFrom<&str> for InputFileId {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
static PATTERN: ::std::sync::LazyLock<::regress::Regex> = ::std::sync::LazyLock::new(||
{ ::regress::Regex::with_flags("^file_.+", "u").unwrap() });
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^file_.+\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<::std::string::String> for InputFileId {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
::std::convert::TryFrom::try_from(value.as_str())
}
}
impl<'de> ::serde::Deserialize<'de> for InputFileId {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::convert::TryFrom::try_from(
::std::string::String::deserialize(deserializer)?,
)
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Input {
file_id: ::std::result::Result<super::InputFileId, ::std::string::String>,
}
impl ::std::default::Default for Input {
fn default() -> Self {
Self {
file_id: Err("no value supplied for file_id".to_string()),
}
}
}
impl Input {
pub fn file_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::InputFileId>,
T::Error: ::std::fmt::Display,
{
self.file_id = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for file_id: {e}")
});
self
}
}
impl ::std::convert::TryFrom<Input> for super::Input {
type Error = super::error::ConversionError;
fn try_from(
value: Input,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self { file_id: value.file_id? })
}
}
impl ::std::convert::From<super::Input> for Input {
fn from(value: super::Input) -> Self {
Self { file_id: Ok(value.file_id) }
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
pub mod output {
///`ErrorResponseError`
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct ErrorResponseError {
///HTTP status code.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub code: ::std::option::Option<i64>,
///Human-readable error message.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub message: ::std::option::Option<::std::string::String>,
///Parameter that caused the error, when applicable.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub param: ::std::option::Option<::std::string::String>,
///Error type identifier.
#[serde(rename = "type", skip_serializing_if = "::std::option::Option::is_none")]
pub type_: ::std::option::Option<::std::string::String>,
}
impl ErrorResponseError {
pub fn builder() -> builder::ErrorResponseError {
Default::default()
}
}
///Successful response is raw binary file content (`application/octet-stream`). If the file does not exist or has expired, the API returns a JSON error object.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(untagged)]
pub enum Output {
Variant0(::std::string::String),
Variant1 {
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
error: ::std::option::Option<ErrorResponseError>,
},
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct ErrorResponseError {
code: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
message: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
param: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
type_: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for ErrorResponseError {
fn default() -> Self {
Self {
code: Ok(Default::default()),
message: Ok(Default::default()),
param: Ok(Default::default()),
type_: Ok(Default::default()),
}
}
}
impl ErrorResponseError {
pub fn code<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.code = value
.try_into()
.map_err(|e| format!("error converting supplied value for code: {e}"));
self
}
pub fn message<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.message = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for message: {e}")
});
self
}
pub fn param<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.param = value
.try_into()
.map_err(|e| format!("error converting supplied value for param: {e}"));
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
}
impl ::std::convert::TryFrom<ErrorResponseError> for super::ErrorResponseError {
type Error = super::error::ConversionError;
fn try_from(
value: ErrorResponseError,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
code: value.code?,
message: value.message?,
param: value.param?,
type_: value.type_?,
})
}
}
impl ::std::convert::From<super::ErrorResponseError> for ErrorResponseError {
fn from(value: super::ErrorResponseError) -> Self {
Self {
code: Ok(value.code),
message: Ok(value.message),
param: Ok(value.param),
type_: Ok(value.type_),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
}
/// Where each field of `Input` goes in the request.
pub const ROUTING: ::one::Routing = ::one::Routing { routes: &[::one::Route { field: "fileId", part: ::one::Part::Path, key: Some("fileId") }], required_parts: &[::one::Part::Path] };
/// Builds the `download_file_content` action.
///
/// # Example input
/// ```json
/// {
/// "fileId": "file_abc123"
/// }
/// ```
pub fn build(input: Input) -> ::std::result::Result<Operation<output::Output>, Error> {
::std::result::Result::Ok(Operation::action("conn_mod_def::GOQ4Cvj6LtA::4dW3DoZhRoiAdi4PgsFkow", Method::GET, "/v1/files/{{fileId}}/content").with_routed(&input, &ROUTING)?
.merge_headers(::serde_json::from_str("{\"Accept\":\"application/octet-stream\"}").map_err(Error::Decode)?).returns::<output::Output>())
}
impl IntoOperation for Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
build(self)
}
}
impl IntoOperation for builder::Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
Input::try_from(self).map_err(|error| Error::InvalidInput(::std::boxed::Box::new(error))).and_then(build)
}
}
}
/// Starts building the `download_file_content` action's input; pass the builder to `run`.
pub fn download_file_content() -> download_file_content::builder::Input {
download_file_content::builder::Input::default()
}
pub mod delete_file {
use ::one::{Error, IntoOperation, Method, Operation};
///Deletes a file identified by its file ID. Batches that were already created from the file are not affected.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct Input {
///File identifier. File IDs use the `file_...` format. Send in the URL path.
#[serde(rename = "fileId")]
pub file_id: InputFileId,
}
impl Input {
pub fn builder() -> builder::Input {
Default::default()
}
}
///File identifier. File IDs use the `file_...` format. Send in the URL path.
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct InputFileId(::std::string::String);
impl ::std::ops::Deref for InputFileId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<InputFileId> for ::std::string::String {
fn from(value: InputFileId) -> Self {
value.0
}
}
impl ::std::str::FromStr for InputFileId {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
::std::convert::TryFrom::try_from(value)
}
}
impl ::std::convert::TryFrom<&str> for InputFileId {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<::std::string::String> for InputFileId {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
::std::convert::TryFrom::try_from(value.as_str())
}
}
impl<'de> ::serde::Deserialize<'de> for InputFileId {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::convert::TryFrom::try_from(
::std::string::String::deserialize(deserializer)?,
)
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Input {
file_id: ::std::result::Result<super::InputFileId, ::std::string::String>,
}
impl ::std::default::Default for Input {
fn default() -> Self {
Self {
file_id: Err("no value supplied for file_id".to_string()),
}
}
}
impl Input {
pub fn file_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::InputFileId>,
T::Error: ::std::fmt::Display,
{
self.file_id = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for file_id: {e}")
});
self
}
}
impl ::std::convert::TryFrom<Input> for super::Input {
type Error = super::error::ConversionError;
fn try_from(
value: Input,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self { file_id: value.file_id? })
}
}
impl ::std::convert::From<super::Input> for Input {
fn from(value: super::Input) -> Self {
Self { file_id: Ok(value.file_id) }
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
pub mod output {
///Error details returned for failed requests.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Error {
///HTTP status code associated with the error.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub code: ::std::option::Option<i64>,
///Human-readable error message.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub message: ::std::option::Option<::std::string::String>,
///Parameter that caused the error, when applicable.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub param: ::std::option::Option<::std::string::String>,
///Error type identifier.
#[serde(rename = "type", skip_serializing_if = "::std::option::Option::is_none")]
pub type_: ::std::option::Option<::std::string::String>,
}
impl Error {
pub fn builder() -> builder::Error {
Default::default()
}
}
///Response returned after attempting to delete a file.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Output {
///Indicates whether the file was deleted.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub deleted: ::std::option::Option<bool>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub error: ::std::option::Option<Error>,
///Identifier of the deleted file.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub id: ::std::option::Option<::std::string::String>,
///Object type. Value: `file`.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub object: ::std::option::Option<OutputObject>,
}
impl Output {
pub fn builder() -> builder::Output {
Default::default()
}
}
///Object type. Value: `file`.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum OutputObject {
#[serde(rename = "file")]
File,
}
impl ::std::fmt::Display for OutputObject {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::File => f.write_str("file"),
}
}
}
impl ::std::str::FromStr for OutputObject {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"file" => Ok(Self::File),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for OutputObject {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for OutputObject {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Error {
code: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
message: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
param: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
type_: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for Error {
fn default() -> Self {
Self {
code: Ok(Default::default()),
message: Ok(Default::default()),
param: Ok(Default::default()),
type_: Ok(Default::default()),
}
}
}
impl Error {
pub fn code<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.code = value
.try_into()
.map_err(|e| format!("error converting supplied value for code: {e}"));
self
}
pub fn message<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.message = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for message: {e}")
});
self
}
pub fn param<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.param = value
.try_into()
.map_err(|e| format!("error converting supplied value for param: {e}"));
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
}
impl ::std::convert::TryFrom<Error> for super::Error {
type Error = super::error::ConversionError;
fn try_from(
value: Error,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
code: value.code?,
message: value.message?,
param: value.param?,
type_: value.type_?,
})
}
}
impl ::std::convert::From<super::Error> for Error {
fn from(value: super::Error) -> Self {
Self {
code: Ok(value.code),
message: Ok(value.message),
param: Ok(value.param),
type_: Ok(value.type_),
}
}
}
#[derive(Clone, Debug)]
pub struct Output {
deleted: ::std::result::Result<
::std::option::Option<bool>,
::std::string::String,
>,
error: ::std::result::Result<
::std::option::Option<super::Error>,
::std::string::String,
>,
id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
object: ::std::result::Result<
::std::option::Option<super::OutputObject>,
::std::string::String,
>,
}
impl ::std::default::Default for Output {
fn default() -> Self {
Self {
deleted: Ok(Default::default()),
error: Ok(Default::default()),
id: Ok(Default::default()),
object: Ok(Default::default()),
}
}
}
impl Output {
pub fn deleted<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<bool>>,
T::Error: ::std::fmt::Display,
{
self.deleted = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for deleted: {e}")
});
self
}
pub fn error<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Error>>,
T::Error: ::std::fmt::Display,
{
self.error = value
.try_into()
.map_err(|e| format!("error converting supplied value for error: {e}"));
self
}
pub fn id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.id = value
.try_into()
.map_err(|e| format!("error converting supplied value for id: {e}"));
self
}
pub fn object<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::OutputObject>>,
T::Error: ::std::fmt::Display,
{
self.object = value
.try_into()
.map_err(|e| format!("error converting supplied value for object: {e}"));
self
}
}
impl ::std::convert::TryFrom<Output> for super::Output {
type Error = super::error::ConversionError;
fn try_from(
value: Output,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
deleted: value.deleted?,
error: value.error?,
id: value.id?,
object: value.object?,
})
}
}
impl ::std::convert::From<super::Output> for Output {
fn from(value: super::Output) -> Self {
Self {
deleted: Ok(value.deleted),
error: Ok(value.error),
id: Ok(value.id),
object: Ok(value.object),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
}
/// Where each field of `Input` goes in the request.
pub const ROUTING: ::one::Routing = ::one::Routing { routes: &[::one::Route { field: "fileId", part: ::one::Part::Path, key: Some("fileId") }], required_parts: &[::one::Part::Path] };
/// Builds the `delete_file` action.
///
/// # Example input
/// ```json
/// {
/// "fileId": "file_abc123"
/// }
/// ```
pub fn build(input: Input) -> ::std::result::Result<Operation<output::Output>, Error> {
::std::result::Result::Ok(Operation::action("conn_mod_def::GOQ4CvkDEEA::mgo1j6gNQ3KCkFZENFv7MA", Method::DELETE, "/v1/files/{{fileId}}").with_routed(&input, &ROUTING)?
.merge_headers(::serde_json::from_str("{\"Accept\":\"application/json\"}").map_err(Error::Decode)?).returns::<output::Output>())
}
impl IntoOperation for Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
build(self)
}
}
impl IntoOperation for builder::Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
Input::try_from(self).map_err(|error| Error::InvalidInput(::std::boxed::Box::new(error))).and_then(build)
}
}
}
/// Starts building the `delete_file` action's input; pass the builder to `run`.
pub fn delete_file() -> delete_file::builder::Input {
delete_file::builder::Input::default()
}
pub mod cancel_batch {
use ::one::{Error, IntoOperation, Method, Operation};
///Moves a batch to the `cancelling` state. The batch becomes `cancelled` after its running items stop. Completed items remain in the output file and are billed.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct Input {
///Batch identifier. Must be sent in the URL path and use the `batch_...` format.
#[serde(rename = "batchId")]
pub batch_id: InputBatchId,
}
impl Input {
pub fn builder() -> builder::Input {
Default::default()
}
}
///Batch identifier. Must be sent in the URL path and use the `batch_...` format.
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct InputBatchId(::std::string::String);
impl ::std::ops::Deref for InputBatchId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<InputBatchId> for ::std::string::String {
fn from(value: InputBatchId) -> Self {
value.0
}
}
impl ::std::str::FromStr for InputBatchId {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
::std::convert::TryFrom::try_from(value)
}
}
impl ::std::convert::TryFrom<&str> for InputBatchId {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
static PATTERN: ::std::sync::LazyLock<::regress::Regex> = ::std::sync::LazyLock::new(||
{ ::regress::Regex::with_flags("^batch_.+", "u").unwrap() });
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^batch_.+\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<::std::string::String> for InputBatchId {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
::std::convert::TryFrom::try_from(value.as_str())
}
}
impl<'de> ::serde::Deserialize<'de> for InputBatchId {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::convert::TryFrom::try_from(
::std::string::String::deserialize(deserializer)?,
)
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Input {
batch_id: ::std::result::Result<super::InputBatchId, ::std::string::String>,
}
impl ::std::default::Default for Input {
fn default() -> Self {
Self {
batch_id: Err("no value supplied for batch_id".to_string()),
}
}
}
impl Input {
pub fn batch_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::InputBatchId>,
T::Error: ::std::fmt::Display,
{
self.batch_id = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for batch_id: {e}")
});
self
}
}
impl ::std::convert::TryFrom<Input> for super::Input {
type Error = super::error::ConversionError;
fn try_from(
value: Input,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self { batch_id: value.batch_id? })
}
}
impl ::std::convert::From<super::Input> for Input {
fn from(value: super::Input) -> Self {
Self {
batch_id: Ok(value.batch_id),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
pub mod output {
///Collection of errors associated with the batch.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct BatchErrors {
///List of batch input errors.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub data: ::std::vec::Vec<BatchInputError>,
///Error collection object type. Always `list`.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub object: ::std::option::Option<BatchErrorsObject>,
}
impl BatchErrors {
pub fn builder() -> builder::BatchErrors {
Default::default()
}
}
///Error collection object type. Always `list`.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum BatchErrorsObject {
#[serde(rename = "list")]
List,
}
impl ::std::fmt::Display for BatchErrorsObject {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::List => f.write_str("list"),
}
}
}
impl ::std::str::FromStr for BatchErrorsObject {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"list" => Ok(Self::List),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for BatchErrorsObject {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for BatchErrorsObject {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///An individual batch input error.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct BatchInputError {
///Error code.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub code: ::std::option::Option<::std::string::String>,
///Optional 1-based input line to which the error refers.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub line: ::std::option::Option<i64>,
///Error message.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub message: ::std::option::Option<::std::string::String>,
}
impl BatchInputError {
pub fn builder() -> builder::BatchInputError {
Default::default()
}
}
///Error object returned for failed requests.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Error {
///HTTP status code.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub code: ::std::option::Option<i64>,
///Human-readable error message.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub message: ::std::option::Option<::std::string::String>,
///Optional parameter that caused the error.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub param: ::std::option::Option<::std::string::String>,
///Error type identifier.
#[serde(rename = "type", skip_serializing_if = "::std::option::Option::is_none")]
pub type_: ::std::option::Option<::std::string::String>,
}
impl Error {
pub fn builder() -> builder::Error {
Default::default()
}
}
///Breakdown of input-token usage.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct InputTokenDetails {
///Number of cached input tokens.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub cached_tokens: ::std::option::Option<i64>,
}
impl InputTokenDetails {
pub fn builder() -> builder::InputTokenDetails {
Default::default()
}
}
///Successful response structure from the API, or an error response.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Output {
///Optional Unix timestamp, in seconds, when the batch was cancelled.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub cancelled_at: ::std::option::Option<i64>,
///Optional Unix timestamp, in seconds, when cancellation began.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub cancelling_at: ::std::option::Option<i64>,
///Optional Unix timestamp, in seconds, when the batch completed.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub completed_at: ::std::option::Option<i64>,
///Time window allowed for batch completion.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub completion_window: ::std::option::Option<::std::string::String>,
///Unix timestamp, in seconds, when the batch was created.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub created_at: ::std::option::Option<i64>,
///Endpoint processed by the batch.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub endpoint: ::std::option::Option<::std::string::String>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub error: ::std::option::Option<Error>,
///Optional identifier of the error file.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub error_file_id: ::std::option::Option<::std::string::String>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub errors: ::std::option::Option<BatchErrors>,
///Optional Unix timestamp, in seconds, when the batch expired.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub expired_at: ::std::option::Option<i64>,
///Optional Unix timestamp, in seconds, when the batch expires.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub expires_at: ::std::option::Option<i64>,
///Optional Unix timestamp, in seconds, when the batch failed.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub failed_at: ::std::option::Option<i64>,
///Optional Unix timestamp, in seconds, when finalization began.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub finalizing_at: ::std::option::Option<i64>,
///Unique batch identifier.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub id: ::std::option::Option<::std::string::String>,
///Optional Unix timestamp, in seconds, when processing began.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub in_progress_at: ::std::option::Option<i64>,
///Identifier of the input file used to create the batch.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub input_file_id: ::std::option::Option<::std::string::String>,
///Optional metadata associated with the batch. Each metadata key and value is a string.
#[serde(default, skip_serializing_if = "::std::collections::HashMap::is_empty")]
pub metadata: ::std::collections::HashMap<
::std::string::String,
::std::string::String,
>,
///Object type. Always `batch`.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub object: ::std::option::Option<OutputObject>,
///Optional identifier of the output file containing completed batch results.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub output_file_id: ::std::option::Option<::std::string::String>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub request_counts: ::std::option::Option<RequestCounts>,
///Batch status: `validating`, `in_progress`, `finalizing`, `completed`, `expired`, `cancelling`, `cancelled`, or `failed`.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub status: ::std::option::Option<OutputStatus>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub usage: ::std::option::Option<Usage>,
}
impl Output {
pub fn builder() -> builder::Output {
Default::default()
}
}
///Object type. Always `batch`.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum OutputObject {
#[serde(rename = "batch")]
Batch,
}
impl ::std::fmt::Display for OutputObject {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Batch => f.write_str("batch"),
}
}
}
impl ::std::str::FromStr for OutputObject {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"batch" => Ok(Self::Batch),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for OutputObject {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for OutputObject {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Batch status: `validating`, `in_progress`, `finalizing`, `completed`, `expired`, `cancelling`, `cancelled`, or `failed`.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum OutputStatus {
#[serde(rename = "validating")]
Validating,
#[serde(rename = "in_progress")]
InProgress,
#[serde(rename = "finalizing")]
Finalizing,
#[serde(rename = "completed")]
Completed,
#[serde(rename = "expired")]
Expired,
#[serde(rename = "cancelling")]
Cancelling,
#[serde(rename = "cancelled")]
Cancelled,
#[serde(rename = "failed")]
Failed,
}
impl ::std::fmt::Display for OutputStatus {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Validating => f.write_str("validating"),
Self::InProgress => f.write_str("in_progress"),
Self::Finalizing => f.write_str("finalizing"),
Self::Completed => f.write_str("completed"),
Self::Expired => f.write_str("expired"),
Self::Cancelling => f.write_str("cancelling"),
Self::Cancelled => f.write_str("cancelled"),
Self::Failed => f.write_str("failed"),
}
}
}
impl ::std::str::FromStr for OutputStatus {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"validating" => Ok(Self::Validating),
"in_progress" => Ok(Self::InProgress),
"finalizing" => Ok(Self::Finalizing),
"completed" => Ok(Self::Completed),
"expired" => Ok(Self::Expired),
"cancelling" => Ok(Self::Cancelling),
"cancelled" => Ok(Self::Cancelled),
"failed" => Ok(Self::Failed),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for OutputStatus {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for OutputStatus {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Breakdown of output-token usage.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct OutputTokenDetails {
///Number of reasoning tokens included in output-token usage.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub reasoning_tokens: ::std::option::Option<i64>,
}
impl OutputTokenDetails {
pub fn builder() -> builder::OutputTokenDetails {
Default::default()
}
}
///Counts of requests in the batch.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct RequestCounts {
///Number of completed requests.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub completed: ::std::option::Option<i64>,
///Number of failed requests.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub failed: ::std::option::Option<i64>,
///Total number of requests in the batch.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub total: ::std::option::Option<i64>,
}
impl RequestCounts {
pub fn builder() -> builder::RequestCounts {
Default::default()
}
}
///Token usage for the batch.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Usage {
///Total number of input tokens.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub input_tokens: ::std::option::Option<i64>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub input_tokens_details: ::std::option::Option<InputTokenDetails>,
///Total number of output tokens.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub output_tokens: ::std::option::Option<i64>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub output_tokens_details: ::std::option::Option<OutputTokenDetails>,
///Total number of input and output tokens.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub total_tokens: ::std::option::Option<i64>,
}
impl Usage {
pub fn builder() -> builder::Usage {
Default::default()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct BatchErrors {
data: ::std::result::Result<
::std::vec::Vec<super::BatchInputError>,
::std::string::String,
>,
object: ::std::result::Result<
::std::option::Option<super::BatchErrorsObject>,
::std::string::String,
>,
}
impl ::std::default::Default for BatchErrors {
fn default() -> Self {
Self {
data: Ok(Default::default()),
object: Ok(Default::default()),
}
}
}
impl BatchErrors {
pub fn data<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::BatchInputError>>,
T::Error: ::std::fmt::Display,
{
self.data = value
.try_into()
.map_err(|e| format!("error converting supplied value for data: {e}"));
self
}
pub fn object<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::BatchErrorsObject>>,
T::Error: ::std::fmt::Display,
{
self.object = value
.try_into()
.map_err(|e| format!("error converting supplied value for object: {e}"));
self
}
}
impl ::std::convert::TryFrom<BatchErrors> for super::BatchErrors {
type Error = super::error::ConversionError;
fn try_from(
value: BatchErrors,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
data: value.data?,
object: value.object?,
})
}
}
impl ::std::convert::From<super::BatchErrors> for BatchErrors {
fn from(value: super::BatchErrors) -> Self {
Self {
data: Ok(value.data),
object: Ok(value.object),
}
}
}
#[derive(Clone, Debug)]
pub struct BatchInputError {
code: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
line: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
message: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for BatchInputError {
fn default() -> Self {
Self {
code: Ok(Default::default()),
line: Ok(Default::default()),
message: Ok(Default::default()),
}
}
}
impl BatchInputError {
pub fn code<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.code = value
.try_into()
.map_err(|e| format!("error converting supplied value for code: {e}"));
self
}
pub fn line<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.line = value
.try_into()
.map_err(|e| format!("error converting supplied value for line: {e}"));
self
}
pub fn message<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.message = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for message: {e}")
});
self
}
}
impl ::std::convert::TryFrom<BatchInputError> for super::BatchInputError {
type Error = super::error::ConversionError;
fn try_from(
value: BatchInputError,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
code: value.code?,
line: value.line?,
message: value.message?,
})
}
}
impl ::std::convert::From<super::BatchInputError> for BatchInputError {
fn from(value: super::BatchInputError) -> Self {
Self {
code: Ok(value.code),
line: Ok(value.line),
message: Ok(value.message),
}
}
}
#[derive(Clone, Debug)]
pub struct Error {
code: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
message: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
param: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
type_: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for Error {
fn default() -> Self {
Self {
code: Ok(Default::default()),
message: Ok(Default::default()),
param: Ok(Default::default()),
type_: Ok(Default::default()),
}
}
}
impl Error {
pub fn code<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.code = value
.try_into()
.map_err(|e| format!("error converting supplied value for code: {e}"));
self
}
pub fn message<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.message = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for message: {e}")
});
self
}
pub fn param<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.param = value
.try_into()
.map_err(|e| format!("error converting supplied value for param: {e}"));
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
}
impl ::std::convert::TryFrom<Error> for super::Error {
type Error = super::error::ConversionError;
fn try_from(
value: Error,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
code: value.code?,
message: value.message?,
param: value.param?,
type_: value.type_?,
})
}
}
impl ::std::convert::From<super::Error> for Error {
fn from(value: super::Error) -> Self {
Self {
code: Ok(value.code),
message: Ok(value.message),
param: Ok(value.param),
type_: Ok(value.type_),
}
}
}
#[derive(Clone, Debug)]
pub struct InputTokenDetails {
cached_tokens: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
}
impl ::std::default::Default for InputTokenDetails {
fn default() -> Self {
Self {
cached_tokens: Ok(Default::default()),
}
}
}
impl InputTokenDetails {
pub fn cached_tokens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.cached_tokens = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for cached_tokens: {e}")
});
self
}
}
impl ::std::convert::TryFrom<InputTokenDetails> for super::InputTokenDetails {
type Error = super::error::ConversionError;
fn try_from(
value: InputTokenDetails,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
cached_tokens: value.cached_tokens?,
})
}
}
impl ::std::convert::From<super::InputTokenDetails> for InputTokenDetails {
fn from(value: super::InputTokenDetails) -> Self {
Self {
cached_tokens: Ok(value.cached_tokens),
}
}
}
#[derive(Clone, Debug)]
pub struct Output {
cancelled_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
cancelling_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
completed_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
completion_window: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
created_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
endpoint: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
error: ::std::result::Result<
::std::option::Option<super::Error>,
::std::string::String,
>,
error_file_id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
errors: ::std::result::Result<
::std::option::Option<super::BatchErrors>,
::std::string::String,
>,
expired_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
expires_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
failed_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
finalizing_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
in_progress_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
input_file_id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
metadata: ::std::result::Result<
::std::collections::HashMap<::std::string::String, ::std::string::String>,
::std::string::String,
>,
object: ::std::result::Result<
::std::option::Option<super::OutputObject>,
::std::string::String,
>,
output_file_id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
request_counts: ::std::result::Result<
::std::option::Option<super::RequestCounts>,
::std::string::String,
>,
status: ::std::result::Result<
::std::option::Option<super::OutputStatus>,
::std::string::String,
>,
usage: ::std::result::Result<
::std::option::Option<super::Usage>,
::std::string::String,
>,
}
impl ::std::default::Default for Output {
fn default() -> Self {
Self {
cancelled_at: Ok(Default::default()),
cancelling_at: Ok(Default::default()),
completed_at: Ok(Default::default()),
completion_window: Ok(Default::default()),
created_at: Ok(Default::default()),
endpoint: Ok(Default::default()),
error: Ok(Default::default()),
error_file_id: Ok(Default::default()),
errors: Ok(Default::default()),
expired_at: Ok(Default::default()),
expires_at: Ok(Default::default()),
failed_at: Ok(Default::default()),
finalizing_at: Ok(Default::default()),
id: Ok(Default::default()),
in_progress_at: Ok(Default::default()),
input_file_id: Ok(Default::default()),
metadata: Ok(Default::default()),
object: Ok(Default::default()),
output_file_id: Ok(Default::default()),
request_counts: Ok(Default::default()),
status: Ok(Default::default()),
usage: Ok(Default::default()),
}
}
}
impl Output {
pub fn cancelled_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.cancelled_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for cancelled_at: {e}")
});
self
}
pub fn cancelling_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.cancelling_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for cancelling_at: {e}")
});
self
}
pub fn completed_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.completed_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for completed_at: {e}")
});
self
}
pub fn completion_window<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.completion_window = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for completion_window: {e}")
});
self
}
pub fn created_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.created_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for created_at: {e}")
});
self
}
pub fn endpoint<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.endpoint = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for endpoint: {e}")
});
self
}
pub fn error<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Error>>,
T::Error: ::std::fmt::Display,
{
self.error = value
.try_into()
.map_err(|e| format!("error converting supplied value for error: {e}"));
self
}
pub fn error_file_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.error_file_id = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for error_file_id: {e}")
});
self
}
pub fn errors<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::BatchErrors>>,
T::Error: ::std::fmt::Display,
{
self.errors = value
.try_into()
.map_err(|e| format!("error converting supplied value for errors: {e}"));
self
}
pub fn expired_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.expired_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for expired_at: {e}")
});
self
}
pub fn expires_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.expires_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for expires_at: {e}")
});
self
}
pub fn failed_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.failed_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for failed_at: {e}")
});
self
}
pub fn finalizing_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.finalizing_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for finalizing_at: {e}")
});
self
}
pub fn id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.id = value
.try_into()
.map_err(|e| format!("error converting supplied value for id: {e}"));
self
}
pub fn in_progress_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.in_progress_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for in_progress_at: {e}")
});
self
}
pub fn input_file_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.input_file_id = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for input_file_id: {e}")
});
self
}
pub fn metadata<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::collections::HashMap<::std::string::String, ::std::string::String>,
>,
T::Error: ::std::fmt::Display,
{
self.metadata = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for metadata: {e}")
});
self
}
pub fn object<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::OutputObject>>,
T::Error: ::std::fmt::Display,
{
self.object = value
.try_into()
.map_err(|e| format!("error converting supplied value for object: {e}"));
self
}
pub fn output_file_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.output_file_id = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for output_file_id: {e}")
});
self
}
pub fn request_counts<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::RequestCounts>>,
T::Error: ::std::fmt::Display,
{
self.request_counts = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for request_counts: {e}")
});
self
}
pub fn status<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::OutputStatus>>,
T::Error: ::std::fmt::Display,
{
self.status = value
.try_into()
.map_err(|e| format!("error converting supplied value for status: {e}"));
self
}
pub fn usage<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Usage>>,
T::Error: ::std::fmt::Display,
{
self.usage = value
.try_into()
.map_err(|e| format!("error converting supplied value for usage: {e}"));
self
}
}
impl ::std::convert::TryFrom<Output> for super::Output {
type Error = super::error::ConversionError;
fn try_from(
value: Output,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
cancelled_at: value.cancelled_at?,
cancelling_at: value.cancelling_at?,
completed_at: value.completed_at?,
completion_window: value.completion_window?,
created_at: value.created_at?,
endpoint: value.endpoint?,
error: value.error?,
error_file_id: value.error_file_id?,
errors: value.errors?,
expired_at: value.expired_at?,
expires_at: value.expires_at?,
failed_at: value.failed_at?,
finalizing_at: value.finalizing_at?,
id: value.id?,
in_progress_at: value.in_progress_at?,
input_file_id: value.input_file_id?,
metadata: value.metadata?,
object: value.object?,
output_file_id: value.output_file_id?,
request_counts: value.request_counts?,
status: value.status?,
usage: value.usage?,
})
}
}
impl ::std::convert::From<super::Output> for Output {
fn from(value: super::Output) -> Self {
Self {
cancelled_at: Ok(value.cancelled_at),
cancelling_at: Ok(value.cancelling_at),
completed_at: Ok(value.completed_at),
completion_window: Ok(value.completion_window),
created_at: Ok(value.created_at),
endpoint: Ok(value.endpoint),
error: Ok(value.error),
error_file_id: Ok(value.error_file_id),
errors: Ok(value.errors),
expired_at: Ok(value.expired_at),
expires_at: Ok(value.expires_at),
failed_at: Ok(value.failed_at),
finalizing_at: Ok(value.finalizing_at),
id: Ok(value.id),
in_progress_at: Ok(value.in_progress_at),
input_file_id: Ok(value.input_file_id),
metadata: Ok(value.metadata),
object: Ok(value.object),
output_file_id: Ok(value.output_file_id),
request_counts: Ok(value.request_counts),
status: Ok(value.status),
usage: Ok(value.usage),
}
}
}
#[derive(Clone, Debug)]
pub struct OutputTokenDetails {
reasoning_tokens: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
}
impl ::std::default::Default for OutputTokenDetails {
fn default() -> Self {
Self {
reasoning_tokens: Ok(Default::default()),
}
}
}
impl OutputTokenDetails {
pub fn reasoning_tokens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.reasoning_tokens = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for reasoning_tokens: {e}")
});
self
}
}
impl ::std::convert::TryFrom<OutputTokenDetails> for super::OutputTokenDetails {
type Error = super::error::ConversionError;
fn try_from(
value: OutputTokenDetails,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
reasoning_tokens: value.reasoning_tokens?,
})
}
}
impl ::std::convert::From<super::OutputTokenDetails> for OutputTokenDetails {
fn from(value: super::OutputTokenDetails) -> Self {
Self {
reasoning_tokens: Ok(value.reasoning_tokens),
}
}
}
#[derive(Clone, Debug)]
pub struct RequestCounts {
completed: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
failed: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
total: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
}
impl ::std::default::Default for RequestCounts {
fn default() -> Self {
Self {
completed: Ok(Default::default()),
failed: Ok(Default::default()),
total: Ok(Default::default()),
}
}
}
impl RequestCounts {
pub fn completed<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.completed = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for completed: {e}")
});
self
}
pub fn failed<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.failed = value
.try_into()
.map_err(|e| format!("error converting supplied value for failed: {e}"));
self
}
pub fn total<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.total = value
.try_into()
.map_err(|e| format!("error converting supplied value for total: {e}"));
self
}
}
impl ::std::convert::TryFrom<RequestCounts> for super::RequestCounts {
type Error = super::error::ConversionError;
fn try_from(
value: RequestCounts,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
completed: value.completed?,
failed: value.failed?,
total: value.total?,
})
}
}
impl ::std::convert::From<super::RequestCounts> for RequestCounts {
fn from(value: super::RequestCounts) -> Self {
Self {
completed: Ok(value.completed),
failed: Ok(value.failed),
total: Ok(value.total),
}
}
}
#[derive(Clone, Debug)]
pub struct Usage {
input_tokens: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
input_tokens_details: ::std::result::Result<
::std::option::Option<super::InputTokenDetails>,
::std::string::String,
>,
output_tokens: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
output_tokens_details: ::std::result::Result<
::std::option::Option<super::OutputTokenDetails>,
::std::string::String,
>,
total_tokens: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
}
impl ::std::default::Default for Usage {
fn default() -> Self {
Self {
input_tokens: Ok(Default::default()),
input_tokens_details: Ok(Default::default()),
output_tokens: Ok(Default::default()),
output_tokens_details: Ok(Default::default()),
total_tokens: Ok(Default::default()),
}
}
}
impl Usage {
pub fn input_tokens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.input_tokens = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for input_tokens: {e}")
});
self
}
pub fn input_tokens_details<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::InputTokenDetails>>,
T::Error: ::std::fmt::Display,
{
self.input_tokens_details = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for input_tokens_details: {e}"
)
});
self
}
pub fn output_tokens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.output_tokens = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for output_tokens: {e}")
});
self
}
pub fn output_tokens_details<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::OutputTokenDetails>>,
T::Error: ::std::fmt::Display,
{
self.output_tokens_details = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for output_tokens_details: {e}"
)
});
self
}
pub fn total_tokens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.total_tokens = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for total_tokens: {e}")
});
self
}
}
impl ::std::convert::TryFrom<Usage> for super::Usage {
type Error = super::error::ConversionError;
fn try_from(
value: Usage,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
input_tokens: value.input_tokens?,
input_tokens_details: value.input_tokens_details?,
output_tokens: value.output_tokens?,
output_tokens_details: value.output_tokens_details?,
total_tokens: value.total_tokens?,
})
}
}
impl ::std::convert::From<super::Usage> for Usage {
fn from(value: super::Usage) -> Self {
Self {
input_tokens: Ok(value.input_tokens),
input_tokens_details: Ok(value.input_tokens_details),
output_tokens: Ok(value.output_tokens),
output_tokens_details: Ok(value.output_tokens_details),
total_tokens: Ok(value.total_tokens),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
}
/// Where each field of `Input` goes in the request.
pub const ROUTING: ::one::Routing = ::one::Routing { routes: &[::one::Route { field: "batchId", part: ::one::Part::Path, key: Some("batchId") }], required_parts: &[::one::Part::Path] };
/// Builds the `cancel_batch` action.
///
/// # Example input
/// ```json
/// {
/// "batchId": "batch_abc123"
/// }
/// ```
pub fn build(input: Input) -> ::std::result::Result<Operation<output::Output>, Error> {
::std::result::Result::Ok(Operation::action("conn_mod_def::GOQ4Cvo0xfg::i2gO9cmgT7GY1AwJPA0g8A", Method::POST, "/v1/batches/{{batchId}}/cancel").with_routed(&input, &ROUTING)?
.merge_headers(::serde_json::from_str("{\"Accept\":\"application/json\"}").map_err(Error::Decode)?).returns::<output::Output>())
}
impl IntoOperation for Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
build(self)
}
}
impl IntoOperation for builder::Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
Input::try_from(self).map_err(|error| Error::InvalidInput(::std::boxed::Box::new(error))).and_then(build)
}
}
}
/// Starts building the `cancel_batch` action's input; pass the builder to `run`.
pub fn cancel_batch() -> cancel_batch::builder::Input {
cancel_batch::builder::Input::default()
}
pub mod create_batch {
use ::one::{Error, IntoOperation, Method, Operation};
///HTTP headers for the batch creation request.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Headers {
///A unique, caller-supplied key for this create operation. Repeating a request with the same key returns the originally created batch, making retries safe.
#[serde(
rename = "Idempotency-Key",
skip_serializing_if = "::std::option::Option::is_none"
)]
pub idempotency_key: ::std::option::Option<::std::string::String>,
}
impl Headers {
pub fn builder() -> builder::Headers {
Default::default()
}
}
///Creates a batch from a previously uploaded input file. A newly created batch begins with the `validating` status and is processed within the requested completion window.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct Input {
///Target completion time for the batch. The only supported value is `24h`, which is also the default.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub completion_window: ::std::option::Option<InputCompletionWindow>,
pub headers: Headers,
///ID of a file uploaded with `purpose=batch`. Send in the request body.
pub input_file_id: ::std::string::String,
///Metadata associated with the batch. Each metadata key and value must be a string.
#[serde(default, skip_serializing_if = "::std::collections::HashMap::is_empty")]
pub metadata: ::std::collections::HashMap<
::std::string::String,
::std::string::String,
>,
}
impl Input {
pub fn builder() -> builder::Input {
Default::default()
}
}
///Target completion time for the batch. The only supported value is `24h`, which is also the default.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum InputCompletionWindow {
#[serde(rename = "24h")]
X24h,
}
impl ::std::fmt::Display for InputCompletionWindow {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::X24h => f.write_str("24h"),
}
}
}
impl ::std::str::FromStr for InputCompletionWindow {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"24h" => Ok(Self::X24h),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for InputCompletionWindow {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for InputCompletionWindow {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Headers {
idempotency_key: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for Headers {
fn default() -> Self {
Self {
idempotency_key: Ok(Default::default()),
}
}
}
impl Headers {
pub fn idempotency_key<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.idempotency_key = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for idempotency_key: {e}")
});
self
}
}
impl ::std::convert::TryFrom<Headers> for super::Headers {
type Error = super::error::ConversionError;
fn try_from(
value: Headers,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
idempotency_key: value.idempotency_key?,
})
}
}
impl ::std::convert::From<super::Headers> for Headers {
fn from(value: super::Headers) -> Self {
Self {
idempotency_key: Ok(value.idempotency_key),
}
}
}
#[derive(Clone, Debug)]
pub struct Input {
completion_window: ::std::result::Result<
::std::option::Option<super::InputCompletionWindow>,
::std::string::String,
>,
headers: ::std::result::Result<super::Headers, ::std::string::String>,
input_file_id: ::std::result::Result<
::std::string::String,
::std::string::String,
>,
metadata: ::std::result::Result<
::std::collections::HashMap<::std::string::String, ::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for Input {
fn default() -> Self {
Self {
completion_window: Ok(Default::default()),
headers: Err("no value supplied for headers".to_string()),
input_file_id: Err("no value supplied for input_file_id".to_string()),
metadata: Ok(Default::default()),
}
}
}
impl Input {
pub fn completion_window<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<super::InputCompletionWindow>,
>,
T::Error: ::std::fmt::Display,
{
self.completion_window = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for completion_window: {e}")
});
self
}
pub fn headers<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::Headers>,
T::Error: ::std::fmt::Display,
{
self.headers = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for headers: {e}")
});
self
}
pub fn input_file_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::string::String>,
T::Error: ::std::fmt::Display,
{
self.input_file_id = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for input_file_id: {e}")
});
self
}
pub fn metadata<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::collections::HashMap<::std::string::String, ::std::string::String>,
>,
T::Error: ::std::fmt::Display,
{
self.metadata = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for metadata: {e}")
});
self
}
}
impl ::std::convert::TryFrom<Input> for super::Input {
type Error = super::error::ConversionError;
fn try_from(
value: Input,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
completion_window: value.completion_window?,
headers: value.headers?,
input_file_id: value.input_file_id?,
metadata: value.metadata?,
})
}
}
impl ::std::convert::From<super::Input> for Input {
fn from(value: super::Input) -> Self {
Self {
completion_window: Ok(value.completion_window),
headers: Ok(value.headers),
input_file_id: Ok(value.input_file_id),
metadata: Ok(value.metadata),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
pub mod output {
///Validation and processing errors associated with the batch.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct BatchErrors {
///List of errors associated with individual input lines.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub data: ::std::vec::Vec<BatchErrorsDataItem>,
///Error collection object type. Always `list`.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub object: ::std::option::Option<BatchErrorsObject>,
}
impl BatchErrors {
pub fn builder() -> builder::BatchErrors {
Default::default()
}
}
///`BatchErrorsDataItem`
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct BatchErrorsDataItem {
///Error code.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub code: ::std::option::Option<::std::string::String>,
///One-based input-file line number to which the error refers.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub line: ::std::option::Option<i64>,
///Human-readable error message.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub message: ::std::option::Option<::std::string::String>,
}
impl BatchErrorsDataItem {
pub fn builder() -> builder::BatchErrorsDataItem {
Default::default()
}
}
///Error collection object type. Always `list`.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum BatchErrorsObject {
#[serde(rename = "list")]
List,
}
impl ::std::fmt::Display for BatchErrorsObject {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::List => f.write_str("list"),
}
}
}
impl ::std::str::FromStr for BatchErrorsObject {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"list" => Ok(Self::List),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for BatchErrorsObject {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for BatchErrorsObject {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Error information returned by unsuccessful responses.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Error {
///HTTP status code.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub code: ::std::option::Option<i64>,
///Human-readable error message.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub message: ::std::option::Option<::std::string::String>,
///Parameter that caused the error, when applicable.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub param: ::std::option::Option<::std::string::String>,
///Error type identifier.
#[serde(rename = "type", skip_serializing_if = "::std::option::Option::is_none")]
pub type_: ::std::option::Option<::std::string::String>,
}
impl Error {
pub fn builder() -> builder::Error {
Default::default()
}
}
///Response structure for creating a batch, including success and error responses.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Output {
///Unix timestamp, in seconds, when cancellation completed.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub cancelled_at: ::std::option::Option<i64>,
///Unix timestamp, in seconds, when cancellation began.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub cancelling_at: ::std::option::Option<i64>,
///Unix timestamp, in seconds, when the batch completed.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub completed_at: ::std::option::Option<i64>,
///Requested target completion time.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub completion_window: ::std::option::Option<::std::string::String>,
///Unix timestamp, in seconds, when the batch was created.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub created_at: ::std::option::Option<i64>,
///Endpoint targeted by each request line in the input file.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub endpoint: ::std::option::Option<OutputEndpoint>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub error: ::std::option::Option<Error>,
///ID of the generated error file, when available.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub error_file_id: ::std::option::Option<::std::string::String>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub errors: ::std::option::Option<BatchErrors>,
///Unix timestamp, in seconds, when the batch expired.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub expired_at: ::std::option::Option<i64>,
///Unix timestamp, in seconds, when the batch expired.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub expires_at: ::std::option::Option<i64>,
///Unix timestamp, in seconds, when the batch failed.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub failed_at: ::std::option::Option<i64>,
///Unix timestamp, in seconds, when the batch entered finalization.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub finalizing_at: ::std::option::Option<i64>,
///Unique identifier of the created batch.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub id: ::std::option::Option<::std::string::String>,
///Unix timestamp, in seconds, when processing began.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub in_progress_at: ::std::option::Option<i64>,
///ID of the uploaded batch input file.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub input_file_id: ::std::option::Option<::std::string::String>,
///Batch metadata containing string keys and string values.
#[serde(default, skip_serializing_if = "::std::collections::HashMap::is_empty")]
pub metadata: ::std::collections::HashMap<
::std::string::String,
::std::string::String,
>,
///Object type. Always `batch`.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub object: ::std::option::Option<OutputObject>,
///ID of the generated output file, when available.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub output_file_id: ::std::option::Option<::std::string::String>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub request_counts: ::std::option::Option<RequestCounts>,
///Batch status: `validating`, `in_progress`, `finalizing`, `completed`, `expired`, `cancelling`, `cancelled`, or `failed`.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub status: ::std::option::Option<OutputStatus>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub usage: ::std::option::Option<Usage>,
}
impl Output {
pub fn builder() -> builder::Output {
Default::default()
}
}
///Endpoint targeted by each request line in the input file.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum OutputEndpoint {
#[serde(rename = "/v1/responses")]
V1Responses,
}
impl ::std::fmt::Display for OutputEndpoint {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::V1Responses => f.write_str("/v1/responses"),
}
}
}
impl ::std::str::FromStr for OutputEndpoint {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"/v1/responses" => Ok(Self::V1Responses),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for OutputEndpoint {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for OutputEndpoint {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Object type. Always `batch`.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum OutputObject {
#[serde(rename = "batch")]
Batch,
}
impl ::std::fmt::Display for OutputObject {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Batch => f.write_str("batch"),
}
}
}
impl ::std::str::FromStr for OutputObject {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"batch" => Ok(Self::Batch),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for OutputObject {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for OutputObject {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Batch status: `validating`, `in_progress`, `finalizing`, `completed`, `expired`, `cancelling`, `cancelled`, or `failed`.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum OutputStatus {
#[serde(rename = "validating")]
Validating,
#[serde(rename = "in_progress")]
InProgress,
#[serde(rename = "finalizing")]
Finalizing,
#[serde(rename = "completed")]
Completed,
#[serde(rename = "expired")]
Expired,
#[serde(rename = "cancelling")]
Cancelling,
#[serde(rename = "cancelled")]
Cancelled,
#[serde(rename = "failed")]
Failed,
}
impl ::std::fmt::Display for OutputStatus {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Validating => f.write_str("validating"),
Self::InProgress => f.write_str("in_progress"),
Self::Finalizing => f.write_str("finalizing"),
Self::Completed => f.write_str("completed"),
Self::Expired => f.write_str("expired"),
Self::Cancelling => f.write_str("cancelling"),
Self::Cancelled => f.write_str("cancelled"),
Self::Failed => f.write_str("failed"),
}
}
}
impl ::std::str::FromStr for OutputStatus {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"validating" => Ok(Self::Validating),
"in_progress" => Ok(Self::InProgress),
"finalizing" => Ok(Self::Finalizing),
"completed" => Ok(Self::Completed),
"expired" => Ok(Self::Expired),
"cancelling" => Ok(Self::Cancelling),
"cancelled" => Ok(Self::Cancelled),
"failed" => Ok(Self::Failed),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for OutputStatus {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for OutputStatus {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Counts of requests in the batch.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct RequestCounts {
///Number of successfully completed requests.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub completed: ::std::option::Option<i64>,
///Number of failed requests.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub failed: ::std::option::Option<i64>,
///Total number of requests in the batch.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub total: ::std::option::Option<i64>,
}
impl RequestCounts {
pub fn builder() -> builder::RequestCounts {
Default::default()
}
}
///Token usage for the batch.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Usage {
///Total number of input tokens used.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub input_tokens: ::std::option::Option<i64>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub input_tokens_details: ::std::option::Option<UsageInputTokensDetails>,
///Total number of output tokens used.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub output_tokens: ::std::option::Option<i64>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub output_tokens_details: ::std::option::Option<UsageOutputTokensDetails>,
///Total number of input and output tokens used.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub total_tokens: ::std::option::Option<i64>,
}
impl Usage {
pub fn builder() -> builder::Usage {
Default::default()
}
}
///Detailed input-token usage information.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct UsageInputTokensDetails {
///Number of cached input tokens.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub cached_tokens: ::std::option::Option<i64>,
}
impl UsageInputTokensDetails {
pub fn builder() -> builder::UsageInputTokensDetails {
Default::default()
}
}
///Detailed output-token usage information.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct UsageOutputTokensDetails {
///Number of reasoning tokens used.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub reasoning_tokens: ::std::option::Option<i64>,
}
impl UsageOutputTokensDetails {
pub fn builder() -> builder::UsageOutputTokensDetails {
Default::default()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct BatchErrors {
data: ::std::result::Result<
::std::vec::Vec<super::BatchErrorsDataItem>,
::std::string::String,
>,
object: ::std::result::Result<
::std::option::Option<super::BatchErrorsObject>,
::std::string::String,
>,
}
impl ::std::default::Default for BatchErrors {
fn default() -> Self {
Self {
data: Ok(Default::default()),
object: Ok(Default::default()),
}
}
}
impl BatchErrors {
pub fn data<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::BatchErrorsDataItem>>,
T::Error: ::std::fmt::Display,
{
self.data = value
.try_into()
.map_err(|e| format!("error converting supplied value for data: {e}"));
self
}
pub fn object<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::BatchErrorsObject>>,
T::Error: ::std::fmt::Display,
{
self.object = value
.try_into()
.map_err(|e| format!("error converting supplied value for object: {e}"));
self
}
}
impl ::std::convert::TryFrom<BatchErrors> for super::BatchErrors {
type Error = super::error::ConversionError;
fn try_from(
value: BatchErrors,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
data: value.data?,
object: value.object?,
})
}
}
impl ::std::convert::From<super::BatchErrors> for BatchErrors {
fn from(value: super::BatchErrors) -> Self {
Self {
data: Ok(value.data),
object: Ok(value.object),
}
}
}
#[derive(Clone, Debug)]
pub struct BatchErrorsDataItem {
code: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
line: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
message: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for BatchErrorsDataItem {
fn default() -> Self {
Self {
code: Ok(Default::default()),
line: Ok(Default::default()),
message: Ok(Default::default()),
}
}
}
impl BatchErrorsDataItem {
pub fn code<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.code = value
.try_into()
.map_err(|e| format!("error converting supplied value for code: {e}"));
self
}
pub fn line<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.line = value
.try_into()
.map_err(|e| format!("error converting supplied value for line: {e}"));
self
}
pub fn message<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.message = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for message: {e}")
});
self
}
}
impl ::std::convert::TryFrom<BatchErrorsDataItem> for super::BatchErrorsDataItem {
type Error = super::error::ConversionError;
fn try_from(
value: BatchErrorsDataItem,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
code: value.code?,
line: value.line?,
message: value.message?,
})
}
}
impl ::std::convert::From<super::BatchErrorsDataItem> for BatchErrorsDataItem {
fn from(value: super::BatchErrorsDataItem) -> Self {
Self {
code: Ok(value.code),
line: Ok(value.line),
message: Ok(value.message),
}
}
}
#[derive(Clone, Debug)]
pub struct Error {
code: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
message: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
param: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
type_: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for Error {
fn default() -> Self {
Self {
code: Ok(Default::default()),
message: Ok(Default::default()),
param: Ok(Default::default()),
type_: Ok(Default::default()),
}
}
}
impl Error {
pub fn code<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.code = value
.try_into()
.map_err(|e| format!("error converting supplied value for code: {e}"));
self
}
pub fn message<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.message = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for message: {e}")
});
self
}
pub fn param<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.param = value
.try_into()
.map_err(|e| format!("error converting supplied value for param: {e}"));
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
}
impl ::std::convert::TryFrom<Error> for super::Error {
type Error = super::error::ConversionError;
fn try_from(
value: Error,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
code: value.code?,
message: value.message?,
param: value.param?,
type_: value.type_?,
})
}
}
impl ::std::convert::From<super::Error> for Error {
fn from(value: super::Error) -> Self {
Self {
code: Ok(value.code),
message: Ok(value.message),
param: Ok(value.param),
type_: Ok(value.type_),
}
}
}
#[derive(Clone, Debug)]
pub struct Output {
cancelled_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
cancelling_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
completed_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
completion_window: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
created_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
endpoint: ::std::result::Result<
::std::option::Option<super::OutputEndpoint>,
::std::string::String,
>,
error: ::std::result::Result<
::std::option::Option<super::Error>,
::std::string::String,
>,
error_file_id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
errors: ::std::result::Result<
::std::option::Option<super::BatchErrors>,
::std::string::String,
>,
expired_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
expires_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
failed_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
finalizing_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
in_progress_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
input_file_id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
metadata: ::std::result::Result<
::std::collections::HashMap<::std::string::String, ::std::string::String>,
::std::string::String,
>,
object: ::std::result::Result<
::std::option::Option<super::OutputObject>,
::std::string::String,
>,
output_file_id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
request_counts: ::std::result::Result<
::std::option::Option<super::RequestCounts>,
::std::string::String,
>,
status: ::std::result::Result<
::std::option::Option<super::OutputStatus>,
::std::string::String,
>,
usage: ::std::result::Result<
::std::option::Option<super::Usage>,
::std::string::String,
>,
}
impl ::std::default::Default for Output {
fn default() -> Self {
Self {
cancelled_at: Ok(Default::default()),
cancelling_at: Ok(Default::default()),
completed_at: Ok(Default::default()),
completion_window: Ok(Default::default()),
created_at: Ok(Default::default()),
endpoint: Ok(Default::default()),
error: Ok(Default::default()),
error_file_id: Ok(Default::default()),
errors: Ok(Default::default()),
expired_at: Ok(Default::default()),
expires_at: Ok(Default::default()),
failed_at: Ok(Default::default()),
finalizing_at: Ok(Default::default()),
id: Ok(Default::default()),
in_progress_at: Ok(Default::default()),
input_file_id: Ok(Default::default()),
metadata: Ok(Default::default()),
object: Ok(Default::default()),
output_file_id: Ok(Default::default()),
request_counts: Ok(Default::default()),
status: Ok(Default::default()),
usage: Ok(Default::default()),
}
}
}
impl Output {
pub fn cancelled_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.cancelled_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for cancelled_at: {e}")
});
self
}
pub fn cancelling_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.cancelling_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for cancelling_at: {e}")
});
self
}
pub fn completed_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.completed_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for completed_at: {e}")
});
self
}
pub fn completion_window<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.completion_window = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for completion_window: {e}")
});
self
}
pub fn created_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.created_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for created_at: {e}")
});
self
}
pub fn endpoint<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::OutputEndpoint>>,
T::Error: ::std::fmt::Display,
{
self.endpoint = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for endpoint: {e}")
});
self
}
pub fn error<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Error>>,
T::Error: ::std::fmt::Display,
{
self.error = value
.try_into()
.map_err(|e| format!("error converting supplied value for error: {e}"));
self
}
pub fn error_file_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.error_file_id = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for error_file_id: {e}")
});
self
}
pub fn errors<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::BatchErrors>>,
T::Error: ::std::fmt::Display,
{
self.errors = value
.try_into()
.map_err(|e| format!("error converting supplied value for errors: {e}"));
self
}
pub fn expired_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.expired_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for expired_at: {e}")
});
self
}
pub fn expires_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.expires_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for expires_at: {e}")
});
self
}
pub fn failed_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.failed_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for failed_at: {e}")
});
self
}
pub fn finalizing_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.finalizing_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for finalizing_at: {e}")
});
self
}
pub fn id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.id = value
.try_into()
.map_err(|e| format!("error converting supplied value for id: {e}"));
self
}
pub fn in_progress_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.in_progress_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for in_progress_at: {e}")
});
self
}
pub fn input_file_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.input_file_id = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for input_file_id: {e}")
});
self
}
pub fn metadata<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::collections::HashMap<::std::string::String, ::std::string::String>,
>,
T::Error: ::std::fmt::Display,
{
self.metadata = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for metadata: {e}")
});
self
}
pub fn object<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::OutputObject>>,
T::Error: ::std::fmt::Display,
{
self.object = value
.try_into()
.map_err(|e| format!("error converting supplied value for object: {e}"));
self
}
pub fn output_file_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.output_file_id = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for output_file_id: {e}")
});
self
}
pub fn request_counts<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::RequestCounts>>,
T::Error: ::std::fmt::Display,
{
self.request_counts = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for request_counts: {e}")
});
self
}
pub fn status<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::OutputStatus>>,
T::Error: ::std::fmt::Display,
{
self.status = value
.try_into()
.map_err(|e| format!("error converting supplied value for status: {e}"));
self
}
pub fn usage<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Usage>>,
T::Error: ::std::fmt::Display,
{
self.usage = value
.try_into()
.map_err(|e| format!("error converting supplied value for usage: {e}"));
self
}
}
impl ::std::convert::TryFrom<Output> for super::Output {
type Error = super::error::ConversionError;
fn try_from(
value: Output,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
cancelled_at: value.cancelled_at?,
cancelling_at: value.cancelling_at?,
completed_at: value.completed_at?,
completion_window: value.completion_window?,
created_at: value.created_at?,
endpoint: value.endpoint?,
error: value.error?,
error_file_id: value.error_file_id?,
errors: value.errors?,
expired_at: value.expired_at?,
expires_at: value.expires_at?,
failed_at: value.failed_at?,
finalizing_at: value.finalizing_at?,
id: value.id?,
in_progress_at: value.in_progress_at?,
input_file_id: value.input_file_id?,
metadata: value.metadata?,
object: value.object?,
output_file_id: value.output_file_id?,
request_counts: value.request_counts?,
status: value.status?,
usage: value.usage?,
})
}
}
impl ::std::convert::From<super::Output> for Output {
fn from(value: super::Output) -> Self {
Self {
cancelled_at: Ok(value.cancelled_at),
cancelling_at: Ok(value.cancelling_at),
completed_at: Ok(value.completed_at),
completion_window: Ok(value.completion_window),
created_at: Ok(value.created_at),
endpoint: Ok(value.endpoint),
error: Ok(value.error),
error_file_id: Ok(value.error_file_id),
errors: Ok(value.errors),
expired_at: Ok(value.expired_at),
expires_at: Ok(value.expires_at),
failed_at: Ok(value.failed_at),
finalizing_at: Ok(value.finalizing_at),
id: Ok(value.id),
in_progress_at: Ok(value.in_progress_at),
input_file_id: Ok(value.input_file_id),
metadata: Ok(value.metadata),
object: Ok(value.object),
output_file_id: Ok(value.output_file_id),
request_counts: Ok(value.request_counts),
status: Ok(value.status),
usage: Ok(value.usage),
}
}
}
#[derive(Clone, Debug)]
pub struct RequestCounts {
completed: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
failed: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
total: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
}
impl ::std::default::Default for RequestCounts {
fn default() -> Self {
Self {
completed: Ok(Default::default()),
failed: Ok(Default::default()),
total: Ok(Default::default()),
}
}
}
impl RequestCounts {
pub fn completed<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.completed = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for completed: {e}")
});
self
}
pub fn failed<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.failed = value
.try_into()
.map_err(|e| format!("error converting supplied value for failed: {e}"));
self
}
pub fn total<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.total = value
.try_into()
.map_err(|e| format!("error converting supplied value for total: {e}"));
self
}
}
impl ::std::convert::TryFrom<RequestCounts> for super::RequestCounts {
type Error = super::error::ConversionError;
fn try_from(
value: RequestCounts,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
completed: value.completed?,
failed: value.failed?,
total: value.total?,
})
}
}
impl ::std::convert::From<super::RequestCounts> for RequestCounts {
fn from(value: super::RequestCounts) -> Self {
Self {
completed: Ok(value.completed),
failed: Ok(value.failed),
total: Ok(value.total),
}
}
}
#[derive(Clone, Debug)]
pub struct Usage {
input_tokens: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
input_tokens_details: ::std::result::Result<
::std::option::Option<super::UsageInputTokensDetails>,
::std::string::String,
>,
output_tokens: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
output_tokens_details: ::std::result::Result<
::std::option::Option<super::UsageOutputTokensDetails>,
::std::string::String,
>,
total_tokens: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
}
impl ::std::default::Default for Usage {
fn default() -> Self {
Self {
input_tokens: Ok(Default::default()),
input_tokens_details: Ok(Default::default()),
output_tokens: Ok(Default::default()),
output_tokens_details: Ok(Default::default()),
total_tokens: Ok(Default::default()),
}
}
}
impl Usage {
pub fn input_tokens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.input_tokens = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for input_tokens: {e}")
});
self
}
pub fn input_tokens_details<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<super::UsageInputTokensDetails>,
>,
T::Error: ::std::fmt::Display,
{
self.input_tokens_details = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for input_tokens_details: {e}"
)
});
self
}
pub fn output_tokens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.output_tokens = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for output_tokens: {e}")
});
self
}
pub fn output_tokens_details<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<super::UsageOutputTokensDetails>,
>,
T::Error: ::std::fmt::Display,
{
self.output_tokens_details = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for output_tokens_details: {e}"
)
});
self
}
pub fn total_tokens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.total_tokens = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for total_tokens: {e}")
});
self
}
}
impl ::std::convert::TryFrom<Usage> for super::Usage {
type Error = super::error::ConversionError;
fn try_from(
value: Usage,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
input_tokens: value.input_tokens?,
input_tokens_details: value.input_tokens_details?,
output_tokens: value.output_tokens?,
output_tokens_details: value.output_tokens_details?,
total_tokens: value.total_tokens?,
})
}
}
impl ::std::convert::From<super::Usage> for Usage {
fn from(value: super::Usage) -> Self {
Self {
input_tokens: Ok(value.input_tokens),
input_tokens_details: Ok(value.input_tokens_details),
output_tokens: Ok(value.output_tokens),
output_tokens_details: Ok(value.output_tokens_details),
total_tokens: Ok(value.total_tokens),
}
}
}
#[derive(Clone, Debug)]
pub struct UsageInputTokensDetails {
cached_tokens: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
}
impl ::std::default::Default for UsageInputTokensDetails {
fn default() -> Self {
Self {
cached_tokens: Ok(Default::default()),
}
}
}
impl UsageInputTokensDetails {
pub fn cached_tokens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.cached_tokens = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for cached_tokens: {e}")
});
self
}
}
impl ::std::convert::TryFrom<UsageInputTokensDetails>
for super::UsageInputTokensDetails {
type Error = super::error::ConversionError;
fn try_from(
value: UsageInputTokensDetails,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
cached_tokens: value.cached_tokens?,
})
}
}
impl ::std::convert::From<super::UsageInputTokensDetails>
for UsageInputTokensDetails {
fn from(value: super::UsageInputTokensDetails) -> Self {
Self {
cached_tokens: Ok(value.cached_tokens),
}
}
}
#[derive(Clone, Debug)]
pub struct UsageOutputTokensDetails {
reasoning_tokens: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
}
impl ::std::default::Default for UsageOutputTokensDetails {
fn default() -> Self {
Self {
reasoning_tokens: Ok(Default::default()),
}
}
}
impl UsageOutputTokensDetails {
pub fn reasoning_tokens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.reasoning_tokens = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for reasoning_tokens: {e}")
});
self
}
}
impl ::std::convert::TryFrom<UsageOutputTokensDetails>
for super::UsageOutputTokensDetails {
type Error = super::error::ConversionError;
fn try_from(
value: UsageOutputTokensDetails,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
reasoning_tokens: value.reasoning_tokens?,
})
}
}
impl ::std::convert::From<super::UsageOutputTokensDetails>
for UsageOutputTokensDetails {
fn from(value: super::UsageOutputTokensDetails) -> Self {
Self {
reasoning_tokens: Ok(value.reasoning_tokens),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
}
/// Where each field of `Input` goes in the request.
pub const ROUTING: ::one::Routing = ::one::Routing { routes: &[::one::Route { field: "completion_window", part: ::one::Part::Body, key: Some("completion_window") }, ::one::Route { field: "input_file_id", part: ::one::Part::Body, key: Some("input_file_id") }, ::one::Route { field: "metadata", part: ::one::Part::Body, key: Some("metadata") }, ::one::Route { field: "headers", part: ::one::Part::Headers, key: None }], required_parts: &[::one::Part::Body] };
/// Builds the `create_batch` action.
///
/// # Example input
/// ```json
/// {
/// "completion_window": "24h",
/// "headers": {
/// "Accept": "application/json",
/// "Content-Type": "application/json",
/// "Idempotency-Key": "batch-create-20250213-01"
/// },
/// "input_file_id": "file_batch_input_01JQ6M4A7KD3P9N2X8R5",
/// "metadata": {
/// "environment": "production",
/// "project": "support-ticket-classification"
/// }
/// }
/// ```
pub fn build(input: Input) -> ::std::result::Result<Operation<output::Output>, Error> {
::std::result::Result::Ok(Operation::action("conn_mod_def::GOQ4Cvwn-tg::U4xxnqWXRx6MfT8y3dns8g", Method::POST, "/v1/batches").with_routed(&input, &ROUTING)?
.merge_body(::serde_json::from_str("{\"endpoint\":\"/v1/responses\"}").map_err(Error::Decode)?)?
.merge_headers(::serde_json::from_str("{\"Accept\":\"application/json\",\"Content-Type\":\"application/json\"}").map_err(Error::Decode)?).returns::<output::Output>())
}
impl IntoOperation for Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
build(self)
}
}
impl IntoOperation for builder::Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
Input::try_from(self).map_err(|error| Error::InvalidInput(::std::boxed::Box::new(error))).and_then(build)
}
}
impl ::std::convert::TryFrom<builder::Headers> for ::std::option::Option<Headers> {
type Error = <Headers as ::std::convert::TryFrom<builder::Headers>>::Error;
fn try_from(value: builder::Headers) -> ::std::result::Result<Self, Self::Error> {
Headers::try_from(value).map(Some)
}
}
}
/// Starts building the `create_batch` action's input; pass the builder to `run`.
pub fn create_batch() -> create_batch::builder::Input {
create_batch::builder::Input::default()
}
pub mod list_batches {
use ::one::{Error, IntoOperation, Method, Operation};
///Lists the organization's batches in newest-first order. The response is paginated and can be continued by supplying the previous page's `last_id` as the `after_id` query parameter.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
#[serde(deny_unknown_fields)]
pub struct Input {
///Batch ID after which to start the page. Use the `last_id` from the previous page to retrieve the next page. Send as a URL query parameter.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub after_id: ::std::option::Option<::std::string::String>,
///Maximum number of batches to return. Send as a URL query parameter.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub limit: ::std::option::Option<i64>,
}
impl Input {
pub fn builder() -> builder::Input {
Default::default()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Input {
after_id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
limit: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
}
impl ::std::default::Default for Input {
fn default() -> Self {
Self {
after_id: Ok(Default::default()),
limit: Ok(Default::default()),
}
}
}
impl Input {
pub fn after_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.after_id = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for after_id: {e}")
});
self
}
pub fn limit<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.limit = value
.try_into()
.map_err(|e| format!("error converting supplied value for limit: {e}"));
self
}
}
impl ::std::convert::TryFrom<Input> for super::Input {
type Error = super::error::ConversionError;
fn try_from(
value: Input,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
after_id: value.after_id?,
limit: value.limit?,
})
}
}
impl ::std::convert::From<super::Input> for Input {
fn from(value: super::Input) -> Self {
Self {
after_id: Ok(value.after_id),
limit: Ok(value.limit),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
pub mod output {
///A batch record.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
pub struct Batch {
///Time cancellation completed, as Unix seconds.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub cancelled_at: ::std::option::Option<i64>,
///Time cancellation began, as Unix seconds.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub cancelling_at: ::std::option::Option<i64>,
///Time completion occurred, as Unix seconds.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub completed_at: ::std::option::Option<i64>,
///Batch completion window.
pub completion_window: ::std::string::String,
///Batch creation time as Unix seconds.
pub created_at: i64,
///Endpoint associated with the batch.
pub endpoint: ::std::string::String,
///Identifier of the error file.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub error_file_id: ::std::option::Option<::std::string::String>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub errors: ::std::option::Option<BatchErrorCollection>,
///Time expiration occurred, as Unix seconds.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub expired_at: ::std::option::Option<i64>,
///Batch expiration time, as Unix seconds.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub expires_at: ::std::option::Option<i64>,
///Time failure occurred, as Unix seconds.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub failed_at: ::std::option::Option<i64>,
///Time finalization began, as Unix seconds.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub finalizing_at: ::std::option::Option<i64>,
///Unique batch identifier.
pub id: ::std::string::String,
///Time processing began, as Unix seconds.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub in_progress_at: ::std::option::Option<i64>,
///Identifier of the batch input file.
pub input_file_id: ::std::string::String,
///String key-value metadata associated with the batch.
#[serde(default, skip_serializing_if = "::std::collections::HashMap::is_empty")]
pub metadata: ::std::collections::HashMap<
::std::string::String,
::std::string::String,
>,
///Object type for the batch. Value: `batch`.
pub object: BatchObject,
///Identifier of the output file.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub output_file_id: ::std::option::Option<::std::string::String>,
///Batch request-count summary (`BatchRequestCounts`). Its nested fields are not specified in the provided documentation.
pub request_counts: ::serde_json::Map<::std::string::String, ::serde_json::Value>,
///Batch status.
pub status: BatchStatus,
///Batch usage summary (`BatchUsage`). Its nested fields are not specified in the provided documentation.
pub usage: ::serde_json::Map<::std::string::String, ::serde_json::Value>,
}
impl Batch {
pub fn builder() -> builder::Batch {
Default::default()
}
}
///An individual batch error object.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
pub struct BatchError {
///Error code.
pub code: ::std::string::String,
///One-based input line to which the error refers.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub line: ::std::option::Option<i64>,
///Human-readable error message.
pub message: ::std::string::String,
}
impl BatchError {
pub fn builder() -> builder::BatchError {
Default::default()
}
}
///Error collection for the batch.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
pub struct BatchErrorCollection {
///Array of batch error objects.
pub data: ::std::vec::Vec<BatchError>,
///Object type for the error collection. Value: `list`.
pub object: BatchErrorCollectionObject,
}
impl BatchErrorCollection {
pub fn builder() -> builder::BatchErrorCollection {
Default::default()
}
}
///Object type for the error collection. Value: `list`.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum BatchErrorCollectionObject {
#[serde(rename = "list")]
List,
}
impl ::std::fmt::Display for BatchErrorCollectionObject {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::List => f.write_str("list"),
}
}
}
impl ::std::str::FromStr for BatchErrorCollectionObject {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"list" => Ok(Self::List),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for BatchErrorCollectionObject {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for BatchErrorCollectionObject {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Object type for the batch. Value: `batch`.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum BatchObject {
#[serde(rename = "batch")]
Batch,
}
impl ::std::fmt::Display for BatchObject {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Batch => f.write_str("batch"),
}
}
}
impl ::std::str::FromStr for BatchObject {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"batch" => Ok(Self::Batch),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for BatchObject {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for BatchObject {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Batch status.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum BatchStatus {
#[serde(rename = "validating")]
Validating,
#[serde(rename = "in_progress")]
InProgress,
#[serde(rename = "finalizing")]
Finalizing,
#[serde(rename = "completed")]
Completed,
#[serde(rename = "expired")]
Expired,
#[serde(rename = "cancelling")]
Cancelling,
#[serde(rename = "cancelled")]
Cancelled,
#[serde(rename = "failed")]
Failed,
}
impl ::std::fmt::Display for BatchStatus {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Validating => f.write_str("validating"),
Self::InProgress => f.write_str("in_progress"),
Self::Finalizing => f.write_str("finalizing"),
Self::Completed => f.write_str("completed"),
Self::Expired => f.write_str("expired"),
Self::Cancelling => f.write_str("cancelling"),
Self::Cancelled => f.write_str("cancelled"),
Self::Failed => f.write_str("failed"),
}
}
}
impl ::std::str::FromStr for BatchStatus {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"validating" => Ok(Self::Validating),
"in_progress" => Ok(Self::InProgress),
"finalizing" => Ok(Self::Finalizing),
"completed" => Ok(Self::Completed),
"expired" => Ok(Self::Expired),
"cancelling" => Ok(Self::Cancelling),
"cancelled" => Ok(Self::Cancelled),
"failed" => Ok(Self::Failed),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for BatchStatus {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for BatchStatus {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Error object returned for client errors.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
pub struct Error {
///HTTP status code.
pub code: i64,
///Human-readable error message.
pub message: ::std::string::String,
///Parameter that caused the error.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub param: ::std::option::Option<::std::string::String>,
///Error type identifier.
#[serde(rename = "type")]
pub type_: ::std::string::String,
}
impl Error {
pub fn builder() -> builder::Error {
Default::default()
}
}
///Response for listing the organization's batches, including successful paginated results and error responses.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Output {
///Array of batch objects, ordered newest first.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub data: ::std::vec::Vec<Batch>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub error: ::std::option::Option<Error>,
///Identifier of the first batch in the returned page.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub first_id: ::std::option::Option<::std::string::String>,
///Whether additional pages of batches are available.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub has_more: ::std::option::Option<bool>,
///Identifier of the last batch in the returned page. Use this value as `after_id` to request the next page.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub last_id: ::std::option::Option<::std::string::String>,
///Object type for the page. Value: `list`.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub object: ::std::option::Option<OutputObject>,
}
impl Output {
pub fn builder() -> builder::Output {
Default::default()
}
}
///Object type for the page. Value: `list`.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum OutputObject {
#[serde(rename = "list")]
List,
}
impl ::std::fmt::Display for OutputObject {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::List => f.write_str("list"),
}
}
}
impl ::std::str::FromStr for OutputObject {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"list" => Ok(Self::List),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for OutputObject {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for OutputObject {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Batch {
cancelled_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
cancelling_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
completed_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
completion_window: ::std::result::Result<
::std::string::String,
::std::string::String,
>,
created_at: ::std::result::Result<i64, ::std::string::String>,
endpoint: ::std::result::Result<::std::string::String, ::std::string::String>,
error_file_id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
errors: ::std::result::Result<
::std::option::Option<super::BatchErrorCollection>,
::std::string::String,
>,
expired_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
expires_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
failed_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
finalizing_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
id: ::std::result::Result<::std::string::String, ::std::string::String>,
in_progress_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
input_file_id: ::std::result::Result<
::std::string::String,
::std::string::String,
>,
metadata: ::std::result::Result<
::std::collections::HashMap<::std::string::String, ::std::string::String>,
::std::string::String,
>,
object: ::std::result::Result<super::BatchObject, ::std::string::String>,
output_file_id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
request_counts: ::std::result::Result<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
::std::string::String,
>,
status: ::std::result::Result<super::BatchStatus, ::std::string::String>,
usage: ::std::result::Result<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
::std::string::String,
>,
}
impl ::std::default::Default for Batch {
fn default() -> Self {
Self {
cancelled_at: Ok(Default::default()),
cancelling_at: Ok(Default::default()),
completed_at: Ok(Default::default()),
completion_window: Err(
"no value supplied for completion_window".to_string(),
),
created_at: Err("no value supplied for created_at".to_string()),
endpoint: Err("no value supplied for endpoint".to_string()),
error_file_id: Ok(Default::default()),
errors: Ok(Default::default()),
expired_at: Ok(Default::default()),
expires_at: Ok(Default::default()),
failed_at: Ok(Default::default()),
finalizing_at: Ok(Default::default()),
id: Err("no value supplied for id".to_string()),
in_progress_at: Ok(Default::default()),
input_file_id: Err("no value supplied for input_file_id".to_string()),
metadata: Ok(Default::default()),
object: Err("no value supplied for object".to_string()),
output_file_id: Ok(Default::default()),
request_counts: Err("no value supplied for request_counts".to_string()),
status: Err("no value supplied for status".to_string()),
usage: Err("no value supplied for usage".to_string()),
}
}
}
impl Batch {
pub fn cancelled_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.cancelled_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for cancelled_at: {e}")
});
self
}
pub fn cancelling_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.cancelling_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for cancelling_at: {e}")
});
self
}
pub fn completed_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.completed_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for completed_at: {e}")
});
self
}
pub fn completion_window<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::string::String>,
T::Error: ::std::fmt::Display,
{
self.completion_window = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for completion_window: {e}")
});
self
}
pub fn created_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<i64>,
T::Error: ::std::fmt::Display,
{
self.created_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for created_at: {e}")
});
self
}
pub fn endpoint<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::string::String>,
T::Error: ::std::fmt::Display,
{
self.endpoint = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for endpoint: {e}")
});
self
}
pub fn error_file_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.error_file_id = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for error_file_id: {e}")
});
self
}
pub fn errors<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<super::BatchErrorCollection>,
>,
T::Error: ::std::fmt::Display,
{
self.errors = value
.try_into()
.map_err(|e| format!("error converting supplied value for errors: {e}"));
self
}
pub fn expired_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.expired_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for expired_at: {e}")
});
self
}
pub fn expires_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.expires_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for expires_at: {e}")
});
self
}
pub fn failed_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.failed_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for failed_at: {e}")
});
self
}
pub fn finalizing_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.finalizing_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for finalizing_at: {e}")
});
self
}
pub fn id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::string::String>,
T::Error: ::std::fmt::Display,
{
self.id = value
.try_into()
.map_err(|e| format!("error converting supplied value for id: {e}"));
self
}
pub fn in_progress_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.in_progress_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for in_progress_at: {e}")
});
self
}
pub fn input_file_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::string::String>,
T::Error: ::std::fmt::Display,
{
self.input_file_id = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for input_file_id: {e}")
});
self
}
pub fn metadata<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::collections::HashMap<::std::string::String, ::std::string::String>,
>,
T::Error: ::std::fmt::Display,
{
self.metadata = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for metadata: {e}")
});
self
}
pub fn object<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::BatchObject>,
T::Error: ::std::fmt::Display,
{
self.object = value
.try_into()
.map_err(|e| format!("error converting supplied value for object: {e}"));
self
}
pub fn output_file_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.output_file_id = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for output_file_id: {e}")
});
self
}
pub fn request_counts<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
T::Error: ::std::fmt::Display,
{
self.request_counts = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for request_counts: {e}")
});
self
}
pub fn status<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::BatchStatus>,
T::Error: ::std::fmt::Display,
{
self.status = value
.try_into()
.map_err(|e| format!("error converting supplied value for status: {e}"));
self
}
pub fn usage<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
T::Error: ::std::fmt::Display,
{
self.usage = value
.try_into()
.map_err(|e| format!("error converting supplied value for usage: {e}"));
self
}
}
impl ::std::convert::TryFrom<Batch> for super::Batch {
type Error = super::error::ConversionError;
fn try_from(
value: Batch,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
cancelled_at: value.cancelled_at?,
cancelling_at: value.cancelling_at?,
completed_at: value.completed_at?,
completion_window: value.completion_window?,
created_at: value.created_at?,
endpoint: value.endpoint?,
error_file_id: value.error_file_id?,
errors: value.errors?,
expired_at: value.expired_at?,
expires_at: value.expires_at?,
failed_at: value.failed_at?,
finalizing_at: value.finalizing_at?,
id: value.id?,
in_progress_at: value.in_progress_at?,
input_file_id: value.input_file_id?,
metadata: value.metadata?,
object: value.object?,
output_file_id: value.output_file_id?,
request_counts: value.request_counts?,
status: value.status?,
usage: value.usage?,
})
}
}
impl ::std::convert::From<super::Batch> for Batch {
fn from(value: super::Batch) -> Self {
Self {
cancelled_at: Ok(value.cancelled_at),
cancelling_at: Ok(value.cancelling_at),
completed_at: Ok(value.completed_at),
completion_window: Ok(value.completion_window),
created_at: Ok(value.created_at),
endpoint: Ok(value.endpoint),
error_file_id: Ok(value.error_file_id),
errors: Ok(value.errors),
expired_at: Ok(value.expired_at),
expires_at: Ok(value.expires_at),
failed_at: Ok(value.failed_at),
finalizing_at: Ok(value.finalizing_at),
id: Ok(value.id),
in_progress_at: Ok(value.in_progress_at),
input_file_id: Ok(value.input_file_id),
metadata: Ok(value.metadata),
object: Ok(value.object),
output_file_id: Ok(value.output_file_id),
request_counts: Ok(value.request_counts),
status: Ok(value.status),
usage: Ok(value.usage),
}
}
}
#[derive(Clone, Debug)]
pub struct BatchError {
code: ::std::result::Result<::std::string::String, ::std::string::String>,
line: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
message: ::std::result::Result<::std::string::String, ::std::string::String>,
}
impl ::std::default::Default for BatchError {
fn default() -> Self {
Self {
code: Err("no value supplied for code".to_string()),
line: Ok(Default::default()),
message: Err("no value supplied for message".to_string()),
}
}
}
impl BatchError {
pub fn code<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::string::String>,
T::Error: ::std::fmt::Display,
{
self.code = value
.try_into()
.map_err(|e| format!("error converting supplied value for code: {e}"));
self
}
pub fn line<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.line = value
.try_into()
.map_err(|e| format!("error converting supplied value for line: {e}"));
self
}
pub fn message<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::string::String>,
T::Error: ::std::fmt::Display,
{
self.message = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for message: {e}")
});
self
}
}
impl ::std::convert::TryFrom<BatchError> for super::BatchError {
type Error = super::error::ConversionError;
fn try_from(
value: BatchError,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
code: value.code?,
line: value.line?,
message: value.message?,
})
}
}
impl ::std::convert::From<super::BatchError> for BatchError {
fn from(value: super::BatchError) -> Self {
Self {
code: Ok(value.code),
line: Ok(value.line),
message: Ok(value.message),
}
}
}
#[derive(Clone, Debug)]
pub struct BatchErrorCollection {
data: ::std::result::Result<
::std::vec::Vec<super::BatchError>,
::std::string::String,
>,
object: ::std::result::Result<
super::BatchErrorCollectionObject,
::std::string::String,
>,
}
impl ::std::default::Default for BatchErrorCollection {
fn default() -> Self {
Self {
data: Err("no value supplied for data".to_string()),
object: Err("no value supplied for object".to_string()),
}
}
}
impl BatchErrorCollection {
pub fn data<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::BatchError>>,
T::Error: ::std::fmt::Display,
{
self.data = value
.try_into()
.map_err(|e| format!("error converting supplied value for data: {e}"));
self
}
pub fn object<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::BatchErrorCollectionObject>,
T::Error: ::std::fmt::Display,
{
self.object = value
.try_into()
.map_err(|e| format!("error converting supplied value for object: {e}"));
self
}
}
impl ::std::convert::TryFrom<BatchErrorCollection> for super::BatchErrorCollection {
type Error = super::error::ConversionError;
fn try_from(
value: BatchErrorCollection,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
data: value.data?,
object: value.object?,
})
}
}
impl ::std::convert::From<super::BatchErrorCollection> for BatchErrorCollection {
fn from(value: super::BatchErrorCollection) -> Self {
Self {
data: Ok(value.data),
object: Ok(value.object),
}
}
}
#[derive(Clone, Debug)]
pub struct Error {
code: ::std::result::Result<i64, ::std::string::String>,
message: ::std::result::Result<::std::string::String, ::std::string::String>,
param: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
type_: ::std::result::Result<::std::string::String, ::std::string::String>,
}
impl ::std::default::Default for Error {
fn default() -> Self {
Self {
code: Err("no value supplied for code".to_string()),
message: Err("no value supplied for message".to_string()),
param: Ok(Default::default()),
type_: Err("no value supplied for type_".to_string()),
}
}
}
impl Error {
pub fn code<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<i64>,
T::Error: ::std::fmt::Display,
{
self.code = value
.try_into()
.map_err(|e| format!("error converting supplied value for code: {e}"));
self
}
pub fn message<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::string::String>,
T::Error: ::std::fmt::Display,
{
self.message = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for message: {e}")
});
self
}
pub fn param<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.param = value
.try_into()
.map_err(|e| format!("error converting supplied value for param: {e}"));
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::string::String>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
}
impl ::std::convert::TryFrom<Error> for super::Error {
type Error = super::error::ConversionError;
fn try_from(
value: Error,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
code: value.code?,
message: value.message?,
param: value.param?,
type_: value.type_?,
})
}
}
impl ::std::convert::From<super::Error> for Error {
fn from(value: super::Error) -> Self {
Self {
code: Ok(value.code),
message: Ok(value.message),
param: Ok(value.param),
type_: Ok(value.type_),
}
}
}
#[derive(Clone, Debug)]
pub struct Output {
data: ::std::result::Result<
::std::vec::Vec<super::Batch>,
::std::string::String,
>,
error: ::std::result::Result<
::std::option::Option<super::Error>,
::std::string::String,
>,
first_id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
has_more: ::std::result::Result<
::std::option::Option<bool>,
::std::string::String,
>,
last_id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
object: ::std::result::Result<
::std::option::Option<super::OutputObject>,
::std::string::String,
>,
}
impl ::std::default::Default for Output {
fn default() -> Self {
Self {
data: Ok(Default::default()),
error: Ok(Default::default()),
first_id: Ok(Default::default()),
has_more: Ok(Default::default()),
last_id: Ok(Default::default()),
object: Ok(Default::default()),
}
}
}
impl Output {
pub fn data<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::Batch>>,
T::Error: ::std::fmt::Display,
{
self.data = value
.try_into()
.map_err(|e| format!("error converting supplied value for data: {e}"));
self
}
pub fn error<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Error>>,
T::Error: ::std::fmt::Display,
{
self.error = value
.try_into()
.map_err(|e| format!("error converting supplied value for error: {e}"));
self
}
pub fn first_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.first_id = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for first_id: {e}")
});
self
}
pub fn has_more<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<bool>>,
T::Error: ::std::fmt::Display,
{
self.has_more = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for has_more: {e}")
});
self
}
pub fn last_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.last_id = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for last_id: {e}")
});
self
}
pub fn object<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::OutputObject>>,
T::Error: ::std::fmt::Display,
{
self.object = value
.try_into()
.map_err(|e| format!("error converting supplied value for object: {e}"));
self
}
}
impl ::std::convert::TryFrom<Output> for super::Output {
type Error = super::error::ConversionError;
fn try_from(
value: Output,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
data: value.data?,
error: value.error?,
first_id: value.first_id?,
has_more: value.has_more?,
last_id: value.last_id?,
object: value.object?,
})
}
}
impl ::std::convert::From<super::Output> for Output {
fn from(value: super::Output) -> Self {
Self {
data: Ok(value.data),
error: Ok(value.error),
first_id: Ok(value.first_id),
has_more: Ok(value.has_more),
last_id: Ok(value.last_id),
object: Ok(value.object),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
}
/// Where each field of `Input` goes in the request.
pub const ROUTING: ::one::Routing = ::one::Routing { routes: &[::one::Route { field: "after_id", part: ::one::Part::Query, key: Some("after_id") }, ::one::Route { field: "limit", part: ::one::Part::Query, key: Some("limit") }], required_parts: &[] };
/// Builds the `list_batches` action.
///
/// # Example input
/// ```json
/// {
/// "after_id": "batch_01JQ3Y5B8Q3H9R6K2M7N4P1ABC",
/// "limit": 20
/// }
/// ```
pub fn build(input: Input) -> ::std::result::Result<Operation<output::Output>, Error> {
::std::result::Result::Ok(Operation::action("conn_mod_def::GOQ4Cv6q_Dg::K7rPnHKGRIm35BQqDikVXg", Method::GET, "/v1/batches").with_routed(&input, &ROUTING)?
.merge_headers(::serde_json::from_str("{\"Accept\":\"application/json\"}").map_err(Error::Decode)?).returns::<output::Output>())
}
impl IntoOperation for Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
build(self)
}
}
impl IntoOperation for builder::Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
Input::try_from(self).map_err(|error| Error::InvalidInput(::std::boxed::Box::new(error))).and_then(build)
}
}
}
/// Starts building the `list_batches` action's input; pass the builder to `run`.
pub fn list_batches() -> list_batches::builder::Input {
list_batches::builder::Input::default()
}
pub mod retrieve_batch {
use ::one::{Error, IntoOperation, Method, Operation};
///Retrieves the current details, processing status, request counts, token usage, timestamps, output files, and errors for a specific batch.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct Input {
///Batch identifier. Expected format: `batch_...`. Send this value in the URL path.
#[serde(rename = "batchId")]
pub batch_id: InputBatchId,
}
impl Input {
pub fn builder() -> builder::Input {
Default::default()
}
}
///Batch identifier. Expected format: `batch_...`. Send this value in the URL path.
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct InputBatchId(::std::string::String);
impl ::std::ops::Deref for InputBatchId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<InputBatchId> for ::std::string::String {
fn from(value: InputBatchId) -> Self {
value.0
}
}
impl ::std::str::FromStr for InputBatchId {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
::std::convert::TryFrom::try_from(value)
}
}
impl ::std::convert::TryFrom<&str> for InputBatchId {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<::std::string::String> for InputBatchId {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
::std::convert::TryFrom::try_from(value.as_str())
}
}
impl<'de> ::serde::Deserialize<'de> for InputBatchId {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::convert::TryFrom::try_from(
::std::string::String::deserialize(deserializer)?,
)
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Input {
batch_id: ::std::result::Result<super::InputBatchId, ::std::string::String>,
}
impl ::std::default::Default for Input {
fn default() -> Self {
Self {
batch_id: Err("no value supplied for batch_id".to_string()),
}
}
}
impl Input {
pub fn batch_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::InputBatchId>,
T::Error: ::std::fmt::Display,
{
self.batch_id = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for batch_id: {e}")
});
self
}
}
impl ::std::convert::TryFrom<Input> for super::Input {
type Error = super::error::ConversionError;
fn try_from(
value: Input,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self { batch_id: value.batch_id? })
}
}
impl ::std::convert::From<super::Input> for Input {
fn from(value: super::Input) -> Self {
Self {
batch_id: Ok(value.batch_id),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
pub mod output {
///Collection of batch input-processing errors, if any.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct BatchErrors {
///Array of error objects.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub data: ::std::vec::Vec<BatchErrorsDataItem>,
///Error collection object type. Value: `list`.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub object: ::std::option::Option<BatchErrorsObject>,
}
impl BatchErrors {
pub fn builder() -> builder::BatchErrors {
Default::default()
}
}
///`BatchErrorsDataItem`
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct BatchErrorsDataItem {
///Error code.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub code: ::std::option::Option<::std::string::String>,
///Optional 1-based input line number to which the error refers.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub line: ::std::option::Option<i64>,
///Human-readable error message.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub message: ::std::option::Option<::std::string::String>,
}
impl BatchErrorsDataItem {
pub fn builder() -> builder::BatchErrorsDataItem {
Default::default()
}
}
///Error collection object type. Value: `list`.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum BatchErrorsObject {
#[serde(rename = "list")]
List,
}
impl ::std::fmt::Display for BatchErrorsObject {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::List => f.write_str("list"),
}
}
}
impl ::std::str::FromStr for BatchErrorsObject {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"list" => Ok(Self::List),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for BatchErrorsObject {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for BatchErrorsObject {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Error details.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Error {
///HTTP status code associated with the error.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub code: ::std::option::Option<i64>,
///Human-readable error message.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub message: ::std::option::Option<::std::string::String>,
///Optional parameter that caused the error.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub param: ::std::option::Option<::std::string::String>,
///Error type identifier.
#[serde(rename = "type", skip_serializing_if = "::std::option::Option::is_none")]
pub type_: ::std::option::Option<::std::string::String>,
}
impl Error {
pub fn builder() -> builder::Error {
Default::default()
}
}
///Response structure for retrieving a specific batch, including success and error responses.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Output {
///Optional Unix timestamp, in seconds, when the batch was cancelled.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub cancelled_at: ::std::option::Option<i64>,
///Optional Unix timestamp, in seconds, when cancellation began.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub cancelling_at: ::std::option::Option<i64>,
///Optional Unix timestamp, in seconds, when the batch completed.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub completed_at: ::std::option::Option<i64>,
///Time window allowed for batch completion.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub completion_window: ::std::option::Option<::std::string::String>,
///Unix timestamp, in seconds, when the batch was created.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub created_at: ::std::option::Option<i64>,
///API endpoint executed by requests in the batch.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub endpoint: ::std::option::Option<::std::string::String>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub error: ::std::option::Option<Error>,
///Optional identifier of the error file containing failed request results.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub error_file_id: ::std::option::Option<::std::string::String>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub errors: ::std::option::Option<BatchErrors>,
///Optional Unix timestamp, in seconds, when the batch expired.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub expired_at: ::std::option::Option<i64>,
///Optional Unix timestamp, in seconds, when the batch expires.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub expires_at: ::std::option::Option<i64>,
///Optional Unix timestamp, in seconds, when the batch failed.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub failed_at: ::std::option::Option<i64>,
///Optional Unix timestamp, in seconds, when the batch entered finalization.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub finalizing_at: ::std::option::Option<i64>,
///Unique identifier of the batch.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub id: ::std::option::Option<::std::string::String>,
///Optional Unix timestamp, in seconds, when batch processing began.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub in_progress_at: ::std::option::Option<i64>,
///Identifier of the input file used to create the batch.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub input_file_id: ::std::option::Option<::std::string::String>,
///Optional string key-value metadata associated with the batch.
#[serde(default, skip_serializing_if = "::std::collections::HashMap::is_empty")]
pub metadata: ::std::collections::HashMap<
::std::string::String,
::std::string::String,
>,
///Object type. Value: `batch`.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub object: ::std::option::Option<OutputObject>,
///Optional identifier of the output file containing successfully completed request results.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub output_file_id: ::std::option::Option<::std::string::String>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub request_counts: ::std::option::Option<RequestCounts>,
///Current batch status.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub status: ::std::option::Option<OutputStatus>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub usage: ::std::option::Option<Usage>,
}
impl Output {
pub fn builder() -> builder::Output {
Default::default()
}
}
///Object type. Value: `batch`.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum OutputObject {
#[serde(rename = "batch")]
Batch,
}
impl ::std::fmt::Display for OutputObject {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Batch => f.write_str("batch"),
}
}
}
impl ::std::str::FromStr for OutputObject {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"batch" => Ok(Self::Batch),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for OutputObject {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for OutputObject {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Current batch status.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum OutputStatus {
#[serde(rename = "validating")]
Validating,
#[serde(rename = "in_progress")]
InProgress,
#[serde(rename = "finalizing")]
Finalizing,
#[serde(rename = "completed")]
Completed,
#[serde(rename = "expired")]
Expired,
#[serde(rename = "cancelling")]
Cancelling,
#[serde(rename = "cancelled")]
Cancelled,
#[serde(rename = "failed")]
Failed,
}
impl ::std::fmt::Display for OutputStatus {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Validating => f.write_str("validating"),
Self::InProgress => f.write_str("in_progress"),
Self::Finalizing => f.write_str("finalizing"),
Self::Completed => f.write_str("completed"),
Self::Expired => f.write_str("expired"),
Self::Cancelling => f.write_str("cancelling"),
Self::Cancelled => f.write_str("cancelled"),
Self::Failed => f.write_str("failed"),
}
}
}
impl ::std::str::FromStr for OutputStatus {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"validating" => Ok(Self::Validating),
"in_progress" => Ok(Self::InProgress),
"finalizing" => Ok(Self::Finalizing),
"completed" => Ok(Self::Completed),
"expired" => Ok(Self::Expired),
"cancelling" => Ok(Self::Cancelling),
"cancelled" => Ok(Self::Cancelled),
"failed" => Ok(Self::Failed),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for OutputStatus {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for OutputStatus {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Counts of requests in the batch by outcome.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct RequestCounts {
///Number of successfully completed requests.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub completed: ::std::option::Option<i64>,
///Number of failed requests.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub failed: ::std::option::Option<i64>,
///Total number of requests in the batch.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub total: ::std::option::Option<i64>,
}
impl RequestCounts {
pub fn builder() -> builder::RequestCounts {
Default::default()
}
}
///Aggregate token usage for the batch.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Usage {
///Total number of input tokens processed.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub input_tokens: ::std::option::Option<i64>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub input_tokens_details: ::std::option::Option<UsageInputTokensDetails>,
///Total number of output tokens generated.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub output_tokens: ::std::option::Option<i64>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub output_tokens_details: ::std::option::Option<UsageOutputTokensDetails>,
///Total token usage, including input and output tokens.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub total_tokens: ::std::option::Option<i64>,
}
impl Usage {
pub fn builder() -> builder::Usage {
Default::default()
}
}
///Details about input token usage.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct UsageInputTokensDetails {
///Number of input tokens served from cache.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub cached_tokens: ::std::option::Option<i64>,
}
impl UsageInputTokensDetails {
pub fn builder() -> builder::UsageInputTokensDetails {
Default::default()
}
}
///Details about output token usage.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct UsageOutputTokensDetails {
///Number of output tokens used for reasoning.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub reasoning_tokens: ::std::option::Option<i64>,
}
impl UsageOutputTokensDetails {
pub fn builder() -> builder::UsageOutputTokensDetails {
Default::default()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct BatchErrors {
data: ::std::result::Result<
::std::vec::Vec<super::BatchErrorsDataItem>,
::std::string::String,
>,
object: ::std::result::Result<
::std::option::Option<super::BatchErrorsObject>,
::std::string::String,
>,
}
impl ::std::default::Default for BatchErrors {
fn default() -> Self {
Self {
data: Ok(Default::default()),
object: Ok(Default::default()),
}
}
}
impl BatchErrors {
pub fn data<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::BatchErrorsDataItem>>,
T::Error: ::std::fmt::Display,
{
self.data = value
.try_into()
.map_err(|e| format!("error converting supplied value for data: {e}"));
self
}
pub fn object<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::BatchErrorsObject>>,
T::Error: ::std::fmt::Display,
{
self.object = value
.try_into()
.map_err(|e| format!("error converting supplied value for object: {e}"));
self
}
}
impl ::std::convert::TryFrom<BatchErrors> for super::BatchErrors {
type Error = super::error::ConversionError;
fn try_from(
value: BatchErrors,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
data: value.data?,
object: value.object?,
})
}
}
impl ::std::convert::From<super::BatchErrors> for BatchErrors {
fn from(value: super::BatchErrors) -> Self {
Self {
data: Ok(value.data),
object: Ok(value.object),
}
}
}
#[derive(Clone, Debug)]
pub struct BatchErrorsDataItem {
code: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
line: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
message: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for BatchErrorsDataItem {
fn default() -> Self {
Self {
code: Ok(Default::default()),
line: Ok(Default::default()),
message: Ok(Default::default()),
}
}
}
impl BatchErrorsDataItem {
pub fn code<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.code = value
.try_into()
.map_err(|e| format!("error converting supplied value for code: {e}"));
self
}
pub fn line<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.line = value
.try_into()
.map_err(|e| format!("error converting supplied value for line: {e}"));
self
}
pub fn message<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.message = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for message: {e}")
});
self
}
}
impl ::std::convert::TryFrom<BatchErrorsDataItem> for super::BatchErrorsDataItem {
type Error = super::error::ConversionError;
fn try_from(
value: BatchErrorsDataItem,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
code: value.code?,
line: value.line?,
message: value.message?,
})
}
}
impl ::std::convert::From<super::BatchErrorsDataItem> for BatchErrorsDataItem {
fn from(value: super::BatchErrorsDataItem) -> Self {
Self {
code: Ok(value.code),
line: Ok(value.line),
message: Ok(value.message),
}
}
}
#[derive(Clone, Debug)]
pub struct Error {
code: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
message: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
param: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
type_: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for Error {
fn default() -> Self {
Self {
code: Ok(Default::default()),
message: Ok(Default::default()),
param: Ok(Default::default()),
type_: Ok(Default::default()),
}
}
}
impl Error {
pub fn code<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.code = value
.try_into()
.map_err(|e| format!("error converting supplied value for code: {e}"));
self
}
pub fn message<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.message = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for message: {e}")
});
self
}
pub fn param<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.param = value
.try_into()
.map_err(|e| format!("error converting supplied value for param: {e}"));
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
}
impl ::std::convert::TryFrom<Error> for super::Error {
type Error = super::error::ConversionError;
fn try_from(
value: Error,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
code: value.code?,
message: value.message?,
param: value.param?,
type_: value.type_?,
})
}
}
impl ::std::convert::From<super::Error> for Error {
fn from(value: super::Error) -> Self {
Self {
code: Ok(value.code),
message: Ok(value.message),
param: Ok(value.param),
type_: Ok(value.type_),
}
}
}
#[derive(Clone, Debug)]
pub struct Output {
cancelled_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
cancelling_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
completed_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
completion_window: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
created_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
endpoint: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
error: ::std::result::Result<
::std::option::Option<super::Error>,
::std::string::String,
>,
error_file_id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
errors: ::std::result::Result<
::std::option::Option<super::BatchErrors>,
::std::string::String,
>,
expired_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
expires_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
failed_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
finalizing_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
in_progress_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
input_file_id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
metadata: ::std::result::Result<
::std::collections::HashMap<::std::string::String, ::std::string::String>,
::std::string::String,
>,
object: ::std::result::Result<
::std::option::Option<super::OutputObject>,
::std::string::String,
>,
output_file_id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
request_counts: ::std::result::Result<
::std::option::Option<super::RequestCounts>,
::std::string::String,
>,
status: ::std::result::Result<
::std::option::Option<super::OutputStatus>,
::std::string::String,
>,
usage: ::std::result::Result<
::std::option::Option<super::Usage>,
::std::string::String,
>,
}
impl ::std::default::Default for Output {
fn default() -> Self {
Self {
cancelled_at: Ok(Default::default()),
cancelling_at: Ok(Default::default()),
completed_at: Ok(Default::default()),
completion_window: Ok(Default::default()),
created_at: Ok(Default::default()),
endpoint: Ok(Default::default()),
error: Ok(Default::default()),
error_file_id: Ok(Default::default()),
errors: Ok(Default::default()),
expired_at: Ok(Default::default()),
expires_at: Ok(Default::default()),
failed_at: Ok(Default::default()),
finalizing_at: Ok(Default::default()),
id: Ok(Default::default()),
in_progress_at: Ok(Default::default()),
input_file_id: Ok(Default::default()),
metadata: Ok(Default::default()),
object: Ok(Default::default()),
output_file_id: Ok(Default::default()),
request_counts: Ok(Default::default()),
status: Ok(Default::default()),
usage: Ok(Default::default()),
}
}
}
impl Output {
pub fn cancelled_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.cancelled_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for cancelled_at: {e}")
});
self
}
pub fn cancelling_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.cancelling_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for cancelling_at: {e}")
});
self
}
pub fn completed_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.completed_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for completed_at: {e}")
});
self
}
pub fn completion_window<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.completion_window = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for completion_window: {e}")
});
self
}
pub fn created_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.created_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for created_at: {e}")
});
self
}
pub fn endpoint<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.endpoint = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for endpoint: {e}")
});
self
}
pub fn error<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Error>>,
T::Error: ::std::fmt::Display,
{
self.error = value
.try_into()
.map_err(|e| format!("error converting supplied value for error: {e}"));
self
}
pub fn error_file_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.error_file_id = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for error_file_id: {e}")
});
self
}
pub fn errors<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::BatchErrors>>,
T::Error: ::std::fmt::Display,
{
self.errors = value
.try_into()
.map_err(|e| format!("error converting supplied value for errors: {e}"));
self
}
pub fn expired_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.expired_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for expired_at: {e}")
});
self
}
pub fn expires_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.expires_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for expires_at: {e}")
});
self
}
pub fn failed_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.failed_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for failed_at: {e}")
});
self
}
pub fn finalizing_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.finalizing_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for finalizing_at: {e}")
});
self
}
pub fn id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.id = value
.try_into()
.map_err(|e| format!("error converting supplied value for id: {e}"));
self
}
pub fn in_progress_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.in_progress_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for in_progress_at: {e}")
});
self
}
pub fn input_file_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.input_file_id = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for input_file_id: {e}")
});
self
}
pub fn metadata<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::collections::HashMap<::std::string::String, ::std::string::String>,
>,
T::Error: ::std::fmt::Display,
{
self.metadata = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for metadata: {e}")
});
self
}
pub fn object<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::OutputObject>>,
T::Error: ::std::fmt::Display,
{
self.object = value
.try_into()
.map_err(|e| format!("error converting supplied value for object: {e}"));
self
}
pub fn output_file_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.output_file_id = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for output_file_id: {e}")
});
self
}
pub fn request_counts<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::RequestCounts>>,
T::Error: ::std::fmt::Display,
{
self.request_counts = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for request_counts: {e}")
});
self
}
pub fn status<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::OutputStatus>>,
T::Error: ::std::fmt::Display,
{
self.status = value
.try_into()
.map_err(|e| format!("error converting supplied value for status: {e}"));
self
}
pub fn usage<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Usage>>,
T::Error: ::std::fmt::Display,
{
self.usage = value
.try_into()
.map_err(|e| format!("error converting supplied value for usage: {e}"));
self
}
}
impl ::std::convert::TryFrom<Output> for super::Output {
type Error = super::error::ConversionError;
fn try_from(
value: Output,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
cancelled_at: value.cancelled_at?,
cancelling_at: value.cancelling_at?,
completed_at: value.completed_at?,
completion_window: value.completion_window?,
created_at: value.created_at?,
endpoint: value.endpoint?,
error: value.error?,
error_file_id: value.error_file_id?,
errors: value.errors?,
expired_at: value.expired_at?,
expires_at: value.expires_at?,
failed_at: value.failed_at?,
finalizing_at: value.finalizing_at?,
id: value.id?,
in_progress_at: value.in_progress_at?,
input_file_id: value.input_file_id?,
metadata: value.metadata?,
object: value.object?,
output_file_id: value.output_file_id?,
request_counts: value.request_counts?,
status: value.status?,
usage: value.usage?,
})
}
}
impl ::std::convert::From<super::Output> for Output {
fn from(value: super::Output) -> Self {
Self {
cancelled_at: Ok(value.cancelled_at),
cancelling_at: Ok(value.cancelling_at),
completed_at: Ok(value.completed_at),
completion_window: Ok(value.completion_window),
created_at: Ok(value.created_at),
endpoint: Ok(value.endpoint),
error: Ok(value.error),
error_file_id: Ok(value.error_file_id),
errors: Ok(value.errors),
expired_at: Ok(value.expired_at),
expires_at: Ok(value.expires_at),
failed_at: Ok(value.failed_at),
finalizing_at: Ok(value.finalizing_at),
id: Ok(value.id),
in_progress_at: Ok(value.in_progress_at),
input_file_id: Ok(value.input_file_id),
metadata: Ok(value.metadata),
object: Ok(value.object),
output_file_id: Ok(value.output_file_id),
request_counts: Ok(value.request_counts),
status: Ok(value.status),
usage: Ok(value.usage),
}
}
}
#[derive(Clone, Debug)]
pub struct RequestCounts {
completed: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
failed: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
total: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
}
impl ::std::default::Default for RequestCounts {
fn default() -> Self {
Self {
completed: Ok(Default::default()),
failed: Ok(Default::default()),
total: Ok(Default::default()),
}
}
}
impl RequestCounts {
pub fn completed<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.completed = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for completed: {e}")
});
self
}
pub fn failed<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.failed = value
.try_into()
.map_err(|e| format!("error converting supplied value for failed: {e}"));
self
}
pub fn total<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.total = value
.try_into()
.map_err(|e| format!("error converting supplied value for total: {e}"));
self
}
}
impl ::std::convert::TryFrom<RequestCounts> for super::RequestCounts {
type Error = super::error::ConversionError;
fn try_from(
value: RequestCounts,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
completed: value.completed?,
failed: value.failed?,
total: value.total?,
})
}
}
impl ::std::convert::From<super::RequestCounts> for RequestCounts {
fn from(value: super::RequestCounts) -> Self {
Self {
completed: Ok(value.completed),
failed: Ok(value.failed),
total: Ok(value.total),
}
}
}
#[derive(Clone, Debug)]
pub struct Usage {
input_tokens: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
input_tokens_details: ::std::result::Result<
::std::option::Option<super::UsageInputTokensDetails>,
::std::string::String,
>,
output_tokens: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
output_tokens_details: ::std::result::Result<
::std::option::Option<super::UsageOutputTokensDetails>,
::std::string::String,
>,
total_tokens: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
}
impl ::std::default::Default for Usage {
fn default() -> Self {
Self {
input_tokens: Ok(Default::default()),
input_tokens_details: Ok(Default::default()),
output_tokens: Ok(Default::default()),
output_tokens_details: Ok(Default::default()),
total_tokens: Ok(Default::default()),
}
}
}
impl Usage {
pub fn input_tokens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.input_tokens = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for input_tokens: {e}")
});
self
}
pub fn input_tokens_details<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<super::UsageInputTokensDetails>,
>,
T::Error: ::std::fmt::Display,
{
self.input_tokens_details = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for input_tokens_details: {e}"
)
});
self
}
pub fn output_tokens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.output_tokens = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for output_tokens: {e}")
});
self
}
pub fn output_tokens_details<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<super::UsageOutputTokensDetails>,
>,
T::Error: ::std::fmt::Display,
{
self.output_tokens_details = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for output_tokens_details: {e}"
)
});
self
}
pub fn total_tokens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.total_tokens = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for total_tokens: {e}")
});
self
}
}
impl ::std::convert::TryFrom<Usage> for super::Usage {
type Error = super::error::ConversionError;
fn try_from(
value: Usage,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
input_tokens: value.input_tokens?,
input_tokens_details: value.input_tokens_details?,
output_tokens: value.output_tokens?,
output_tokens_details: value.output_tokens_details?,
total_tokens: value.total_tokens?,
})
}
}
impl ::std::convert::From<super::Usage> for Usage {
fn from(value: super::Usage) -> Self {
Self {
input_tokens: Ok(value.input_tokens),
input_tokens_details: Ok(value.input_tokens_details),
output_tokens: Ok(value.output_tokens),
output_tokens_details: Ok(value.output_tokens_details),
total_tokens: Ok(value.total_tokens),
}
}
}
#[derive(Clone, Debug)]
pub struct UsageInputTokensDetails {
cached_tokens: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
}
impl ::std::default::Default for UsageInputTokensDetails {
fn default() -> Self {
Self {
cached_tokens: Ok(Default::default()),
}
}
}
impl UsageInputTokensDetails {
pub fn cached_tokens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.cached_tokens = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for cached_tokens: {e}")
});
self
}
}
impl ::std::convert::TryFrom<UsageInputTokensDetails>
for super::UsageInputTokensDetails {
type Error = super::error::ConversionError;
fn try_from(
value: UsageInputTokensDetails,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
cached_tokens: value.cached_tokens?,
})
}
}
impl ::std::convert::From<super::UsageInputTokensDetails>
for UsageInputTokensDetails {
fn from(value: super::UsageInputTokensDetails) -> Self {
Self {
cached_tokens: Ok(value.cached_tokens),
}
}
}
#[derive(Clone, Debug)]
pub struct UsageOutputTokensDetails {
reasoning_tokens: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
}
impl ::std::default::Default for UsageOutputTokensDetails {
fn default() -> Self {
Self {
reasoning_tokens: Ok(Default::default()),
}
}
}
impl UsageOutputTokensDetails {
pub fn reasoning_tokens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.reasoning_tokens = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for reasoning_tokens: {e}")
});
self
}
}
impl ::std::convert::TryFrom<UsageOutputTokensDetails>
for super::UsageOutputTokensDetails {
type Error = super::error::ConversionError;
fn try_from(
value: UsageOutputTokensDetails,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
reasoning_tokens: value.reasoning_tokens?,
})
}
}
impl ::std::convert::From<super::UsageOutputTokensDetails>
for UsageOutputTokensDetails {
fn from(value: super::UsageOutputTokensDetails) -> Self {
Self {
reasoning_tokens: Ok(value.reasoning_tokens),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
}
/// Where each field of `Input` goes in the request.
pub const ROUTING: ::one::Routing = ::one::Routing { routes: &[::one::Route { field: "batchId", part: ::one::Part::Path, key: Some("batchId") }], required_parts: &[::one::Part::Path] };
/// Builds the `retrieve_batch` action.
///
/// # Example input
/// ```json
/// {
/// "batchId": "batch_abc123def456"
/// }
/// ```
pub fn build(input: Input) -> ::std::result::Result<Operation<output::Output>, Error> {
::std::result::Result::Ok(Operation::action("conn_mod_def::GOQ4C2r7VUA::KPYnRbCSRaOY2MXu0W1CAg", Method::GET, "/v1/batches/{{batchId}}").with_routed(&input, &ROUTING)?
.merge_headers(::serde_json::from_str("{\"Accept\":\"application/json\"}").map_err(Error::Decode)?).returns::<output::Output>())
}
impl IntoOperation for Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
build(self)
}
}
impl IntoOperation for builder::Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
Input::try_from(self).map_err(|error| Error::InvalidInput(::std::boxed::Box::new(error))).and_then(build)
}
}
}
/// Starts building the `retrieve_batch` action's input; pass the builder to `run`.
pub fn retrieve_batch() -> retrieve_batch::builder::Input {
retrieve_batch::builder::Input::default()
}
pub mod retrieve_file {
use ::one::{Error, IntoOperation, Method, Operation};
///Retrieves metadata for a specific file. Files may be uploaded batch files or batch output/error files.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct Input {
///File identifier. File IDs use the `file_...` format. Send this value in the URL path.
#[serde(rename = "fileId")]
pub file_id: InputFileId,
}
impl Input {
pub fn builder() -> builder::Input {
Default::default()
}
}
///File identifier. File IDs use the `file_...` format. Send this value in the URL path.
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct InputFileId(::std::string::String);
impl ::std::ops::Deref for InputFileId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<InputFileId> for ::std::string::String {
fn from(value: InputFileId) -> Self {
value.0
}
}
impl ::std::str::FromStr for InputFileId {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
::std::convert::TryFrom::try_from(value)
}
}
impl ::std::convert::TryFrom<&str> for InputFileId {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<::std::string::String> for InputFileId {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
::std::convert::TryFrom::try_from(value.as_str())
}
}
impl<'de> ::serde::Deserialize<'de> for InputFileId {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::convert::TryFrom::try_from(
::std::string::String::deserialize(deserializer)?,
)
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Input {
file_id: ::std::result::Result<super::InputFileId, ::std::string::String>,
}
impl ::std::default::Default for Input {
fn default() -> Self {
Self {
file_id: Err("no value supplied for file_id".to_string()),
}
}
}
impl Input {
pub fn file_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::InputFileId>,
T::Error: ::std::fmt::Display,
{
self.file_id = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for file_id: {e}")
});
self
}
}
impl ::std::convert::TryFrom<Input> for super::Input {
type Error = super::error::ConversionError;
fn try_from(
value: Input,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self { file_id: value.file_id? })
}
}
impl ::std::convert::From<super::Input> for Input {
fn from(value: super::Input) -> Self {
Self { file_id: Ok(value.file_id) }
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
pub mod output {
///Error details returned for an unsuccessful request.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Error {
///HTTP status code associated with the error.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub code: ::std::option::Option<i64>,
///Human-readable error message.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub message: ::std::option::Option<::std::string::String>,
///Optional parameter that caused the error.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub param: ::std::option::Option<::std::string::String>,
///Error type identifier.
#[serde(rename = "type", skip_serializing_if = "::std::option::Option::is_none")]
pub type_: ::std::option::Option<::std::string::String>,
}
impl Error {
pub fn builder() -> builder::Error {
Default::default()
}
}
///Response structure for retrieving metadata for a specific file or an error when the file does not exist or has expired.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Output {
///File size in bytes.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub bytes: ::std::option::Option<i64>,
///Unix timestamp, in seconds, indicating when the file was created.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub created_at: ::std::option::Option<i64>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub error: ::std::option::Option<Error>,
///Optional Unix timestamp, in seconds, indicating when the file expires.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub expires_at: ::std::option::Option<i64>,
///Original filename.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub filename: ::std::option::Option<::std::string::String>,
///Unique file identifier.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub id: ::std::option::Option<::std::string::String>,
///Object type. Value: `file`.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub object: ::std::option::Option<OutputObject>,
///File purpose. Possible values: `batch` for uploaded batch files, or `batch_output` for batch output and error files.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub purpose: ::std::option::Option<OutputPurpose>,
}
impl Output {
pub fn builder() -> builder::Output {
Default::default()
}
}
///Object type. Value: `file`.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum OutputObject {
#[serde(rename = "file")]
File,
}
impl ::std::fmt::Display for OutputObject {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::File => f.write_str("file"),
}
}
}
impl ::std::str::FromStr for OutputObject {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"file" => Ok(Self::File),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for OutputObject {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for OutputObject {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///File purpose. Possible values: `batch` for uploaded batch files, or `batch_output` for batch output and error files.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum OutputPurpose {
#[serde(rename = "batch")]
Batch,
#[serde(rename = "batch_output")]
BatchOutput,
}
impl ::std::fmt::Display for OutputPurpose {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Batch => f.write_str("batch"),
Self::BatchOutput => f.write_str("batch_output"),
}
}
}
impl ::std::str::FromStr for OutputPurpose {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"batch" => Ok(Self::Batch),
"batch_output" => Ok(Self::BatchOutput),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for OutputPurpose {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for OutputPurpose {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Error {
code: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
message: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
param: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
type_: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for Error {
fn default() -> Self {
Self {
code: Ok(Default::default()),
message: Ok(Default::default()),
param: Ok(Default::default()),
type_: Ok(Default::default()),
}
}
}
impl Error {
pub fn code<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.code = value
.try_into()
.map_err(|e| format!("error converting supplied value for code: {e}"));
self
}
pub fn message<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.message = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for message: {e}")
});
self
}
pub fn param<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.param = value
.try_into()
.map_err(|e| format!("error converting supplied value for param: {e}"));
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
}
impl ::std::convert::TryFrom<Error> for super::Error {
type Error = super::error::ConversionError;
fn try_from(
value: Error,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
code: value.code?,
message: value.message?,
param: value.param?,
type_: value.type_?,
})
}
}
impl ::std::convert::From<super::Error> for Error {
fn from(value: super::Error) -> Self {
Self {
code: Ok(value.code),
message: Ok(value.message),
param: Ok(value.param),
type_: Ok(value.type_),
}
}
}
#[derive(Clone, Debug)]
pub struct Output {
bytes: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
created_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
error: ::std::result::Result<
::std::option::Option<super::Error>,
::std::string::String,
>,
expires_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
filename: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
object: ::std::result::Result<
::std::option::Option<super::OutputObject>,
::std::string::String,
>,
purpose: ::std::result::Result<
::std::option::Option<super::OutputPurpose>,
::std::string::String,
>,
}
impl ::std::default::Default for Output {
fn default() -> Self {
Self {
bytes: Ok(Default::default()),
created_at: Ok(Default::default()),
error: Ok(Default::default()),
expires_at: Ok(Default::default()),
filename: Ok(Default::default()),
id: Ok(Default::default()),
object: Ok(Default::default()),
purpose: Ok(Default::default()),
}
}
}
impl Output {
pub fn bytes<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.bytes = value
.try_into()
.map_err(|e| format!("error converting supplied value for bytes: {e}"));
self
}
pub fn created_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.created_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for created_at: {e}")
});
self
}
pub fn error<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Error>>,
T::Error: ::std::fmt::Display,
{
self.error = value
.try_into()
.map_err(|e| format!("error converting supplied value for error: {e}"));
self
}
pub fn expires_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.expires_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for expires_at: {e}")
});
self
}
pub fn filename<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.filename = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for filename: {e}")
});
self
}
pub fn id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.id = value
.try_into()
.map_err(|e| format!("error converting supplied value for id: {e}"));
self
}
pub fn object<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::OutputObject>>,
T::Error: ::std::fmt::Display,
{
self.object = value
.try_into()
.map_err(|e| format!("error converting supplied value for object: {e}"));
self
}
pub fn purpose<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::OutputPurpose>>,
T::Error: ::std::fmt::Display,
{
self.purpose = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for purpose: {e}")
});
self
}
}
impl ::std::convert::TryFrom<Output> for super::Output {
type Error = super::error::ConversionError;
fn try_from(
value: Output,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
bytes: value.bytes?,
created_at: value.created_at?,
error: value.error?,
expires_at: value.expires_at?,
filename: value.filename?,
id: value.id?,
object: value.object?,
purpose: value.purpose?,
})
}
}
impl ::std::convert::From<super::Output> for Output {
fn from(value: super::Output) -> Self {
Self {
bytes: Ok(value.bytes),
created_at: Ok(value.created_at),
error: Ok(value.error),
expires_at: Ok(value.expires_at),
filename: Ok(value.filename),
id: Ok(value.id),
object: Ok(value.object),
purpose: Ok(value.purpose),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
}
/// Where each field of `Input` goes in the request.
pub const ROUTING: ::one::Routing = ::one::Routing { routes: &[::one::Route { field: "fileId", part: ::one::Part::Path, key: Some("fileId") }], required_parts: &[::one::Part::Path] };
/// Builds the `retrieve_file` action.
///
/// # Example input
/// ```json
/// {
/// "fileId": "file_abc123def456"
/// }
/// ```
pub fn build(input: Input) -> ::std::result::Result<Operation<output::Output>, Error> {
::std::result::Result::Ok(Operation::action("conn_mod_def::GOQ4C298Pcg::SWXBuEhRS--8ACQW8_RMCw", Method::GET, "/v1/files/{{fileId}}").with_routed(&input, &ROUTING)?
.merge_headers(::serde_json::from_str("{\"Accept\":\"application/json\"}").map_err(Error::Decode)?).returns::<output::Output>())
}
impl IntoOperation for Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
build(self)
}
}
impl IntoOperation for builder::Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
Input::try_from(self).map_err(|error| Error::InvalidInput(::std::boxed::Box::new(error))).and_then(build)
}
}
}
/// Starts building the `retrieve_file` action's input; pass the builder to `run`.
pub fn retrieve_file() -> retrieve_file::builder::Input {
retrieve_file::builder::Input::default()
}
pub mod answer_questions {
use ::one::{Error, IntoOperation, Method, Operation};
///Evaluates one or more named questions against the provided state content. A single request can mix noul, choice, and score question types; the response returns an answer for every question using the same question name.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct Input {
///Decision model to use.
pub model: InputModel,
///Object containing one or more named questions. Each property name is a caller-defined question name, and each value is a NoulQuestion, ChoiceQuestion, or ScoreQuestion.
pub questions: ::std::collections::HashMap<
::std::string::String,
InputQuestionsValue,
>,
///Content against which questions are evaluated. Can be a string, JSON object, or array.
pub state: InputState,
}
impl Input {
pub fn builder() -> builder::Input {
Default::default()
}
}
///Decision model to use.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum InputModel {
#[serde(rename = "pplx-decider-v1.2")]
PplxDeciderV12,
#[serde(rename = "pplx-decider-flash-v1.2")]
PplxDeciderFlashV12,
#[serde(rename = "pplx-decider-latest")]
PplxDeciderLatest,
#[serde(rename = "perplexity/pplx-decider-latest")]
PerplexityPplxDeciderLatest,
#[serde(rename = "pplx-decider-flash-latest")]
PplxDeciderFlashLatest,
#[serde(rename = "perplexity/pplx-decider-flash-latest")]
PerplexityPplxDeciderFlashLatest,
#[serde(rename = "pplx-decider-v1.1-27b")]
PplxDeciderV1127b,
#[serde(rename = "pplx-decider-v1-27b")]
PplxDeciderV127b,
}
impl ::std::fmt::Display for InputModel {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::PplxDeciderV12 => f.write_str("pplx-decider-v1.2"),
Self::PplxDeciderFlashV12 => f.write_str("pplx-decider-flash-v1.2"),
Self::PplxDeciderLatest => f.write_str("pplx-decider-latest"),
Self::PerplexityPplxDeciderLatest => {
f.write_str("perplexity/pplx-decider-latest")
}
Self::PplxDeciderFlashLatest => f.write_str("pplx-decider-flash-latest"),
Self::PerplexityPplxDeciderFlashLatest => {
f.write_str("perplexity/pplx-decider-flash-latest")
}
Self::PplxDeciderV1127b => f.write_str("pplx-decider-v1.1-27b"),
Self::PplxDeciderV127b => f.write_str("pplx-decider-v1-27b"),
}
}
}
impl ::std::str::FromStr for InputModel {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"pplx-decider-v1.2" => Ok(Self::PplxDeciderV12),
"pplx-decider-flash-v1.2" => Ok(Self::PplxDeciderFlashV12),
"pplx-decider-latest" => Ok(Self::PplxDeciderLatest),
"perplexity/pplx-decider-latest" => Ok(Self::PerplexityPplxDeciderLatest),
"pplx-decider-flash-latest" => Ok(Self::PplxDeciderFlashLatest),
"perplexity/pplx-decider-flash-latest" => {
Ok(Self::PerplexityPplxDeciderFlashLatest)
}
"pplx-decider-v1.1-27b" => Ok(Self::PplxDeciderV1127b),
"pplx-decider-v1-27b" => Ok(Self::PplxDeciderV127b),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for InputModel {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for InputModel {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///A named question definition.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
#[serde(deny_unknown_fields)]
pub struct InputQuestionsValue {
///Used by a choice question as an object of possible choices, or by a score question as an ordered array of score legend entries.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub criteria: ::std::option::Option<InputQuestionsValueCriteria>,
///Instructions describing what the model should evaluate or answer.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub instructions: ::std::option::Option<::std::string::String>,
///Question type.
#[serde(rename = "type", skip_serializing_if = "::std::option::Option::is_none")]
pub type_: ::std::option::Option<InputQuestionsValueType>,
}
impl InputQuestionsValue {
pub fn builder() -> builder::InputQuestionsValue {
Default::default()
}
}
///Used by a choice question as an object of possible choices, or by a score question as an ordered array of score legend entries.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(untagged)]
pub enum InputQuestionsValueCriteria {
Object(::std::collections::HashMap<::std::string::String, ::std::string::String>),
Array(::std::vec::Vec<::std::string::String>),
}
impl ::std::convert::From<
::std::collections::HashMap<::std::string::String, ::std::string::String>,
> for InputQuestionsValueCriteria {
fn from(
value: ::std::collections::HashMap<::std::string::String, ::std::string::String>,
) -> Self {
Self::Object(value)
}
}
impl ::std::convert::From<::std::vec::Vec<::std::string::String>>
for InputQuestionsValueCriteria {
fn from(value: ::std::vec::Vec<::std::string::String>) -> Self {
Self::Array(value)
}
}
///Question type.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum InputQuestionsValueType {
#[serde(rename = "noul")]
Noul,
#[serde(rename = "choice")]
Choice,
#[serde(rename = "score")]
Score,
}
impl ::std::fmt::Display for InputQuestionsValueType {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Noul => f.write_str("noul"),
Self::Choice => f.write_str("choice"),
Self::Score => f.write_str("score"),
}
}
}
impl ::std::str::FromStr for InputQuestionsValueType {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"noul" => Ok(Self::Noul),
"choice" => Ok(Self::Choice),
"score" => Ok(Self::Score),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for InputQuestionsValueType {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for InputQuestionsValueType {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Content against which questions are evaluated. Can be a string, JSON object, or array.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(untagged)]
pub enum InputState {
String(::std::string::String),
Object(::serde_json::Map<::std::string::String, ::serde_json::Value>),
Array(::std::vec::Vec<::serde_json::Value>),
}
impl ::std::convert::From<::serde_json::Map<::std::string::String, ::serde_json::Value>>
for InputState {
fn from(
value: ::serde_json::Map<::std::string::String, ::serde_json::Value>,
) -> Self {
Self::Object(value)
}
}
impl ::std::convert::From<::std::vec::Vec<::serde_json::Value>> for InputState {
fn from(value: ::std::vec::Vec<::serde_json::Value>) -> Self {
Self::Array(value)
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Input {
model: ::std::result::Result<super::InputModel, ::std::string::String>,
questions: ::std::result::Result<
::std::collections::HashMap<
::std::string::String,
super::InputQuestionsValue,
>,
::std::string::String,
>,
state: ::std::result::Result<super::InputState, ::std::string::String>,
}
impl ::std::default::Default for Input {
fn default() -> Self {
Self {
model: Err("no value supplied for model".to_string()),
questions: Err("no value supplied for questions".to_string()),
state: Err("no value supplied for state".to_string()),
}
}
}
impl Input {
pub fn model<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::InputModel>,
T::Error: ::std::fmt::Display,
{
self.model = value
.try_into()
.map_err(|e| format!("error converting supplied value for model: {e}"));
self
}
pub fn questions<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::collections::HashMap<
::std::string::String,
super::InputQuestionsValue,
>,
>,
T::Error: ::std::fmt::Display,
{
self.questions = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for questions: {e}")
});
self
}
pub fn state<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::InputState>,
T::Error: ::std::fmt::Display,
{
self.state = value
.try_into()
.map_err(|e| format!("error converting supplied value for state: {e}"));
self
}
}
impl ::std::convert::TryFrom<Input> for super::Input {
type Error = super::error::ConversionError;
fn try_from(
value: Input,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
model: value.model?,
questions: value.questions?,
state: value.state?,
})
}
}
impl ::std::convert::From<super::Input> for Input {
fn from(value: super::Input) -> Self {
Self {
model: Ok(value.model),
questions: Ok(value.questions),
state: Ok(value.state),
}
}
}
#[derive(Clone, Debug)]
pub struct InputQuestionsValue {
criteria: ::std::result::Result<
::std::option::Option<super::InputQuestionsValueCriteria>,
::std::string::String,
>,
instructions: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
type_: ::std::result::Result<
::std::option::Option<super::InputQuestionsValueType>,
::std::string::String,
>,
}
impl ::std::default::Default for InputQuestionsValue {
fn default() -> Self {
Self {
criteria: Ok(Default::default()),
instructions: Ok(Default::default()),
type_: Ok(Default::default()),
}
}
}
impl InputQuestionsValue {
pub fn criteria<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<super::InputQuestionsValueCriteria>,
>,
T::Error: ::std::fmt::Display,
{
self.criteria = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for criteria: {e}")
});
self
}
pub fn instructions<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.instructions = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for instructions: {e}")
});
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<super::InputQuestionsValueType>,
>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
}
impl ::std::convert::TryFrom<InputQuestionsValue> for super::InputQuestionsValue {
type Error = super::error::ConversionError;
fn try_from(
value: InputQuestionsValue,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
criteria: value.criteria?,
instructions: value.instructions?,
type_: value.type_?,
})
}
}
impl ::std::convert::From<super::InputQuestionsValue> for InputQuestionsValue {
fn from(value: super::InputQuestionsValue) -> Self {
Self {
criteria: Ok(value.criteria),
instructions: Ok(value.instructions),
type_: Ok(value.type_),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
pub mod output {
///Successful or error response structure from the decisions endpoint.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Output {
///Answers keyed by the corresponding question names supplied in questions.
#[serde(default, skip_serializing_if = "::std::collections::HashMap::is_empty")]
pub answers: ::std::collections::HashMap<::std::string::String, OutputAnswersValue>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub error: ::std::option::Option<OutputError>,
///The model name sent in the request, echoed back in the response.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub model: ::std::option::Option<::std::string::String>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub usage: ::std::option::Option<OutputUsage>,
}
impl Output {
pub fn builder() -> builder::Output {
Default::default()
}
}
///Answer object whose shape corresponds to the type of the named question.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct OutputAnswersValue {
///Selected choice key for a choice answer.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub choice: ::std::option::Option<::std::string::String>,
///Confidence value returned for documented choice and score answers.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub confidence: ::std::option::Option<f64>,
///Score-level legend for a score answer. Keys are score levels and values are their labels.
#[serde(default, skip_serializing_if = "::std::collections::HashMap::is_empty")]
pub legend: ::std::collections::HashMap<
::std::string::String,
::std::string::String,
>,
///noul result value for a noul answer.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub noul: ::std::option::Option<f64>,
///Probability distribution. For choice answers, keys correspond to choice criteria. For score answers, keys correspond to score levels.
#[serde(default, skip_serializing_if = "::std::collections::HashMap::is_empty")]
pub probabilities: ::std::collections::HashMap<::std::string::String, f64>,
///Numeric score for a score answer.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub score: ::std::option::Option<f64>,
///Answer type.
#[serde(rename = "type", skip_serializing_if = "::std::option::Option::is_none")]
pub type_: ::std::option::Option<OutputAnswersValueType>,
}
impl OutputAnswersValue {
pub fn builder() -> builder::OutputAnswersValue {
Default::default()
}
}
///Answer type.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum OutputAnswersValueType {
#[serde(rename = "noul")]
Noul,
#[serde(rename = "choice")]
Choice,
#[serde(rename = "score")]
Score,
}
impl ::std::fmt::Display for OutputAnswersValueType {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Noul => f.write_str("noul"),
Self::Choice => f.write_str("choice"),
Self::Score => f.write_str("score"),
}
}
}
impl ::std::str::FromStr for OutputAnswersValueType {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"noul" => Ok(Self::Noul),
"choice" => Ok(Self::Choice),
"score" => Ok(Self::Score),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for OutputAnswersValueType {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for OutputAnswersValueType {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Error response body.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct OutputError {
///Error code, if any.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub code: ::std::option::Option<::std::string::String>,
///Human-readable error message.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub message: ::std::option::Option<::std::string::String>,
///Associated parameter name, if any.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub param: ::std::option::Option<::std::string::String>,
///Error type.
#[serde(rename = "type", skip_serializing_if = "::std::option::Option::is_none")]
pub type_: ::std::option::Option<::std::string::String>,
}
impl OutputError {
pub fn builder() -> builder::OutputError {
Default::default()
}
}
///Token usage for the request.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct OutputUsage {
///Number of input tokens processed for the request.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub input_tokens: ::std::option::Option<i64>,
///Number of output tokens generated for the answers.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub output_tokens: ::std::option::Option<i64>,
}
impl OutputUsage {
pub fn builder() -> builder::OutputUsage {
Default::default()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Output {
answers: ::std::result::Result<
::std::collections::HashMap<
::std::string::String,
super::OutputAnswersValue,
>,
::std::string::String,
>,
error: ::std::result::Result<
::std::option::Option<super::OutputError>,
::std::string::String,
>,
model: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
usage: ::std::result::Result<
::std::option::Option<super::OutputUsage>,
::std::string::String,
>,
}
impl ::std::default::Default for Output {
fn default() -> Self {
Self {
answers: Ok(Default::default()),
error: Ok(Default::default()),
model: Ok(Default::default()),
usage: Ok(Default::default()),
}
}
}
impl Output {
pub fn answers<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::collections::HashMap<
::std::string::String,
super::OutputAnswersValue,
>,
>,
T::Error: ::std::fmt::Display,
{
self.answers = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for answers: {e}")
});
self
}
pub fn error<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::OutputError>>,
T::Error: ::std::fmt::Display,
{
self.error = value
.try_into()
.map_err(|e| format!("error converting supplied value for error: {e}"));
self
}
pub fn model<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.model = value
.try_into()
.map_err(|e| format!("error converting supplied value for model: {e}"));
self
}
pub fn usage<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::OutputUsage>>,
T::Error: ::std::fmt::Display,
{
self.usage = value
.try_into()
.map_err(|e| format!("error converting supplied value for usage: {e}"));
self
}
}
impl ::std::convert::TryFrom<Output> for super::Output {
type Error = super::error::ConversionError;
fn try_from(
value: Output,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
answers: value.answers?,
error: value.error?,
model: value.model?,
usage: value.usage?,
})
}
}
impl ::std::convert::From<super::Output> for Output {
fn from(value: super::Output) -> Self {
Self {
answers: Ok(value.answers),
error: Ok(value.error),
model: Ok(value.model),
usage: Ok(value.usage),
}
}
}
#[derive(Clone, Debug)]
pub struct OutputAnswersValue {
choice: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
confidence: ::std::result::Result<
::std::option::Option<f64>,
::std::string::String,
>,
legend: ::std::result::Result<
::std::collections::HashMap<::std::string::String, ::std::string::String>,
::std::string::String,
>,
noul: ::std::result::Result<::std::option::Option<f64>, ::std::string::String>,
probabilities: ::std::result::Result<
::std::collections::HashMap<::std::string::String, f64>,
::std::string::String,
>,
score: ::std::result::Result<::std::option::Option<f64>, ::std::string::String>,
type_: ::std::result::Result<
::std::option::Option<super::OutputAnswersValueType>,
::std::string::String,
>,
}
impl ::std::default::Default for OutputAnswersValue {
fn default() -> Self {
Self {
choice: Ok(Default::default()),
confidence: Ok(Default::default()),
legend: Ok(Default::default()),
noul: Ok(Default::default()),
probabilities: Ok(Default::default()),
score: Ok(Default::default()),
type_: Ok(Default::default()),
}
}
}
impl OutputAnswersValue {
pub fn choice<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.choice = value
.try_into()
.map_err(|e| format!("error converting supplied value for choice: {e}"));
self
}
pub fn confidence<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<f64>>,
T::Error: ::std::fmt::Display,
{
self.confidence = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for confidence: {e}")
});
self
}
pub fn legend<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::collections::HashMap<::std::string::String, ::std::string::String>,
>,
T::Error: ::std::fmt::Display,
{
self.legend = value
.try_into()
.map_err(|e| format!("error converting supplied value for legend: {e}"));
self
}
pub fn noul<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<f64>>,
T::Error: ::std::fmt::Display,
{
self.noul = value
.try_into()
.map_err(|e| format!("error converting supplied value for noul: {e}"));
self
}
pub fn probabilities<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::collections::HashMap<::std::string::String, f64>,
>,
T::Error: ::std::fmt::Display,
{
self.probabilities = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for probabilities: {e}")
});
self
}
pub fn score<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<f64>>,
T::Error: ::std::fmt::Display,
{
self.score = value
.try_into()
.map_err(|e| format!("error converting supplied value for score: {e}"));
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<super::OutputAnswersValueType>,
>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
}
impl ::std::convert::TryFrom<OutputAnswersValue> for super::OutputAnswersValue {
type Error = super::error::ConversionError;
fn try_from(
value: OutputAnswersValue,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
choice: value.choice?,
confidence: value.confidence?,
legend: value.legend?,
noul: value.noul?,
probabilities: value.probabilities?,
score: value.score?,
type_: value.type_?,
})
}
}
impl ::std::convert::From<super::OutputAnswersValue> for OutputAnswersValue {
fn from(value: super::OutputAnswersValue) -> Self {
Self {
choice: Ok(value.choice),
confidence: Ok(value.confidence),
legend: Ok(value.legend),
noul: Ok(value.noul),
probabilities: Ok(value.probabilities),
score: Ok(value.score),
type_: Ok(value.type_),
}
}
}
#[derive(Clone, Debug)]
pub struct OutputError {
code: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
message: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
param: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
type_: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for OutputError {
fn default() -> Self {
Self {
code: Ok(Default::default()),
message: Ok(Default::default()),
param: Ok(Default::default()),
type_: Ok(Default::default()),
}
}
}
impl OutputError {
pub fn code<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.code = value
.try_into()
.map_err(|e| format!("error converting supplied value for code: {e}"));
self
}
pub fn message<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.message = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for message: {e}")
});
self
}
pub fn param<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.param = value
.try_into()
.map_err(|e| format!("error converting supplied value for param: {e}"));
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
}
impl ::std::convert::TryFrom<OutputError> for super::OutputError {
type Error = super::error::ConversionError;
fn try_from(
value: OutputError,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
code: value.code?,
message: value.message?,
param: value.param?,
type_: value.type_?,
})
}
}
impl ::std::convert::From<super::OutputError> for OutputError {
fn from(value: super::OutputError) -> Self {
Self {
code: Ok(value.code),
message: Ok(value.message),
param: Ok(value.param),
type_: Ok(value.type_),
}
}
}
#[derive(Clone, Debug)]
pub struct OutputUsage {
input_tokens: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
output_tokens: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
}
impl ::std::default::Default for OutputUsage {
fn default() -> Self {
Self {
input_tokens: Ok(Default::default()),
output_tokens: Ok(Default::default()),
}
}
}
impl OutputUsage {
pub fn input_tokens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.input_tokens = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for input_tokens: {e}")
});
self
}
pub fn output_tokens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.output_tokens = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for output_tokens: {e}")
});
self
}
}
impl ::std::convert::TryFrom<OutputUsage> for super::OutputUsage {
type Error = super::error::ConversionError;
fn try_from(
value: OutputUsage,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
input_tokens: value.input_tokens?,
output_tokens: value.output_tokens?,
})
}
}
impl ::std::convert::From<super::OutputUsage> for OutputUsage {
fn from(value: super::OutputUsage) -> Self {
Self {
input_tokens: Ok(value.input_tokens),
output_tokens: Ok(value.output_tokens),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
}
/// Where each field of `Input` goes in the request.
pub const ROUTING: ::one::Routing = ::one::Routing { routes: &[::one::Route { field: "model", part: ::one::Part::Body, key: Some("model") }, ::one::Route { field: "questions", part: ::one::Part::Body, key: Some("questions") }, ::one::Route { field: "state", part: ::one::Part::Body, key: Some("state") }], required_parts: &[::one::Part::Body] };
/// Builds the `answer_questions` action.
///
/// # Example input
/// ```json
/// {
/// "model": "pplx-decider-latest",
/// "questions": {
/// "defect": {
/// "instructions": "Does the review report a product defect?",
/// "type": "noul"
/// },
/// "sentiment": {
/// "criteria": {
/// "mixed": "Praise and complaints in one review",
/// "negative": "Mostly dissatisfied",
/// "positive": "Mostly satisfied"
/// },
/// "instructions": "What is the overall sentiment of the review?",
/// "type": "choice"
/// },
/// "severity": {
/// "criteria": [
/// "Cosmetic",
/// "Inconvenient",
/// "Product unusable"
/// ],
/// "instructions": "How severe is the reported problem?",
/// "type": "score"
/// }
/// },
/// "state": {
/// "review": "The headphones sound great, but the battery stopped charging after two weeks.",
/// "title": "Battery died after two weeks"
/// }
/// }
/// ```
pub fn build(input: Input) -> ::std::result::Result<Operation<output::Output>, Error> {
::std::result::Result::Ok(Operation::action("conn_mod_def::GOQ4C3RnlGg::ftX2lIFDQVSYsgMYEpB4hw", Method::POST, "/v1/decisions").with_routed(&input, &ROUTING)?
.merge_headers(::serde_json::from_str("{\"Accept\":\"application/json\",\"Content-Type\":\"application/json\"}").map_err(Error::Decode)?).returns::<output::Output>())
}
impl IntoOperation for Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
build(self)
}
}
impl IntoOperation for builder::Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
Input::try_from(self).map_err(|error| Error::InvalidInput(::std::boxed::Box::new(error))).and_then(build)
}
}
impl ::std::convert::TryFrom<builder::InputQuestionsValue> for ::std::option::Option<InputQuestionsValue> {
type Error = <InputQuestionsValue as ::std::convert::TryFrom<builder::InputQuestionsValue>>::Error;
fn try_from(value: builder::InputQuestionsValue) -> ::std::result::Result<Self, Self::Error> {
InputQuestionsValue::try_from(value).map(Some)
}
}
}
/// Starts building the `answer_questions` action's input; pass the builder to `run`.
pub fn answer_questions() -> answer_questions::builder::Input {
answer_questions::builder::Input::default()
}
pub mod upload_batch_input_file {
use ::one::{Error, IntoOperation, Method, Operation};
///Uploads a JSONL file for batch processing. Each line in the uploaded file is validated before the file is stored. Uploaded files expire 30 days after creation.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct Input {
///The JSONL batch input file to upload. Send as a multipart file field. Maximum size: 200 MB. Maximum content length: 50,000 JSONL lines.
pub file: ::std::string::String,
///The purpose of the uploaded file. Must be `batch`.
pub purpose: InputPurpose,
}
impl Input {
pub fn builder() -> builder::Input {
Default::default()
}
}
///The purpose of the uploaded file. Must be `batch`.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum InputPurpose {
#[serde(rename = "batch")]
Batch,
}
impl ::std::fmt::Display for InputPurpose {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Batch => f.write_str("batch"),
}
}
}
impl ::std::str::FromStr for InputPurpose {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"batch" => Ok(Self::Batch),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for InputPurpose {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for InputPurpose {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Input {
file: ::std::result::Result<::std::string::String, ::std::string::String>,
purpose: ::std::result::Result<super::InputPurpose, ::std::string::String>,
}
impl ::std::default::Default for Input {
fn default() -> Self {
Self {
file: Err("no value supplied for file".to_string()),
purpose: Err("no value supplied for purpose".to_string()),
}
}
}
impl Input {
pub fn file<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::string::String>,
T::Error: ::std::fmt::Display,
{
self.file = value
.try_into()
.map_err(|e| format!("error converting supplied value for file: {e}"));
self
}
pub fn purpose<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::InputPurpose>,
T::Error: ::std::fmt::Display,
{
self.purpose = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for purpose: {e}")
});
self
}
}
impl ::std::convert::TryFrom<Input> for super::Input {
type Error = super::error::ConversionError;
fn try_from(
value: Input,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
file: value.file?,
purpose: value.purpose?,
})
}
}
impl ::std::convert::From<super::Input> for Input {
fn from(value: super::Input) -> Self {
Self {
file: Ok(value.file),
purpose: Ok(value.purpose),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
pub mod output {
///Response structure for successful file upload and documented error responses.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Output {
///Size of the uploaded file in bytes.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub bytes: ::std::option::Option<i64>,
///Unix timestamp, in seconds, when the file was created.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub created_at: ::std::option::Option<i64>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub error: ::std::option::Option<OutputError>,
///Unix timestamp, in seconds, when the file expires.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub expires_at: ::std::option::Option<i64>,
///Original filename of the uploaded file.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub filename: ::std::option::Option<::std::string::String>,
///Unique identifier for the stored file.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub id: ::std::option::Option<::std::string::String>,
///Object type. Always `file`.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub object: ::std::option::Option<OutputObject>,
///File purpose. Values include `batch` for uploaded batch input files and `batch_output` for output and error files.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub purpose: ::std::option::Option<OutputPurpose>,
}
impl Output {
pub fn builder() -> builder::Output {
Default::default()
}
}
///Error information present in error responses.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct OutputError {
///HTTP status code. Present in error responses.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub code: ::std::option::Option<OutputErrorCode>,
///Human-readable error message. Present in error responses.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub message: ::std::option::Option<::std::string::String>,
///Parameter that caused the error, when applicable. Present in error responses.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub param: ::std::option::Option<::std::string::String>,
///Error type identifier. Present in error responses.
#[serde(rename = "type", skip_serializing_if = "::std::option::Option::is_none")]
pub type_: ::std::option::Option<OutputErrorType>,
}
impl OutputError {
pub fn builder() -> builder::OutputError {
Default::default()
}
}
///HTTP status code. Present in error responses.
#[derive(::serde::Serialize, Clone, Debug)]
#[serde(transparent)]
pub struct OutputErrorCode(i64);
impl ::std::ops::Deref for OutputErrorCode {
type Target = i64;
fn deref(&self) -> &i64 {
&self.0
}
}
impl ::std::convert::From<OutputErrorCode> for i64 {
fn from(value: OutputErrorCode) -> Self {
value.0
}
}
impl ::std::str::FromStr for OutputErrorCode {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value
.parse::<i64>()
.map_err(|e| ::std::string::ToString::to_string(&e).into())
.and_then(Self::try_from)
}
}
impl ::std::convert::TryFrom<i64> for OutputErrorCode {
type Error = self::error::ConversionError;
fn try_from(
value: i64,
) -> ::std::result::Result<Self, self::error::ConversionError> {
if ![400_i64, 403_i64, 413_i64, 429_i64].contains(&value) {
Err("invalid value".into())
} else {
Ok(Self(value))
}
}
}
impl<'de> ::serde::Deserialize<'de> for OutputErrorCode {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
Self::try_from(<i64>::deserialize(deserializer)?)
.map_err(|e| { <D::Error as ::serde::de::Error>::custom(e.to_string()) })
}
}
///Error type identifier. Present in error responses.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum OutputErrorType {
#[serde(rename = "invalid_request_error")]
InvalidRequestError,
#[serde(rename = "forbidden_error")]
ForbiddenError,
#[serde(rename = "request_too_large")]
RequestTooLarge,
#[serde(rename = "rate_limit_error")]
RateLimitError,
}
impl ::std::fmt::Display for OutputErrorType {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::InvalidRequestError => f.write_str("invalid_request_error"),
Self::ForbiddenError => f.write_str("forbidden_error"),
Self::RequestTooLarge => f.write_str("request_too_large"),
Self::RateLimitError => f.write_str("rate_limit_error"),
}
}
}
impl ::std::str::FromStr for OutputErrorType {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"invalid_request_error" => Ok(Self::InvalidRequestError),
"forbidden_error" => Ok(Self::ForbiddenError),
"request_too_large" => Ok(Self::RequestTooLarge),
"rate_limit_error" => Ok(Self::RateLimitError),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for OutputErrorType {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for OutputErrorType {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Object type. Always `file`.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum OutputObject {
#[serde(rename = "file")]
File,
}
impl ::std::fmt::Display for OutputObject {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::File => f.write_str("file"),
}
}
}
impl ::std::str::FromStr for OutputObject {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"file" => Ok(Self::File),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for OutputObject {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for OutputObject {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///File purpose. Values include `batch` for uploaded batch input files and `batch_output` for output and error files.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum OutputPurpose {
#[serde(rename = "batch")]
Batch,
#[serde(rename = "batch_output")]
BatchOutput,
}
impl ::std::fmt::Display for OutputPurpose {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Batch => f.write_str("batch"),
Self::BatchOutput => f.write_str("batch_output"),
}
}
}
impl ::std::str::FromStr for OutputPurpose {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"batch" => Ok(Self::Batch),
"batch_output" => Ok(Self::BatchOutput),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for OutputPurpose {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for OutputPurpose {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Output {
bytes: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
created_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
error: ::std::result::Result<
::std::option::Option<super::OutputError>,
::std::string::String,
>,
expires_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
filename: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
object: ::std::result::Result<
::std::option::Option<super::OutputObject>,
::std::string::String,
>,
purpose: ::std::result::Result<
::std::option::Option<super::OutputPurpose>,
::std::string::String,
>,
}
impl ::std::default::Default for Output {
fn default() -> Self {
Self {
bytes: Ok(Default::default()),
created_at: Ok(Default::default()),
error: Ok(Default::default()),
expires_at: Ok(Default::default()),
filename: Ok(Default::default()),
id: Ok(Default::default()),
object: Ok(Default::default()),
purpose: Ok(Default::default()),
}
}
}
impl Output {
pub fn bytes<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.bytes = value
.try_into()
.map_err(|e| format!("error converting supplied value for bytes: {e}"));
self
}
pub fn created_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.created_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for created_at: {e}")
});
self
}
pub fn error<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::OutputError>>,
T::Error: ::std::fmt::Display,
{
self.error = value
.try_into()
.map_err(|e| format!("error converting supplied value for error: {e}"));
self
}
pub fn expires_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.expires_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for expires_at: {e}")
});
self
}
pub fn filename<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.filename = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for filename: {e}")
});
self
}
pub fn id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.id = value
.try_into()
.map_err(|e| format!("error converting supplied value for id: {e}"));
self
}
pub fn object<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::OutputObject>>,
T::Error: ::std::fmt::Display,
{
self.object = value
.try_into()
.map_err(|e| format!("error converting supplied value for object: {e}"));
self
}
pub fn purpose<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::OutputPurpose>>,
T::Error: ::std::fmt::Display,
{
self.purpose = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for purpose: {e}")
});
self
}
}
impl ::std::convert::TryFrom<Output> for super::Output {
type Error = super::error::ConversionError;
fn try_from(
value: Output,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
bytes: value.bytes?,
created_at: value.created_at?,
error: value.error?,
expires_at: value.expires_at?,
filename: value.filename?,
id: value.id?,
object: value.object?,
purpose: value.purpose?,
})
}
}
impl ::std::convert::From<super::Output> for Output {
fn from(value: super::Output) -> Self {
Self {
bytes: Ok(value.bytes),
created_at: Ok(value.created_at),
error: Ok(value.error),
expires_at: Ok(value.expires_at),
filename: Ok(value.filename),
id: Ok(value.id),
object: Ok(value.object),
purpose: Ok(value.purpose),
}
}
}
#[derive(Clone, Debug)]
pub struct OutputError {
code: ::std::result::Result<
::std::option::Option<super::OutputErrorCode>,
::std::string::String,
>,
message: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
param: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
type_: ::std::result::Result<
::std::option::Option<super::OutputErrorType>,
::std::string::String,
>,
}
impl ::std::default::Default for OutputError {
fn default() -> Self {
Self {
code: Ok(Default::default()),
message: Ok(Default::default()),
param: Ok(Default::default()),
type_: Ok(Default::default()),
}
}
}
impl OutputError {
pub fn code<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::OutputErrorCode>>,
T::Error: ::std::fmt::Display,
{
self.code = value
.try_into()
.map_err(|e| format!("error converting supplied value for code: {e}"));
self
}
pub fn message<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.message = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for message: {e}")
});
self
}
pub fn param<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.param = value
.try_into()
.map_err(|e| format!("error converting supplied value for param: {e}"));
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::OutputErrorType>>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
}
impl ::std::convert::TryFrom<OutputError> for super::OutputError {
type Error = super::error::ConversionError;
fn try_from(
value: OutputError,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
code: value.code?,
message: value.message?,
param: value.param?,
type_: value.type_?,
})
}
}
impl ::std::convert::From<super::OutputError> for OutputError {
fn from(value: super::OutputError) -> Self {
Self {
code: Ok(value.code),
message: Ok(value.message),
param: Ok(value.param),
type_: Ok(value.type_),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
}
/// Where each field of `Input` goes in the request.
pub const ROUTING: ::one::Routing = ::one::Routing { routes: &[::one::Route { field: "file", part: ::one::Part::Body, key: Some("file") }, ::one::Route { field: "purpose", part: ::one::Part::Body, key: Some("purpose") }], required_parts: &[::one::Part::Body] };
/// Builds the `upload_batch_input_file` action.
///
/// # Example input
/// ```json
/// {
/// "file": "@customer-support-batch.jsonl",
/// "purpose": "batch"
/// }
/// ```
pub fn build(input: Input) -> ::std::result::Result<Operation<output::Output>, Error> {
::std::result::Result::Ok(Operation::action("conn_mod_def::GOQ4C3-c16g::ip7Zrl7dS0GxYogF8tkVnw", Method::POST, "/v1/files").with_routed(&input, &ROUTING)?
.merge_headers(::serde_json::from_str("{\"Accept\":\"application/json\",\"Content-Type\":\"multipart/form-data\"}").map_err(Error::Decode)?).returns::<output::Output>())
}
impl IntoOperation for Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
build(self)
}
}
impl IntoOperation for builder::Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
Input::try_from(self).map_err(|error| Error::InvalidInput(::std::boxed::Box::new(error))).and_then(build)
}
}
}
/// Starts building the `upload_batch_input_file` action's input; pass the builder to `run`.
pub fn upload_batch_input_file() -> upload_batch_input_file::builder::Input {
upload_batch_input_file::builder::Input::default()
}
pub mod list_organization_files {
use ::one::{Error, IntoOperation, Method, Operation};
///Lists files belonging to the organization, including uploaded batch files and output or error files produced by batch operations. Deleted and expired files are not included in the response.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
#[serde(deny_unknown_fields)]
pub struct Input {
///File ID after which to begin listing files. Use the last_id value from the previous page to retrieve the next page. Send as a URL query parameter.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub after_id: ::std::option::Option<::std::string::String>,
///Maximum number of files to return. Send as a URL query parameter.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub limit: ::std::option::Option<i64>,
///Sort order. Allowed values: asc or desc. Use desc for newest files first. Send as a URL query parameter.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub order: ::std::option::Option<InputOrder>,
///Filters files by purpose. Allowed values: batch for uploaded batch files, or batch_output for batch output and error files. Send as a URL query parameter.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub purpose: ::std::option::Option<InputPurpose>,
}
impl Input {
pub fn builder() -> builder::Input {
Default::default()
}
}
///Sort order. Allowed values: asc or desc. Use desc for newest files first. Send as a URL query parameter.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum InputOrder {
#[serde(rename = "asc")]
Asc,
#[serde(rename = "desc")]
Desc,
}
impl ::std::fmt::Display for InputOrder {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Asc => f.write_str("asc"),
Self::Desc => f.write_str("desc"),
}
}
}
impl ::std::str::FromStr for InputOrder {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"asc" => Ok(Self::Asc),
"desc" => Ok(Self::Desc),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for InputOrder {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for InputOrder {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Filters files by purpose. Allowed values: batch for uploaded batch files, or batch_output for batch output and error files. Send as a URL query parameter.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum InputPurpose {
#[serde(rename = "batch")]
Batch,
#[serde(rename = "batch_output")]
BatchOutput,
}
impl ::std::fmt::Display for InputPurpose {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Batch => f.write_str("batch"),
Self::BatchOutput => f.write_str("batch_output"),
}
}
}
impl ::std::str::FromStr for InputPurpose {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"batch" => Ok(Self::Batch),
"batch_output" => Ok(Self::BatchOutput),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for InputPurpose {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for InputPurpose {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Input {
after_id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
limit: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
order: ::std::result::Result<
::std::option::Option<super::InputOrder>,
::std::string::String,
>,
purpose: ::std::result::Result<
::std::option::Option<super::InputPurpose>,
::std::string::String,
>,
}
impl ::std::default::Default for Input {
fn default() -> Self {
Self {
after_id: Ok(Default::default()),
limit: Ok(Default::default()),
order: Ok(Default::default()),
purpose: Ok(Default::default()),
}
}
}
impl Input {
pub fn after_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.after_id = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for after_id: {e}")
});
self
}
pub fn limit<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.limit = value
.try_into()
.map_err(|e| format!("error converting supplied value for limit: {e}"));
self
}
pub fn order<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::InputOrder>>,
T::Error: ::std::fmt::Display,
{
self.order = value
.try_into()
.map_err(|e| format!("error converting supplied value for order: {e}"));
self
}
pub fn purpose<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::InputPurpose>>,
T::Error: ::std::fmt::Display,
{
self.purpose = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for purpose: {e}")
});
self
}
}
impl ::std::convert::TryFrom<Input> for super::Input {
type Error = super::error::ConversionError;
fn try_from(
value: Input,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
after_id: value.after_id?,
limit: value.limit?,
order: value.order?,
purpose: value.purpose?,
})
}
}
impl ::std::convert::From<super::Input> for Input {
fn from(value: super::Input) -> Self {
Self {
after_id: Ok(value.after_id),
limit: Ok(value.limit),
order: Ok(value.order),
purpose: Ok(value.purpose),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
pub mod output {
///Error object returned for failed requests.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct ErrorObject {
///HTTP status code associated with the error.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub code: ::std::option::Option<i64>,
///Human-readable error message.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub message: ::std::option::Option<::std::string::String>,
///Optional parameter name that caused the error.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub param: ::std::option::Option<::std::string::String>,
///Error type identifier.
#[serde(rename = "type", skip_serializing_if = "::std::option::Option::is_none")]
pub type_: ::std::option::Option<::std::string::String>,
}
impl ErrorObject {
pub fn builder() -> builder::ErrorObject {
Default::default()
}
}
///Represents a file belonging to the organization.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct FileObject {
///Size of the file in bytes.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub bytes: ::std::option::Option<i64>,
///Unix timestamp, in seconds, indicating when the file was created.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub created_at: ::std::option::Option<i64>,
///Optional Unix timestamp, in seconds, indicating when the file expires.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub expires_at: ::std::option::Option<i64>,
///Original filename.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub filename: ::std::option::Option<::std::string::String>,
///Unique identifier for the file.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub id: ::std::option::Option<::std::string::String>,
///Object type for each item. The value is file.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub object: ::std::option::Option<FileObjectObject>,
///File purpose. Possible values are batch for uploads and batch_output for output and error files.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub purpose: ::std::option::Option<FileObjectPurpose>,
}
impl FileObject {
pub fn builder() -> builder::FileObject {
Default::default()
}
}
///Object type for each item. The value is file.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum FileObjectObject {
#[serde(rename = "file")]
File,
}
impl ::std::fmt::Display for FileObjectObject {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::File => f.write_str("file"),
}
}
}
impl ::std::str::FromStr for FileObjectObject {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"file" => Ok(Self::File),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for FileObjectObject {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for FileObjectObject {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///File purpose. Possible values are batch for uploads and batch_output for output and error files.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum FileObjectPurpose {
#[serde(rename = "batch")]
Batch,
#[serde(rename = "batch_output")]
BatchOutput,
}
impl ::std::fmt::Display for FileObjectPurpose {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Batch => f.write_str("batch"),
Self::BatchOutput => f.write_str("batch_output"),
}
}
}
impl ::std::str::FromStr for FileObjectPurpose {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"batch" => Ok(Self::Batch),
"batch_output" => Ok(Self::BatchOutput),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for FileObjectPurpose {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for FileObjectPurpose {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Response structure for listing organization files, including success and error responses.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Output {
///Array of file objects.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub data: ::std::vec::Vec<FileObject>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub error: ::std::option::Option<ErrorObject>,
///ID of the first file in the returned page, when present.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub first_id: ::std::option::Option<::std::string::String>,
///Whether additional files are available after the current page.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub has_more: ::std::option::Option<bool>,
///ID of the last file in the returned page, when present. Use this value as after_id to retrieve the next page.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub last_id: ::std::option::Option<::std::string::String>,
///Response object type. The value is list.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub object: ::std::option::Option<OutputObject>,
}
impl Output {
pub fn builder() -> builder::Output {
Default::default()
}
}
///Response object type. The value is list.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum OutputObject {
#[serde(rename = "list")]
List,
}
impl ::std::fmt::Display for OutputObject {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::List => f.write_str("list"),
}
}
}
impl ::std::str::FromStr for OutputObject {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"list" => Ok(Self::List),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for OutputObject {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for OutputObject {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct ErrorObject {
code: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
message: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
param: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
type_: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for ErrorObject {
fn default() -> Self {
Self {
code: Ok(Default::default()),
message: Ok(Default::default()),
param: Ok(Default::default()),
type_: Ok(Default::default()),
}
}
}
impl ErrorObject {
pub fn code<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.code = value
.try_into()
.map_err(|e| format!("error converting supplied value for code: {e}"));
self
}
pub fn message<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.message = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for message: {e}")
});
self
}
pub fn param<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.param = value
.try_into()
.map_err(|e| format!("error converting supplied value for param: {e}"));
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
}
impl ::std::convert::TryFrom<ErrorObject> for super::ErrorObject {
type Error = super::error::ConversionError;
fn try_from(
value: ErrorObject,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
code: value.code?,
message: value.message?,
param: value.param?,
type_: value.type_?,
})
}
}
impl ::std::convert::From<super::ErrorObject> for ErrorObject {
fn from(value: super::ErrorObject) -> Self {
Self {
code: Ok(value.code),
message: Ok(value.message),
param: Ok(value.param),
type_: Ok(value.type_),
}
}
}
#[derive(Clone, Debug)]
pub struct FileObject {
bytes: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
created_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
expires_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
filename: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
object: ::std::result::Result<
::std::option::Option<super::FileObjectObject>,
::std::string::String,
>,
purpose: ::std::result::Result<
::std::option::Option<super::FileObjectPurpose>,
::std::string::String,
>,
}
impl ::std::default::Default for FileObject {
fn default() -> Self {
Self {
bytes: Ok(Default::default()),
created_at: Ok(Default::default()),
expires_at: Ok(Default::default()),
filename: Ok(Default::default()),
id: Ok(Default::default()),
object: Ok(Default::default()),
purpose: Ok(Default::default()),
}
}
}
impl FileObject {
pub fn bytes<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.bytes = value
.try_into()
.map_err(|e| format!("error converting supplied value for bytes: {e}"));
self
}
pub fn created_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.created_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for created_at: {e}")
});
self
}
pub fn expires_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.expires_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for expires_at: {e}")
});
self
}
pub fn filename<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.filename = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for filename: {e}")
});
self
}
pub fn id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.id = value
.try_into()
.map_err(|e| format!("error converting supplied value for id: {e}"));
self
}
pub fn object<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::FileObjectObject>>,
T::Error: ::std::fmt::Display,
{
self.object = value
.try_into()
.map_err(|e| format!("error converting supplied value for object: {e}"));
self
}
pub fn purpose<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::FileObjectPurpose>>,
T::Error: ::std::fmt::Display,
{
self.purpose = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for purpose: {e}")
});
self
}
}
impl ::std::convert::TryFrom<FileObject> for super::FileObject {
type Error = super::error::ConversionError;
fn try_from(
value: FileObject,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
bytes: value.bytes?,
created_at: value.created_at?,
expires_at: value.expires_at?,
filename: value.filename?,
id: value.id?,
object: value.object?,
purpose: value.purpose?,
})
}
}
impl ::std::convert::From<super::FileObject> for FileObject {
fn from(value: super::FileObject) -> Self {
Self {
bytes: Ok(value.bytes),
created_at: Ok(value.created_at),
expires_at: Ok(value.expires_at),
filename: Ok(value.filename),
id: Ok(value.id),
object: Ok(value.object),
purpose: Ok(value.purpose),
}
}
}
#[derive(Clone, Debug)]
pub struct Output {
data: ::std::result::Result<
::std::vec::Vec<super::FileObject>,
::std::string::String,
>,
error: ::std::result::Result<
::std::option::Option<super::ErrorObject>,
::std::string::String,
>,
first_id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
has_more: ::std::result::Result<
::std::option::Option<bool>,
::std::string::String,
>,
last_id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
object: ::std::result::Result<
::std::option::Option<super::OutputObject>,
::std::string::String,
>,
}
impl ::std::default::Default for Output {
fn default() -> Self {
Self {
data: Ok(Default::default()),
error: Ok(Default::default()),
first_id: Ok(Default::default()),
has_more: Ok(Default::default()),
last_id: Ok(Default::default()),
object: Ok(Default::default()),
}
}
}
impl Output {
pub fn data<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::FileObject>>,
T::Error: ::std::fmt::Display,
{
self.data = value
.try_into()
.map_err(|e| format!("error converting supplied value for data: {e}"));
self
}
pub fn error<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ErrorObject>>,
T::Error: ::std::fmt::Display,
{
self.error = value
.try_into()
.map_err(|e| format!("error converting supplied value for error: {e}"));
self
}
pub fn first_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.first_id = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for first_id: {e}")
});
self
}
pub fn has_more<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<bool>>,
T::Error: ::std::fmt::Display,
{
self.has_more = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for has_more: {e}")
});
self
}
pub fn last_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.last_id = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for last_id: {e}")
});
self
}
pub fn object<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::OutputObject>>,
T::Error: ::std::fmt::Display,
{
self.object = value
.try_into()
.map_err(|e| format!("error converting supplied value for object: {e}"));
self
}
}
impl ::std::convert::TryFrom<Output> for super::Output {
type Error = super::error::ConversionError;
fn try_from(
value: Output,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
data: value.data?,
error: value.error?,
first_id: value.first_id?,
has_more: value.has_more?,
last_id: value.last_id?,
object: value.object?,
})
}
}
impl ::std::convert::From<super::Output> for Output {
fn from(value: super::Output) -> Self {
Self {
data: Ok(value.data),
error: Ok(value.error),
first_id: Ok(value.first_id),
has_more: Ok(value.has_more),
last_id: Ok(value.last_id),
object: Ok(value.object),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
}
/// Where each field of `Input` goes in the request.
pub const ROUTING: ::one::Routing = ::one::Routing { routes: &[::one::Route { field: "after_id", part: ::one::Part::Query, key: Some("after_id") }, ::one::Route { field: "limit", part: ::one::Part::Query, key: Some("limit") }, ::one::Route { field: "order", part: ::one::Part::Query, key: Some("order") }, ::one::Route { field: "purpose", part: ::one::Part::Query, key: Some("purpose") }], required_parts: &[] };
/// Builds the `list_organization_files` action.
///
/// # Example input
/// ```json
/// {
/// "after_id": "file_01JQZ8J6K9L2M5N8P1R4S7T0V3",
/// "limit": 20,
/// "order": "desc",
/// "purpose": "batch"
/// }
/// ```
pub fn build(input: Input) -> ::std::result::Result<Operation<output::Output>, Error> {
::std::result::Result::Ok(Operation::action("conn_mod_def::GOQ4C4ADJxA::GjuOjehzSNy9beABVaA0zQ", Method::GET, "/v1/files").with_routed(&input, &ROUTING)?
.merge_headers(::serde_json::from_str("{\"Accept\":\"application/json\"}").map_err(Error::Decode)?).returns::<output::Output>())
}
impl IntoOperation for Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
build(self)
}
}
impl IntoOperation for builder::Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
Input::try_from(self).map_err(|error| Error::InvalidInput(::std::boxed::Box::new(error))).and_then(build)
}
}
}
/// Starts building the `list_organization_files` action's input; pass the builder to `run`.
pub fn list_organization_files() -> list_organization_files::builder::Input {
list_organization_files::builder::Input::default()
}
pub mod list_available_agent_api_models {
use ::one::{Error, IntoOperation, Method, Operation};
///Lists the models available for the Agent API.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
#[serde(deny_unknown_fields)]
pub struct Input {}
impl Input {
pub fn builder() -> builder::Input {
Default::default()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Input {}
impl ::std::default::Default for Input {
fn default() -> Self {
Self {}
}
}
impl Input {}
impl ::std::convert::TryFrom<Input> for super::Input {
type Error = super::error::ConversionError;
fn try_from(
_value: Input,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {})
}
}
impl ::std::convert::From<super::Input> for Input {
fn from(_value: super::Input) -> Self {
Self {}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
pub mod output {
///A model entry in provider/model-name format.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct ModelObject {
///Unix timestamp, in seconds, indicating when the model was created.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub created: ::std::option::Option<i64>,
///Model identifier in `provider/model-name` format. Use this value as the `model` parameter in Agent API requests.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub id: ::std::option::Option<::std::string::String>,
///The model object type. Always `model`.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub object: ::std::option::Option<ModelObjectObject>,
///Provider that owns the model. Examples include `openai`, `anthropic`, `google`, `perplexity`, `xai`, `z-ai`, `moonshotai`, and `nvidia`.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub owned_by: ::std::option::Option<::std::string::String>,
}
impl ModelObject {
pub fn builder() -> builder::ModelObject {
Default::default()
}
}
///The model object type. Always `model`.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum ModelObjectObject {
#[serde(rename = "model")]
Model,
}
impl ::std::fmt::Display for ModelObjectObject {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Model => f.write_str("model"),
}
}
}
impl ::std::str::FromStr for ModelObjectObject {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"model" => Ok(Self::Model),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for ModelObjectObject {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ModelObjectObject {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Lists the models available for the Agent API. The response uses the OpenAI List Models format for compatibility with third-party tools.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Output {
///List of available model objects.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub data: ::std::vec::Vec<ModelObject>,
///The response object type. Always `list`.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub object: ::std::option::Option<OutputObject>,
}
impl Output {
pub fn builder() -> builder::Output {
Default::default()
}
}
///The response object type. Always `list`.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum OutputObject {
#[serde(rename = "list")]
List,
}
impl ::std::fmt::Display for OutputObject {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::List => f.write_str("list"),
}
}
}
impl ::std::str::FromStr for OutputObject {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"list" => Ok(Self::List),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for OutputObject {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for OutputObject {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct ModelObject {
created: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
object: ::std::result::Result<
::std::option::Option<super::ModelObjectObject>,
::std::string::String,
>,
owned_by: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for ModelObject {
fn default() -> Self {
Self {
created: Ok(Default::default()),
id: Ok(Default::default()),
object: Ok(Default::default()),
owned_by: Ok(Default::default()),
}
}
}
impl ModelObject {
pub fn created<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.created = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for created: {e}")
});
self
}
pub fn id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.id = value
.try_into()
.map_err(|e| format!("error converting supplied value for id: {e}"));
self
}
pub fn object<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ModelObjectObject>>,
T::Error: ::std::fmt::Display,
{
self.object = value
.try_into()
.map_err(|e| format!("error converting supplied value for object: {e}"));
self
}
pub fn owned_by<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.owned_by = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for owned_by: {e}")
});
self
}
}
impl ::std::convert::TryFrom<ModelObject> for super::ModelObject {
type Error = super::error::ConversionError;
fn try_from(
value: ModelObject,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
created: value.created?,
id: value.id?,
object: value.object?,
owned_by: value.owned_by?,
})
}
}
impl ::std::convert::From<super::ModelObject> for ModelObject {
fn from(value: super::ModelObject) -> Self {
Self {
created: Ok(value.created),
id: Ok(value.id),
object: Ok(value.object),
owned_by: Ok(value.owned_by),
}
}
}
#[derive(Clone, Debug)]
pub struct Output {
data: ::std::result::Result<
::std::vec::Vec<super::ModelObject>,
::std::string::String,
>,
object: ::std::result::Result<
::std::option::Option<super::OutputObject>,
::std::string::String,
>,
}
impl ::std::default::Default for Output {
fn default() -> Self {
Self {
data: Ok(Default::default()),
object: Ok(Default::default()),
}
}
}
impl Output {
pub fn data<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::ModelObject>>,
T::Error: ::std::fmt::Display,
{
self.data = value
.try_into()
.map_err(|e| format!("error converting supplied value for data: {e}"));
self
}
pub fn object<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::OutputObject>>,
T::Error: ::std::fmt::Display,
{
self.object = value
.try_into()
.map_err(|e| format!("error converting supplied value for object: {e}"));
self
}
}
impl ::std::convert::TryFrom<Output> for super::Output {
type Error = super::error::ConversionError;
fn try_from(
value: Output,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
data: value.data?,
object: value.object?,
})
}
}
impl ::std::convert::From<super::Output> for Output {
fn from(value: super::Output) -> Self {
Self {
data: Ok(value.data),
object: Ok(value.object),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
}
/// Where each field of `Input` goes in the request.
pub const ROUTING: ::one::Routing = ::one::Routing { routes: &[], required_parts: &[] };
/// Builds the `list_available_agent_api_models` action.
///
/// # Example input
/// ```json
/// {}
/// ```
pub fn build(input: Input) -> ::std::result::Result<Operation<output::Output>, Error> {
::std::result::Result::Ok(Operation::action("conn_mod_def::GOQ4C_mphGA::NM3qTBtiRKKKrFiCZw5WlA", Method::GET, "/v1/models").with_routed(&input, &ROUTING)?
.merge_headers(::serde_json::from_str("{\"Accept\":\"application/json\"}").map_err(Error::Decode)?).returns::<output::Output>())
}
impl IntoOperation for Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
build(self)
}
}
impl IntoOperation for builder::Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
Input::try_from(self).map_err(|error| Error::InvalidInput(::std::boxed::Box::new(error))).and_then(build)
}
}
}
/// Starts building the `list_available_agent_api_models` action's input; pass the builder to `run`.
pub fn list_available_agent_api_models() -> list_available_agent_api_models::builder::Input {
list_available_agent_api_models::builder::Input::default()
}
pub mod cancel_agent_response {
use ::one::{Error, IntoOperation, Method, Operation};
///Requests cancellation of an agent response. Cancellation acts on durable state, so it can cancel background runs that outlive the client connection.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct Input {
///Response ID to cancel. Must use the `resp_<...>` format. Send in the URL path.
pub id: InputId,
}
impl Input {
pub fn builder() -> builder::Input {
Default::default()
}
}
///Response ID to cancel. Must use the `resp_<...>` format. Send in the URL path.
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct InputId(::std::string::String);
impl ::std::ops::Deref for InputId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<InputId> for ::std::string::String {
fn from(value: InputId) -> Self {
value.0
}
}
impl ::std::str::FromStr for InputId {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
::std::convert::TryFrom::try_from(value)
}
}
impl ::std::convert::TryFrom<&str> for InputId {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
static PATTERN: ::std::sync::LazyLock<::regress::Regex> = ::std::sync::LazyLock::new(||
{ ::regress::Regex::with_flags("^resp_.+$", "u").unwrap() });
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^resp_.+$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<::std::string::String> for InputId {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
::std::convert::TryFrom::try_from(value.as_str())
}
}
impl<'de> ::serde::Deserialize<'de> for InputId {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::convert::TryFrom::try_from(
::std::string::String::deserialize(deserializer)?,
)
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Input {
id: ::std::result::Result<super::InputId, ::std::string::String>,
}
impl ::std::default::Default for Input {
fn default() -> Self {
Self {
id: Err("no value supplied for id".to_string()),
}
}
}
impl Input {
pub fn id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::InputId>,
T::Error: ::std::fmt::Display,
{
self.id = value
.try_into()
.map_err(|e| format!("error converting supplied value for id: {e}"));
self
}
}
impl ::std::convert::TryFrom<Input> for super::Input {
type Error = super::error::ConversionError;
fn try_from(
value: Input,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self { id: value.id? })
}
}
impl ::std::convert::From<super::Input> for Input {
fn from(value: super::Input) -> Self {
Self { id: Ok(value.id) }
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
pub mod output {
///Error details, present in `400` and `404` responses.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Error {
///Error code.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub code: ::std::option::Option<ErrorCode>,
///Human-readable error message.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub message: ::std::option::Option<::std::string::String>,
///Error type category.
#[serde(rename = "type", skip_serializing_if = "::std::option::Option::is_none")]
pub type_: ::std::option::Option<ErrorType>,
}
impl Error {
pub fn builder() -> builder::Error {
Default::default()
}
}
///Error code.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum ErrorCode {
#[serde(rename = "invalid_request")]
InvalidRequest,
#[serde(rename = "not_found")]
NotFound,
}
impl ::std::fmt::Display for ErrorCode {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::InvalidRequest => f.write_str("invalid_request"),
Self::NotFound => f.write_str("not_found"),
}
}
}
impl ::std::str::FromStr for ErrorCode {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"invalid_request" => Ok(Self::InvalidRequest),
"not_found" => Ok(Self::NotFound),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for ErrorCode {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ErrorCode {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Error type category.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum ErrorType {
#[serde(rename = "invalid_request_error")]
InvalidRequestError,
#[serde(rename = "not_found_error")]
NotFoundError,
}
impl ::std::fmt::Display for ErrorType {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::InvalidRequestError => f.write_str("invalid_request_error"),
Self::NotFoundError => f.write_str("not_found_error"),
}
}
}
impl ::std::str::FromStr for ErrorType {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"invalid_request_error" => Ok(Self::InvalidRequestError),
"not_found_error" => Ok(Self::NotFoundError),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for ErrorType {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ErrorType {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Asynchronous cancellation acknowledgement or error response for cancelling an agent response.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Output {
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub error: ::std::option::Option<Error>,
///The cancelled response ID in `resp_<...>` format. Present in successful responses.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub response_id: ::std::option::Option<OutputResponseId>,
///Always `cancelling` for a successful cancellation request. The response will stop asynchronously.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub status: ::std::option::Option<OutputStatus>,
}
impl Output {
pub fn builder() -> builder::Output {
Default::default()
}
}
///The cancelled response ID in `resp_<...>` format. Present in successful responses.
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct OutputResponseId(::std::string::String);
impl ::std::ops::Deref for OutputResponseId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<OutputResponseId> for ::std::string::String {
fn from(value: OutputResponseId) -> Self {
value.0
}
}
impl ::std::str::FromStr for OutputResponseId {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
::std::convert::TryFrom::try_from(value)
}
}
impl ::std::convert::TryFrom<&str> for OutputResponseId {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
static PATTERN: ::std::sync::LazyLock<::regress::Regex> = ::std::sync::LazyLock::new(||
{ ::regress::Regex::with_flags("^resp_.+$", "u").unwrap() });
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^resp_.+$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<::std::string::String> for OutputResponseId {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
::std::convert::TryFrom::try_from(value.as_str())
}
}
impl<'de> ::serde::Deserialize<'de> for OutputResponseId {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::convert::TryFrom::try_from(
::std::string::String::deserialize(deserializer)?,
)
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///Always `cancelling` for a successful cancellation request. The response will stop asynchronously.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum OutputStatus {
#[serde(rename = "cancelling")]
Cancelling,
}
impl ::std::fmt::Display for OutputStatus {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Cancelling => f.write_str("cancelling"),
}
}
}
impl ::std::str::FromStr for OutputStatus {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"cancelling" => Ok(Self::Cancelling),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for OutputStatus {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for OutputStatus {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Error {
code: ::std::result::Result<
::std::option::Option<super::ErrorCode>,
::std::string::String,
>,
message: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
type_: ::std::result::Result<
::std::option::Option<super::ErrorType>,
::std::string::String,
>,
}
impl ::std::default::Default for Error {
fn default() -> Self {
Self {
code: Ok(Default::default()),
message: Ok(Default::default()),
type_: Ok(Default::default()),
}
}
}
impl Error {
pub fn code<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ErrorCode>>,
T::Error: ::std::fmt::Display,
{
self.code = value
.try_into()
.map_err(|e| format!("error converting supplied value for code: {e}"));
self
}
pub fn message<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.message = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for message: {e}")
});
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ErrorType>>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
}
impl ::std::convert::TryFrom<Error> for super::Error {
type Error = super::error::ConversionError;
fn try_from(
value: Error,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
code: value.code?,
message: value.message?,
type_: value.type_?,
})
}
}
impl ::std::convert::From<super::Error> for Error {
fn from(value: super::Error) -> Self {
Self {
code: Ok(value.code),
message: Ok(value.message),
type_: Ok(value.type_),
}
}
}
#[derive(Clone, Debug)]
pub struct Output {
error: ::std::result::Result<
::std::option::Option<super::Error>,
::std::string::String,
>,
response_id: ::std::result::Result<
::std::option::Option<super::OutputResponseId>,
::std::string::String,
>,
status: ::std::result::Result<
::std::option::Option<super::OutputStatus>,
::std::string::String,
>,
}
impl ::std::default::Default for Output {
fn default() -> Self {
Self {
error: Ok(Default::default()),
response_id: Ok(Default::default()),
status: Ok(Default::default()),
}
}
}
impl Output {
pub fn error<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Error>>,
T::Error: ::std::fmt::Display,
{
self.error = value
.try_into()
.map_err(|e| format!("error converting supplied value for error: {e}"));
self
}
pub fn response_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::OutputResponseId>>,
T::Error: ::std::fmt::Display,
{
self.response_id = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for response_id: {e}")
});
self
}
pub fn status<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::OutputStatus>>,
T::Error: ::std::fmt::Display,
{
self.status = value
.try_into()
.map_err(|e| format!("error converting supplied value for status: {e}"));
self
}
}
impl ::std::convert::TryFrom<Output> for super::Output {
type Error = super::error::ConversionError;
fn try_from(
value: Output,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
error: value.error?,
response_id: value.response_id?,
status: value.status?,
})
}
}
impl ::std::convert::From<super::Output> for Output {
fn from(value: super::Output) -> Self {
Self {
error: Ok(value.error),
response_id: Ok(value.response_id),
status: Ok(value.status),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
}
/// Where each field of `Input` goes in the request.
pub const ROUTING: ::one::Routing = ::one::Routing { routes: &[::one::Route { field: "id", part: ::one::Part::Path, key: Some("id") }], required_parts: &[::one::Part::Path] };
/// Builds the `cancel_agent_response` action.
///
/// # Example input
/// ```json
/// {
/// "id": "resp_01JABCDEF123456789"
/// }
/// ```
pub fn build(input: Input) -> ::std::result::Result<Operation<output::Output>, Error> {
::std::result::Result::Ok(Operation::action("conn_mod_def::GOQ4C_ow__g::-HDfrxXrRLKWMZR_WKA_nA", Method::POST, "/v1/agent/{{id}}/cancel").with_routed(&input, &ROUTING)?
.merge_headers(::serde_json::from_str("{\"Accept\":\"application/json\"}").map_err(Error::Decode)?).returns::<output::Output>())
}
impl IntoOperation for Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
build(self)
}
}
impl IntoOperation for builder::Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
Input::try_from(self).map_err(|error| Error::InvalidInput(::std::boxed::Box::new(error))).and_then(build)
}
}
}
/// Starts building the `cancel_agent_response` action's input; pass the builder to `run`.
pub fn cancel_agent_response() -> cancel_agent_response::builder::Input {
cancel_agent_response::builder::Input::default()
}
pub mod download_agent_response_file {
use ::one::{Error, IntoOperation, Method, Operation};
///Downloads the raw bytes of a file delivered by an agent response through the `share_file` tool. The response is streamed as file content rather than JSON, with a content type matching the downloaded file and an attachment filename supplied in the `Content-Disposition` response header.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct Input {
///File ID obtained from the file list endpoint. This is distinct from the response ID. Send this value in the URL path.
#[serde(rename = "fileId")]
pub file_id: InputFileId,
///Response ID in the format `resp_<...>`. Send this value in the URL path.
pub id: InputId,
}
impl Input {
pub fn builder() -> builder::Input {
Default::default()
}
}
///File ID obtained from the file list endpoint. This is distinct from the response ID. Send this value in the URL path.
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct InputFileId(::std::string::String);
impl ::std::ops::Deref for InputFileId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<InputFileId> for ::std::string::String {
fn from(value: InputFileId) -> Self {
value.0
}
}
impl ::std::str::FromStr for InputFileId {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
::std::convert::TryFrom::try_from(value)
}
}
impl ::std::convert::TryFrom<&str> for InputFileId {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<::std::string::String> for InputFileId {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
::std::convert::TryFrom::try_from(value.as_str())
}
}
impl<'de> ::serde::Deserialize<'de> for InputFileId {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::convert::TryFrom::try_from(
::std::string::String::deserialize(deserializer)?,
)
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///Response ID in the format `resp_<...>`. Send this value in the URL path.
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct InputId(::std::string::String);
impl ::std::ops::Deref for InputId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<InputId> for ::std::string::String {
fn from(value: InputId) -> Self {
value.0
}
}
impl ::std::str::FromStr for InputId {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
::std::convert::TryFrom::try_from(value)
}
}
impl ::std::convert::TryFrom<&str> for InputId {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
static PATTERN: ::std::sync::LazyLock<::regress::Regex> = ::std::sync::LazyLock::new(||
{ ::regress::Regex::with_flags("^resp_.+", "u").unwrap() });
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^resp_.+\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<::std::string::String> for InputId {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
::std::convert::TryFrom::try_from(value.as_str())
}
}
impl<'de> ::serde::Deserialize<'de> for InputId {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::convert::TryFrom::try_from(
::std::string::String::deserialize(deserializer)?,
)
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Input {
file_id: ::std::result::Result<super::InputFileId, ::std::string::String>,
id: ::std::result::Result<super::InputId, ::std::string::String>,
}
impl ::std::default::Default for Input {
fn default() -> Self {
Self {
file_id: Err("no value supplied for file_id".to_string()),
id: Err("no value supplied for id".to_string()),
}
}
}
impl Input {
pub fn file_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::InputFileId>,
T::Error: ::std::fmt::Display,
{
self.file_id = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for file_id: {e}")
});
self
}
pub fn id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::InputId>,
T::Error: ::std::fmt::Display,
{
self.id = value
.try_into()
.map_err(|e| format!("error converting supplied value for id: {e}"));
self
}
}
impl ::std::convert::TryFrom<Input> for super::Input {
type Error = super::error::ConversionError;
fn try_from(
value: Input,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
file_id: value.file_id?,
id: value.id?,
})
}
}
impl ::std::convert::From<super::Input> for Input {
fn from(value: super::Input) -> Self {
Self {
file_id: Ok(value.file_id),
id: Ok(value.id),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
pub mod output {
///Error details.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Error {
///Error code.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub code: ::std::option::Option<::std::string::String>,
///Human-readable error message.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub message: ::std::option::Option<::std::string::String>,
///Error type category.
#[serde(rename = "type", skip_serializing_if = "::std::option::Option::is_none")]
pub type_: ::std::option::Option<::std::string::String>,
}
impl Error {
pub fn builder() -> builder::Error {
Default::default()
}
}
///Successful response returns raw file bytes as binary content rather than JSON. Error responses return a JSON error object.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Output {
///Successful response body is raw file bytes; error response body is a JSON object.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub body: ::std::option::Option<OutputBody>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub headers: ::std::option::Option<ResponseHeaders>,
///HTTP status code for the response.
#[serde(
rename = "statusCode",
skip_serializing_if = "::std::option::Option::is_none"
)]
pub status_code: ::std::option::Option<i64>,
}
impl Output {
pub fn builder() -> builder::Output {
Default::default()
}
}
///Successful response body is raw file bytes; error response body is a JSON object.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(untagged)]
pub enum OutputBody {
BinaryFileContent(::std::string::String),
ErrorResponseBody {
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
error: ::std::option::Option<Error>,
},
}
///Response headers. On success, includes a file-specific `Content-Type` and `Content-Disposition: attachment` with the original filename.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct ResponseHeaders {
///Contains attachment information and the original filename for successful downloads.
#[serde(
rename = "Content-Disposition",
skip_serializing_if = "::std::option::Option::is_none"
)]
pub content_disposition: ::std::option::Option<::std::string::String>,
///On success, matches the downloaded file's media type. On errors, typically a JSON media type.
#[serde(
rename = "Content-Type",
skip_serializing_if = "::std::option::Option::is_none"
)]
pub content_type: ::std::option::Option<::std::string::String>,
}
impl ResponseHeaders {
pub fn builder() -> builder::ResponseHeaders {
Default::default()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Error {
code: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
message: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
type_: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for Error {
fn default() -> Self {
Self {
code: Ok(Default::default()),
message: Ok(Default::default()),
type_: Ok(Default::default()),
}
}
}
impl Error {
pub fn code<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.code = value
.try_into()
.map_err(|e| format!("error converting supplied value for code: {e}"));
self
}
pub fn message<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.message = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for message: {e}")
});
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
}
impl ::std::convert::TryFrom<Error> for super::Error {
type Error = super::error::ConversionError;
fn try_from(
value: Error,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
code: value.code?,
message: value.message?,
type_: value.type_?,
})
}
}
impl ::std::convert::From<super::Error> for Error {
fn from(value: super::Error) -> Self {
Self {
code: Ok(value.code),
message: Ok(value.message),
type_: Ok(value.type_),
}
}
}
#[derive(Clone, Debug)]
pub struct Output {
body: ::std::result::Result<
::std::option::Option<super::OutputBody>,
::std::string::String,
>,
headers: ::std::result::Result<
::std::option::Option<super::ResponseHeaders>,
::std::string::String,
>,
status_code: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
}
impl ::std::default::Default for Output {
fn default() -> Self {
Self {
body: Ok(Default::default()),
headers: Ok(Default::default()),
status_code: Ok(Default::default()),
}
}
}
impl Output {
pub fn body<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::OutputBody>>,
T::Error: ::std::fmt::Display,
{
self.body = value
.try_into()
.map_err(|e| format!("error converting supplied value for body: {e}"));
self
}
pub fn headers<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ResponseHeaders>>,
T::Error: ::std::fmt::Display,
{
self.headers = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for headers: {e}")
});
self
}
pub fn status_code<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.status_code = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for status_code: {e}")
});
self
}
}
impl ::std::convert::TryFrom<Output> for super::Output {
type Error = super::error::ConversionError;
fn try_from(
value: Output,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
body: value.body?,
headers: value.headers?,
status_code: value.status_code?,
})
}
}
impl ::std::convert::From<super::Output> for Output {
fn from(value: super::Output) -> Self {
Self {
body: Ok(value.body),
headers: Ok(value.headers),
status_code: Ok(value.status_code),
}
}
}
#[derive(Clone, Debug)]
pub struct ResponseHeaders {
content_disposition: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
content_type: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for ResponseHeaders {
fn default() -> Self {
Self {
content_disposition: Ok(Default::default()),
content_type: Ok(Default::default()),
}
}
}
impl ResponseHeaders {
pub fn content_disposition<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.content_disposition = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for content_disposition: {e}"
)
});
self
}
pub fn content_type<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.content_type = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for content_type: {e}")
});
self
}
}
impl ::std::convert::TryFrom<ResponseHeaders> for super::ResponseHeaders {
type Error = super::error::ConversionError;
fn try_from(
value: ResponseHeaders,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
content_disposition: value.content_disposition?,
content_type: value.content_type?,
})
}
}
impl ::std::convert::From<super::ResponseHeaders> for ResponseHeaders {
fn from(value: super::ResponseHeaders) -> Self {
Self {
content_disposition: Ok(value.content_disposition),
content_type: Ok(value.content_type),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
}
/// Where each field of `Input` goes in the request.
pub const ROUTING: ::one::Routing = ::one::Routing { routes: &[::one::Route { field: "fileId", part: ::one::Part::Path, key: Some("fileId") }, ::one::Route { field: "id", part: ::one::Part::Path, key: Some("id") }], required_parts: &[::one::Part::Path] };
/// Builds the `download_agent_response_file` action.
///
/// # Example input
/// ```json
/// {
/// "fileId": "file_01HFILEDEF",
/// "id": "resp_01HXYZABC"
/// }
/// ```
pub fn build(input: Input) -> ::std::result::Result<Operation<output::Output>, Error> {
::std::result::Result::Ok(Operation::action("conn_mod_def::GOQ4C_1ULUA::GpV9-iA0SJmqaAjef6JzmQ", Method::GET, "/v1/agent/{{id}}/files/{{fileId}}/content").with_routed(&input, &ROUTING)?
.merge_headers(::serde_json::from_str("{\"Accept\":\"application/octet-stream\"}").map_err(Error::Decode)?).returns::<output::Output>())
}
impl IntoOperation for Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
build(self)
}
}
impl IntoOperation for builder::Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
Input::try_from(self).map_err(|error| Error::InvalidInput(::std::boxed::Box::new(error))).and_then(build)
}
}
}
/// Starts building the `download_agent_response_file` action's input; pass the builder to `run`.
pub fn download_agent_response_file() -> download_agent_response_file::builder::Input {
download_agent_response_file::builder::Input::default()
}
pub mod list_files_produced_agent_response {
use ::one::{Error, IntoOperation, Method, Operation};
///Lists files that an agent response produced in its sandbox and delivered through the `share_file` tool. The endpoint returns file metadata only; file content is not included inline and must be retrieved using the file content endpoint.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct Input {
///Agent response ID in the format `resp_<...>`. Send this value in the URL path.
pub id: InputId,
}
impl Input {
pub fn builder() -> builder::Input {
Default::default()
}
}
///Agent response ID in the format `resp_<...>`. Send this value in the URL path.
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct InputId(::std::string::String);
impl ::std::ops::Deref for InputId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<InputId> for ::std::string::String {
fn from(value: InputId) -> Self {
value.0
}
}
impl ::std::str::FromStr for InputId {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
::std::convert::TryFrom::try_from(value)
}
}
impl ::std::convert::TryFrom<&str> for InputId {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
static PATTERN: ::std::sync::LazyLock<::regress::Regex> = ::std::sync::LazyLock::new(||
{ ::regress::Regex::with_flags("^resp_.+", "u").unwrap() });
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^resp_.+\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<::std::string::String> for InputId {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
::std::convert::TryFrom::try_from(value.as_str())
}
}
impl<'de> ::serde::Deserialize<'de> for InputId {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::convert::TryFrom::try_from(
::std::string::String::deserialize(deserializer)?,
)
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Input {
id: ::std::result::Result<super::InputId, ::std::string::String>,
}
impl ::std::default::Default for Input {
fn default() -> Self {
Self {
id: Err("no value supplied for id".to_string()),
}
}
}
impl Input {
pub fn id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::InputId>,
T::Error: ::std::fmt::Display,
{
self.id = value
.try_into()
.map_err(|e| format!("error converting supplied value for id: {e}"));
self
}
}
impl ::std::convert::TryFrom<Input> for super::Input {
type Error = super::error::ConversionError;
fn try_from(
value: Input,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self { id: value.id? })
}
}
impl ::std::convert::From<super::Input> for Input {
fn from(value: super::Input) -> Self {
Self { id: Ok(value.id) }
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
pub mod output {
///Error details returned for an unsuccessful request.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Error {
///Error code, when provided.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub code: ::std::option::Option<::std::string::String>,
///Human-readable error message.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub message: ::std::option::Option<::std::string::String>,
///Error type category, when provided.
#[serde(rename = "type", skip_serializing_if = "::std::option::Option::is_none")]
pub type_: ::std::option::Option<::std::string::String>,
}
impl Error {
pub fn builder() -> builder::Error {
Default::default()
}
}
///Metadata describing a file produced by the agent response.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct FileMetadata {
///File size in bytes.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub bytes: ::std::option::Option<i64>,
///Unix timestamp indicating when the file was created.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub created_at: ::std::option::Option<i64>,
///Filename assigned by the sandbox.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub filename: ::std::option::Option<::std::string::String>,
///File identifier used to download the file content. This is distinct from the agent response ID.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub id: ::std::option::Option<::std::string::String>,
///Always `file`.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub object: ::std::option::Option<FileMetadataObject>,
}
impl FileMetadata {
pub fn builder() -> builder::FileMetadata {
Default::default()
}
}
///Always `file`.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum FileMetadataObject {
#[serde(rename = "file")]
File,
}
impl ::std::fmt::Display for FileMetadataObject {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::File => f.write_str("file"),
}
}
}
impl ::std::str::FromStr for FileMetadataObject {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"file" => Ok(Self::File),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for FileMetadataObject {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for FileMetadataObject {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Response containing file metadata for files delivered from an agent response sandbox, or an error object for unsuccessful requests.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Output {
///List of files delivered from the agent response sandbox.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub data: ::std::vec::Vec<FileMetadata>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub error: ::std::option::Option<Error>,
///Always `list`.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub object: ::std::option::Option<OutputObject>,
}
impl Output {
pub fn builder() -> builder::Output {
Default::default()
}
}
///Always `list`.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum OutputObject {
#[serde(rename = "list")]
List,
}
impl ::std::fmt::Display for OutputObject {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::List => f.write_str("list"),
}
}
}
impl ::std::str::FromStr for OutputObject {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"list" => Ok(Self::List),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for OutputObject {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for OutputObject {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Error {
code: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
message: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
type_: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for Error {
fn default() -> Self {
Self {
code: Ok(Default::default()),
message: Ok(Default::default()),
type_: Ok(Default::default()),
}
}
}
impl Error {
pub fn code<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.code = value
.try_into()
.map_err(|e| format!("error converting supplied value for code: {e}"));
self
}
pub fn message<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.message = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for message: {e}")
});
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
}
impl ::std::convert::TryFrom<Error> for super::Error {
type Error = super::error::ConversionError;
fn try_from(
value: Error,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
code: value.code?,
message: value.message?,
type_: value.type_?,
})
}
}
impl ::std::convert::From<super::Error> for Error {
fn from(value: super::Error) -> Self {
Self {
code: Ok(value.code),
message: Ok(value.message),
type_: Ok(value.type_),
}
}
}
#[derive(Clone, Debug)]
pub struct FileMetadata {
bytes: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
created_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
filename: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
object: ::std::result::Result<
::std::option::Option<super::FileMetadataObject>,
::std::string::String,
>,
}
impl ::std::default::Default for FileMetadata {
fn default() -> Self {
Self {
bytes: Ok(Default::default()),
created_at: Ok(Default::default()),
filename: Ok(Default::default()),
id: Ok(Default::default()),
object: Ok(Default::default()),
}
}
}
impl FileMetadata {
pub fn bytes<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.bytes = value
.try_into()
.map_err(|e| format!("error converting supplied value for bytes: {e}"));
self
}
pub fn created_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.created_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for created_at: {e}")
});
self
}
pub fn filename<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.filename = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for filename: {e}")
});
self
}
pub fn id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.id = value
.try_into()
.map_err(|e| format!("error converting supplied value for id: {e}"));
self
}
pub fn object<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::FileMetadataObject>>,
T::Error: ::std::fmt::Display,
{
self.object = value
.try_into()
.map_err(|e| format!("error converting supplied value for object: {e}"));
self
}
}
impl ::std::convert::TryFrom<FileMetadata> for super::FileMetadata {
type Error = super::error::ConversionError;
fn try_from(
value: FileMetadata,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
bytes: value.bytes?,
created_at: value.created_at?,
filename: value.filename?,
id: value.id?,
object: value.object?,
})
}
}
impl ::std::convert::From<super::FileMetadata> for FileMetadata {
fn from(value: super::FileMetadata) -> Self {
Self {
bytes: Ok(value.bytes),
created_at: Ok(value.created_at),
filename: Ok(value.filename),
id: Ok(value.id),
object: Ok(value.object),
}
}
}
#[derive(Clone, Debug)]
pub struct Output {
data: ::std::result::Result<
::std::vec::Vec<super::FileMetadata>,
::std::string::String,
>,
error: ::std::result::Result<
::std::option::Option<super::Error>,
::std::string::String,
>,
object: ::std::result::Result<
::std::option::Option<super::OutputObject>,
::std::string::String,
>,
}
impl ::std::default::Default for Output {
fn default() -> Self {
Self {
data: Ok(Default::default()),
error: Ok(Default::default()),
object: Ok(Default::default()),
}
}
}
impl Output {
pub fn data<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::FileMetadata>>,
T::Error: ::std::fmt::Display,
{
self.data = value
.try_into()
.map_err(|e| format!("error converting supplied value for data: {e}"));
self
}
pub fn error<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Error>>,
T::Error: ::std::fmt::Display,
{
self.error = value
.try_into()
.map_err(|e| format!("error converting supplied value for error: {e}"));
self
}
pub fn object<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::OutputObject>>,
T::Error: ::std::fmt::Display,
{
self.object = value
.try_into()
.map_err(|e| format!("error converting supplied value for object: {e}"));
self
}
}
impl ::std::convert::TryFrom<Output> for super::Output {
type Error = super::error::ConversionError;
fn try_from(
value: Output,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
data: value.data?,
error: value.error?,
object: value.object?,
})
}
}
impl ::std::convert::From<super::Output> for Output {
fn from(value: super::Output) -> Self {
Self {
data: Ok(value.data),
error: Ok(value.error),
object: Ok(value.object),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
}
/// Where each field of `Input` goes in the request.
pub const ROUTING: ::one::Routing = ::one::Routing { routes: &[::one::Route { field: "id", part: ::one::Part::Path, key: Some("id") }], required_parts: &[::one::Part::Path] };
/// Builds the `list_files_produced_agent_response` action.
///
/// # Example input
/// ```json
/// {
/// "id": "resp_01HQX2Y3Z4A5B6C7D8E9"
/// }
/// ```
pub fn build(input: Input) -> ::std::result::Result<Operation<output::Output>, Error> {
::std::result::Result::Ok(Operation::action("conn_mod_def::GOQ4DAEIZ1g::LnDZak9-QIiiuJCLWddVwg", Method::GET, "/v1/agent/{{id}}/files").with_routed(&input, &ROUTING)?
.merge_headers(::serde_json::from_str("{\"Accept\":\"application/json\"}").map_err(Error::Decode)?).returns::<output::Output>())
}
impl IntoOperation for Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
build(self)
}
}
impl IntoOperation for builder::Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
Input::try_from(self).map_err(|error| Error::InvalidInput(::std::boxed::Box::new(error))).and_then(build)
}
}
}
/// Starts building the `list_files_produced_agent_response` action's input; pass the builder to `run`.
pub fn list_files_produced_agent_response() -> list_files_produced_agent_response::builder::Input {
list_files_produced_agent_response::builder::Input::default()
}
pub mod retrieve_agent_response {
use ::one::{Error, IntoOperation, Method, Operation};
///Retrieves a JSON snapshot of an agent response created earlier. Only responses created with `store` omitted or set to `true` can be retrieved; responses created with `store: false` return `404 Not Found`.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct Input {
///Response ID to retrieve. Must use the `resp_<...>` format.
pub id: InputId,
}
impl Input {
pub fn builder() -> builder::Input {
Default::default()
}
}
///Response ID to retrieve. Must use the `resp_<...>` format.
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct InputId(::std::string::String);
impl ::std::ops::Deref for InputId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<InputId> for ::std::string::String {
fn from(value: InputId) -> Self {
value.0
}
}
impl ::std::str::FromStr for InputId {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
::std::convert::TryFrom::try_from(value)
}
}
impl ::std::convert::TryFrom<&str> for InputId {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
static PATTERN: ::std::sync::LazyLock<::regress::Regex> = ::std::sync::LazyLock::new(||
{ ::regress::Regex::with_flags("^resp_.+$", "u").unwrap() });
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^resp_.+$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<::std::string::String> for InputId {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
::std::convert::TryFrom::try_from(value.as_str())
}
}
impl<'de> ::serde::Deserialize<'de> for InputId {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::convert::TryFrom::try_from(
::std::string::String::deserialize(deserializer)?,
)
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Input {
id: ::std::result::Result<super::InputId, ::std::string::String>,
}
impl ::std::default::Default for Input {
fn default() -> Self {
Self {
id: Err("no value supplied for id".to_string()),
}
}
}
impl Input {
pub fn id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::InputId>,
T::Error: ::std::fmt::Display,
{
self.id = value
.try_into()
.map_err(|e| format!("error converting supplied value for id: {e}"));
self
}
}
impl ::std::convert::TryFrom<Input> for super::Input {
type Error = super::error::ConversionError;
fn try_from(
value: Input,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self { id: value.id? })
}
}
impl ::std::convert::From<super::Input> for Input {
fn from(value: super::Input) -> Self {
Self { id: Ok(value.id) }
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
pub mod output {
///Error information associated with the response, when present.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
pub struct Error {
///Error code.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub code: ::std::option::Option<::std::string::String>,
///Required when `error` is present. Human-readable error message.
pub message: ::std::string::String,
///Error type category.
#[serde(rename = "type", skip_serializing_if = "::std::option::Option::is_none")]
pub type_: ::std::option::Option<::std::string::String>,
}
impl Error {
pub fn builder() -> builder::Error {
Default::default()
}
}
///Response returned when retrieving a stored agent response snapshot, or an error when the response cannot be found or accessed.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Output {
///Required. Unix timestamp when the response was created.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub created_at: ::std::option::Option<i64>,
///Effort and version that ran the response, formatted as `name@<version>`, for example `fast@2026-09-29.0`. Present only when the request used an effort level. Streams resumed with `starting_after` omit this field. For an alias, this is the effort and version selected by the alias. Supplying a versioned value as the request `effort` runs that configuration again; released versions may receive bug-fix patches. A value without a version is a bare effort name, indicating the run was created before effort versions or was served without versions.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub effort: ::std::option::Option<::std::string::String>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub error: ::std::option::Option<Error>,
///Required. Unique identifier for the response.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub id: ::std::option::Option<::std::string::String>,
///Required. Model used for generation.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub model: ::std::option::Option<::std::string::String>,
///Required. Response object type. Always `response`.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub object: ::std::option::Option<OutputObject>,
///Required. Array of output items, including messages, search results, tool calls, and tool-related results.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub output: ::std::vec::Vec<OutputItem>,
///Required. Response status: `completed`, `failed`, `incomplete`, `in_progress`, `queued`, or `cancelled`.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub status: ::std::option::Option<OutputStatus>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub usage: ::std::option::Option<Usage>,
}
impl Output {
pub fn builder() -> builder::Output {
Default::default()
}
}
///An output item. Supported item variants are `MessageOutputItem`, `SearchResultsOutputItem`, `ImageSearchResultsOutputItem`, `FetchUrlResultsOutputItem`, `FinanceResultsOutputItem`, `PeopleSearchResultsOutputItem`, `FunctionCallOutputItem`, `SandboxResultsOutputItem`, `McpListToolsOutputItem`, `McpCallOutputItem`, `McpApprovalRequestOutputItem`, and `ToolSearchOutputItem`.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct OutputItem {
///Output item type.
#[serde(rename = "type", skip_serializing_if = "::std::option::Option::is_none")]
pub type_: ::std::option::Option<::std::string::String>,
}
impl OutputItem {
pub fn builder() -> builder::OutputItem {
Default::default()
}
}
///Required. Response object type. Always `response`.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum OutputObject {
#[serde(rename = "response")]
Response,
}
impl ::std::fmt::Display for OutputObject {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Response => f.write_str("response"),
}
}
}
impl ::std::str::FromStr for OutputObject {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"response" => Ok(Self::Response),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for OutputObject {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for OutputObject {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Required. Response status: `completed`, `failed`, `incomplete`, `in_progress`, `queued`, or `cancelled`.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum OutputStatus {
#[serde(rename = "completed")]
Completed,
#[serde(rename = "failed")]
Failed,
#[serde(rename = "incomplete")]
Incomplete,
#[serde(rename = "in_progress")]
InProgress,
#[serde(rename = "queued")]
Queued,
#[serde(rename = "cancelled")]
Cancelled,
}
impl ::std::fmt::Display for OutputStatus {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Completed => f.write_str("completed"),
Self::Failed => f.write_str("failed"),
Self::Incomplete => f.write_str("incomplete"),
Self::InProgress => f.write_str("in_progress"),
Self::Queued => f.write_str("queued"),
Self::Cancelled => f.write_str("cancelled"),
}
}
}
impl ::std::str::FromStr for OutputStatus {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"completed" => Ok(Self::Completed),
"failed" => Ok(Self::Failed),
"incomplete" => Ok(Self::Incomplete),
"in_progress" => Ok(Self::InProgress),
"queued" => Ok(Self::Queued),
"cancelled" => Ok(Self::Cancelled),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for OutputStatus {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for OutputStatus {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Token-usage and cost information, when present.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
pub struct Usage {
///Response cost information.
#[serde(default, skip_serializing_if = "::serde_json::Map::is_empty")]
pub cost: ::serde_json::Map<::std::string::String, ::serde_json::Value>,
///Required when `usage` is present. Number of input tokens used.
pub input_tokens: i64,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub input_tokens_details: ::std::option::Option<UsageInputTokensDetails>,
///Required when `usage` is present. Number of output tokens generated.
pub output_tokens: i64,
///Tool-call details keyed by tool-call identifier.
#[serde(default, skip_serializing_if = "::serde_json::Map::is_empty")]
pub tool_calls_details: ::serde_json::Map<
::std::string::String,
::serde_json::Value,
>,
///Required when `usage` is present. Total tokens used: input tokens plus output tokens.
pub total_tokens: i64,
}
impl Usage {
pub fn builder() -> builder::Usage {
Default::default()
}
}
///Input-token cache details.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct UsageInputTokensDetails {
///Tokens used for cache creation.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub cache_creation_input_tokens: ::std::option::Option<i64>,
///Tokens read from cache.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub cache_read_input_tokens: ::std::option::Option<i64>,
}
impl UsageInputTokensDetails {
pub fn builder() -> builder::UsageInputTokensDetails {
Default::default()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Error {
code: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
message: ::std::result::Result<::std::string::String, ::std::string::String>,
type_: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for Error {
fn default() -> Self {
Self {
code: Ok(Default::default()),
message: Err("no value supplied for message".to_string()),
type_: Ok(Default::default()),
}
}
}
impl Error {
pub fn code<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.code = value
.try_into()
.map_err(|e| format!("error converting supplied value for code: {e}"));
self
}
pub fn message<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::string::String>,
T::Error: ::std::fmt::Display,
{
self.message = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for message: {e}")
});
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
}
impl ::std::convert::TryFrom<Error> for super::Error {
type Error = super::error::ConversionError;
fn try_from(
value: Error,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
code: value.code?,
message: value.message?,
type_: value.type_?,
})
}
}
impl ::std::convert::From<super::Error> for Error {
fn from(value: super::Error) -> Self {
Self {
code: Ok(value.code),
message: Ok(value.message),
type_: Ok(value.type_),
}
}
}
#[derive(Clone, Debug)]
pub struct Output {
created_at: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
effort: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
error: ::std::result::Result<
::std::option::Option<super::Error>,
::std::string::String,
>,
id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
model: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
object: ::std::result::Result<
::std::option::Option<super::OutputObject>,
::std::string::String,
>,
output: ::std::result::Result<
::std::vec::Vec<super::OutputItem>,
::std::string::String,
>,
status: ::std::result::Result<
::std::option::Option<super::OutputStatus>,
::std::string::String,
>,
usage: ::std::result::Result<
::std::option::Option<super::Usage>,
::std::string::String,
>,
}
impl ::std::default::Default for Output {
fn default() -> Self {
Self {
created_at: Ok(Default::default()),
effort: Ok(Default::default()),
error: Ok(Default::default()),
id: Ok(Default::default()),
model: Ok(Default::default()),
object: Ok(Default::default()),
output: Ok(Default::default()),
status: Ok(Default::default()),
usage: Ok(Default::default()),
}
}
}
impl Output {
pub fn created_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.created_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for created_at: {e}")
});
self
}
pub fn effort<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.effort = value
.try_into()
.map_err(|e| format!("error converting supplied value for effort: {e}"));
self
}
pub fn error<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Error>>,
T::Error: ::std::fmt::Display,
{
self.error = value
.try_into()
.map_err(|e| format!("error converting supplied value for error: {e}"));
self
}
pub fn id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.id = value
.try_into()
.map_err(|e| format!("error converting supplied value for id: {e}"));
self
}
pub fn model<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.model = value
.try_into()
.map_err(|e| format!("error converting supplied value for model: {e}"));
self
}
pub fn object<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::OutputObject>>,
T::Error: ::std::fmt::Display,
{
self.object = value
.try_into()
.map_err(|e| format!("error converting supplied value for object: {e}"));
self
}
pub fn output<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::OutputItem>>,
T::Error: ::std::fmt::Display,
{
self.output = value
.try_into()
.map_err(|e| format!("error converting supplied value for output: {e}"));
self
}
pub fn status<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::OutputStatus>>,
T::Error: ::std::fmt::Display,
{
self.status = value
.try_into()
.map_err(|e| format!("error converting supplied value for status: {e}"));
self
}
pub fn usage<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Usage>>,
T::Error: ::std::fmt::Display,
{
self.usage = value
.try_into()
.map_err(|e| format!("error converting supplied value for usage: {e}"));
self
}
}
impl ::std::convert::TryFrom<Output> for super::Output {
type Error = super::error::ConversionError;
fn try_from(
value: Output,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
created_at: value.created_at?,
effort: value.effort?,
error: value.error?,
id: value.id?,
model: value.model?,
object: value.object?,
output: value.output?,
status: value.status?,
usage: value.usage?,
})
}
}
impl ::std::convert::From<super::Output> for Output {
fn from(value: super::Output) -> Self {
Self {
created_at: Ok(value.created_at),
effort: Ok(value.effort),
error: Ok(value.error),
id: Ok(value.id),
model: Ok(value.model),
object: Ok(value.object),
output: Ok(value.output),
status: Ok(value.status),
usage: Ok(value.usage),
}
}
}
#[derive(Clone, Debug)]
pub struct OutputItem {
type_: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for OutputItem {
fn default() -> Self {
Self {
type_: Ok(Default::default()),
}
}
}
impl OutputItem {
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
}
impl ::std::convert::TryFrom<OutputItem> for super::OutputItem {
type Error = super::error::ConversionError;
fn try_from(
value: OutputItem,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self { type_: value.type_? })
}
}
impl ::std::convert::From<super::OutputItem> for OutputItem {
fn from(value: super::OutputItem) -> Self {
Self { type_: Ok(value.type_) }
}
}
#[derive(Clone, Debug)]
pub struct Usage {
cost: ::std::result::Result<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
::std::string::String,
>,
input_tokens: ::std::result::Result<i64, ::std::string::String>,
input_tokens_details: ::std::result::Result<
::std::option::Option<super::UsageInputTokensDetails>,
::std::string::String,
>,
output_tokens: ::std::result::Result<i64, ::std::string::String>,
tool_calls_details: ::std::result::Result<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
::std::string::String,
>,
total_tokens: ::std::result::Result<i64, ::std::string::String>,
}
impl ::std::default::Default for Usage {
fn default() -> Self {
Self {
cost: Ok(Default::default()),
input_tokens: Err("no value supplied for input_tokens".to_string()),
input_tokens_details: Ok(Default::default()),
output_tokens: Err("no value supplied for output_tokens".to_string()),
tool_calls_details: Ok(Default::default()),
total_tokens: Err("no value supplied for total_tokens".to_string()),
}
}
}
impl Usage {
pub fn cost<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
T::Error: ::std::fmt::Display,
{
self.cost = value
.try_into()
.map_err(|e| format!("error converting supplied value for cost: {e}"));
self
}
pub fn input_tokens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<i64>,
T::Error: ::std::fmt::Display,
{
self.input_tokens = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for input_tokens: {e}")
});
self
}
pub fn input_tokens_details<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<super::UsageInputTokensDetails>,
>,
T::Error: ::std::fmt::Display,
{
self.input_tokens_details = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for input_tokens_details: {e}"
)
});
self
}
pub fn output_tokens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<i64>,
T::Error: ::std::fmt::Display,
{
self.output_tokens = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for output_tokens: {e}")
});
self
}
pub fn tool_calls_details<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
T::Error: ::std::fmt::Display,
{
self.tool_calls_details = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for tool_calls_details: {e}"
)
});
self
}
pub fn total_tokens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<i64>,
T::Error: ::std::fmt::Display,
{
self.total_tokens = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for total_tokens: {e}")
});
self
}
}
impl ::std::convert::TryFrom<Usage> for super::Usage {
type Error = super::error::ConversionError;
fn try_from(
value: Usage,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
cost: value.cost?,
input_tokens: value.input_tokens?,
input_tokens_details: value.input_tokens_details?,
output_tokens: value.output_tokens?,
tool_calls_details: value.tool_calls_details?,
total_tokens: value.total_tokens?,
})
}
}
impl ::std::convert::From<super::Usage> for Usage {
fn from(value: super::Usage) -> Self {
Self {
cost: Ok(value.cost),
input_tokens: Ok(value.input_tokens),
input_tokens_details: Ok(value.input_tokens_details),
output_tokens: Ok(value.output_tokens),
tool_calls_details: Ok(value.tool_calls_details),
total_tokens: Ok(value.total_tokens),
}
}
}
#[derive(Clone, Debug)]
pub struct UsageInputTokensDetails {
cache_creation_input_tokens: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
cache_read_input_tokens: ::std::result::Result<
::std::option::Option<i64>,
::std::string::String,
>,
}
impl ::std::default::Default for UsageInputTokensDetails {
fn default() -> Self {
Self {
cache_creation_input_tokens: Ok(Default::default()),
cache_read_input_tokens: Ok(Default::default()),
}
}
}
impl UsageInputTokensDetails {
pub fn cache_creation_input_tokens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.cache_creation_input_tokens = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for cache_creation_input_tokens: {e}"
)
});
self
}
pub fn cache_read_input_tokens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.cache_read_input_tokens = value
.try_into()
.map_err(|e| {
format!(
"error converting supplied value for cache_read_input_tokens: {e}"
)
});
self
}
}
impl ::std::convert::TryFrom<UsageInputTokensDetails>
for super::UsageInputTokensDetails {
type Error = super::error::ConversionError;
fn try_from(
value: UsageInputTokensDetails,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
cache_creation_input_tokens: value.cache_creation_input_tokens?,
cache_read_input_tokens: value.cache_read_input_tokens?,
})
}
}
impl ::std::convert::From<super::UsageInputTokensDetails>
for UsageInputTokensDetails {
fn from(value: super::UsageInputTokensDetails) -> Self {
Self {
cache_creation_input_tokens: Ok(value.cache_creation_input_tokens),
cache_read_input_tokens: Ok(value.cache_read_input_tokens),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
}
/// Where each field of `Input` goes in the request.
pub const ROUTING: ::one::Routing = ::one::Routing { routes: &[::one::Route { field: "id", part: ::one::Part::Path, key: Some("id") }], required_parts: &[::one::Part::Path] };
/// Builds the `retrieve_agent_response` action.
///
/// # Example input
/// ```json
/// {
/// "id": "resp_01JQ8YR4C5P9M2K7V6D3X1A0BC"
/// }
/// ```
pub fn build(input: Input) -> ::std::result::Result<Operation<output::Output>, Error> {
::std::result::Result::Ok(Operation::action("conn_mod_def::GOQ4DAutPfA::zBfHj2pfT4mAb_sPwyGRIw", Method::GET, "/v1/agent/{{id}}").with_routed(&input, &ROUTING)?
.merge_headers(::serde_json::from_str("{\"Accept\":\"application/json\"}").map_err(Error::Decode)?).returns::<output::Output>())
}
impl IntoOperation for Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
build(self)
}
}
impl IntoOperation for builder::Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
Input::try_from(self).map_err(|error| Error::InvalidInput(::std::boxed::Box::new(error))).and_then(build)
}
}
}
/// Starts building the `retrieve_agent_response` action's input; pass the builder to `run`.
pub fn retrieve_agent_response() -> retrieve_agent_response::builder::Input {
retrieve_agent_response::builder::Input::default()
}
pub mod get_skill {
use ::one::{Error, IntoOperation, Method, Operation};
///Returns a skill and its revision metadata. When the optional `revision` query parameter is omitted, the endpoint returns the skill's active revision.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct Input {
///Opaque revision token to retrieve. When omitted, the active revision is returned. Send this value as a URL query parameter.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub revision: ::std::option::Option<::std::string::String>,
///Skill identifier returned by skill creation or by `GET /v1/skills`. Send this value in the URL path.
#[serde(rename = "skillId")]
pub skill_id: InputSkillId,
}
impl Input {
pub fn builder() -> builder::Input {
Default::default()
}
}
///Skill identifier returned by skill creation or by `GET /v1/skills`. Send this value in the URL path.
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct InputSkillId(::std::string::String);
impl ::std::ops::Deref for InputSkillId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<InputSkillId> for ::std::string::String {
fn from(value: InputSkillId) -> Self {
value.0
}
}
impl ::std::str::FromStr for InputSkillId {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
::std::convert::TryFrom::try_from(value)
}
}
impl ::std::convert::TryFrom<&str> for InputSkillId {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<::std::string::String> for InputSkillId {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
::std::convert::TryFrom::try_from(value.as_str())
}
}
impl<'de> ::serde::Deserialize<'de> for InputSkillId {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::convert::TryFrom::try_from(
::std::string::String::deserialize(deserializer)?,
)
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Input {
revision: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
skill_id: ::std::result::Result<super::InputSkillId, ::std::string::String>,
}
impl ::std::default::Default for Input {
fn default() -> Self {
Self {
revision: Ok(Default::default()),
skill_id: Err("no value supplied for skill_id".to_string()),
}
}
}
impl Input {
pub fn revision<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.revision = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for revision: {e}")
});
self
}
pub fn skill_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::InputSkillId>,
T::Error: ::std::fmt::Display,
{
self.skill_id = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for skill_id: {e}")
});
self
}
}
impl ::std::convert::TryFrom<Input> for super::Input {
type Error = super::error::ConversionError;
fn try_from(
value: Input,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
revision: value.revision?,
skill_id: value.skill_id?,
})
}
}
impl ::std::convert::From<super::Input> for Input {
fn from(value: super::Input) -> Self {
Self {
revision: Ok(value.revision),
skill_id: Ok(value.skill_id),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
pub mod output {
///Error object returned for unsuccessful requests.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Error {
///HTTP status code associated with the error.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub code: ::std::option::Option<i64>,
///Human-readable error message.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub message: ::std::option::Option<::std::string::String>,
///Parameter that caused the error, when applicable.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub param: ::std::option::Option<::std::string::String>,
///Error type identifier.
#[serde(rename = "type", skip_serializing_if = "::std::option::Option::is_none")]
pub type_: ::std::option::Option<::std::string::String>,
}
impl Error {
pub fn builder() -> builder::Error {
Default::default()
}
}
///Successful or error response structure for retrieving a skill and its revision metadata.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Output {
///Timestamp indicating when the skill was created.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub created_at: ::std::option::Option<::std::string::String>,
///Skill description read from the bundle's `SKILL.md` file.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub description: ::std::option::Option<::std::string::String>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub error: ::std::option::Option<Error>,
///Opaque token for the skill's current latest revision. Pass this value as `expected_revision` when updating or deleting the skill.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub latest_revision: ::std::option::Option<::std::string::String>,
///Skill name read from the bundle's `SKILL.md` file.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub name: ::std::option::Option<::std::string::String>,
///Opaque token for the revision returned in this response. This is the latest revision or the specific revision requested with `revision`.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub revision: ::std::option::Option<::std::string::String>,
///Skill identifier.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub skill_id: ::std::option::Option<::std::string::String>,
///Timestamp indicating when the skill was last updated.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub updated_at: ::std::option::Option<::std::string::String>,
}
impl Output {
pub fn builder() -> builder::Output {
Default::default()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Error {
code: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
message: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
param: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
type_: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for Error {
fn default() -> Self {
Self {
code: Ok(Default::default()),
message: Ok(Default::default()),
param: Ok(Default::default()),
type_: Ok(Default::default()),
}
}
}
impl Error {
pub fn code<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.code = value
.try_into()
.map_err(|e| format!("error converting supplied value for code: {e}"));
self
}
pub fn message<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.message = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for message: {e}")
});
self
}
pub fn param<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.param = value
.try_into()
.map_err(|e| format!("error converting supplied value for param: {e}"));
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
}
impl ::std::convert::TryFrom<Error> for super::Error {
type Error = super::error::ConversionError;
fn try_from(
value: Error,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
code: value.code?,
message: value.message?,
param: value.param?,
type_: value.type_?,
})
}
}
impl ::std::convert::From<super::Error> for Error {
fn from(value: super::Error) -> Self {
Self {
code: Ok(value.code),
message: Ok(value.message),
param: Ok(value.param),
type_: Ok(value.type_),
}
}
}
#[derive(Clone, Debug)]
pub struct Output {
created_at: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
description: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
error: ::std::result::Result<
::std::option::Option<super::Error>,
::std::string::String,
>,
latest_revision: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
name: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
revision: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
skill_id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
updated_at: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for Output {
fn default() -> Self {
Self {
created_at: Ok(Default::default()),
description: Ok(Default::default()),
error: Ok(Default::default()),
latest_revision: Ok(Default::default()),
name: Ok(Default::default()),
revision: Ok(Default::default()),
skill_id: Ok(Default::default()),
updated_at: Ok(Default::default()),
}
}
}
impl Output {
pub fn created_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.created_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for created_at: {e}")
});
self
}
pub fn description<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.description = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for description: {e}")
});
self
}
pub fn error<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Error>>,
T::Error: ::std::fmt::Display,
{
self.error = value
.try_into()
.map_err(|e| format!("error converting supplied value for error: {e}"));
self
}
pub fn latest_revision<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.latest_revision = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for latest_revision: {e}")
});
self
}
pub fn name<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.name = value
.try_into()
.map_err(|e| format!("error converting supplied value for name: {e}"));
self
}
pub fn revision<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.revision = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for revision: {e}")
});
self
}
pub fn skill_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.skill_id = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for skill_id: {e}")
});
self
}
pub fn updated_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.updated_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for updated_at: {e}")
});
self
}
}
impl ::std::convert::TryFrom<Output> for super::Output {
type Error = super::error::ConversionError;
fn try_from(
value: Output,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
created_at: value.created_at?,
description: value.description?,
error: value.error?,
latest_revision: value.latest_revision?,
name: value.name?,
revision: value.revision?,
skill_id: value.skill_id?,
updated_at: value.updated_at?,
})
}
}
impl ::std::convert::From<super::Output> for Output {
fn from(value: super::Output) -> Self {
Self {
created_at: Ok(value.created_at),
description: Ok(value.description),
error: Ok(value.error),
latest_revision: Ok(value.latest_revision),
name: Ok(value.name),
revision: Ok(value.revision),
skill_id: Ok(value.skill_id),
updated_at: Ok(value.updated_at),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
}
/// Where each field of `Input` goes in the request.
pub const ROUTING: ::one::Routing = ::one::Routing { routes: &[::one::Route { field: "skillId", part: ::one::Part::Path, key: Some("skillId") }, ::one::Route { field: "revision", part: ::one::Part::Query, key: Some("revision") }], required_parts: &[::one::Part::Path] };
/// Builds the `get_skill` action.
///
/// # Example input
/// ```json
/// {
/// "revision": "rev_01HRQ8P7F5K2A9M4N8C6D3E1B0",
/// "skillId": "skill_01HRQ8K5ZB7P3M2V6C9D4E1F0A"
/// }
/// ```
pub fn build(input: Input) -> ::std::result::Result<Operation<output::Output>, Error> {
::std::result::Result::Ok(Operation::action("conn_mod_def::GOQ4DIN3eKA::yhjbogK_SHWQZIhg-SoceQ", Method::GET, "/v1/skills/{{skillId}}").with_routed(&input, &ROUTING)?
.merge_headers(::serde_json::from_str("{\"Accept\":\"application/json\"}").map_err(Error::Decode)?).returns::<output::Output>())
}
impl IntoOperation for Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
build(self)
}
}
impl IntoOperation for builder::Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
Input::try_from(self).map_err(|error| Error::InvalidInput(::std::boxed::Box::new(error))).and_then(build)
}
}
}
/// Starts building the `get_skill` action's input; pass the builder to `run`.
pub fn get_skill() -> get_skill::builder::Input {
get_skill::builder::Input::default()
}
pub mod create_skill {
use ::one::{Error, IntoOperation, Method, Operation};
///Creates a skill from a ZIP bundle. The bundle must contain a `SKILL.md` file; the skill `name` and `description` are read from that file and are not supplied as request fields.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct Input {
///Raw ZIP bundle content sent as the request body. The bundle must include `SKILL.md`. The documentation does not specify individual request-body fields or a dedicated upload media type.
pub body: ::std::string::String,
}
impl Input {
pub fn builder() -> builder::Input {
Default::default()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Input {
body: ::std::result::Result<::std::string::String, ::std::string::String>,
}
impl ::std::default::Default for Input {
fn default() -> Self {
Self {
body: Err("no value supplied for body".to_string()),
}
}
}
impl Input {
pub fn body<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::string::String>,
T::Error: ::std::fmt::Display,
{
self.body = value
.try_into()
.map_err(|e| format!("error converting supplied value for body: {e}"));
self
}
}
impl ::std::convert::TryFrom<Input> for super::Input {
type Error = super::error::ConversionError;
fn try_from(
value: Input,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self { body: value.body? })
}
}
impl ::std::convert::From<super::Input> for Input {
fn from(value: super::Input) -> Self {
Self { body: Ok(value.body) }
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
pub mod output {
///Error details returned for unsuccessful requests.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
pub struct Error {
///HTTP status code.
pub code: i64,
///Human-readable error message.
pub message: ::std::string::String,
///Parameter that caused the error, when applicable.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub param: ::std::option::Option<::std::string::String>,
///Error type identifier.
#[serde(rename = "type")]
pub type_: ::std::string::String,
}
impl Error {
pub fn builder() -> builder::Error {
Default::default()
}
}
///Response returned after attempting to create a skill from a ZIP bundle.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Output {
///Timestamp indicating when the skill was created.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub created_at: ::std::option::Option<::std::string::String>,
///Skill description read from the bundle's `SKILL.md`.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub description: ::std::option::Option<::std::string::String>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub error: ::std::option::Option<Error>,
///Opaque token for the skill's current latest revision. Pass this value as `expected_revision` when updating or deleting the skill.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub latest_revision: ::std::option::Option<::std::string::String>,
///Skill name read from the bundle's `SKILL.md`.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub name: ::std::option::Option<::std::string::String>,
///Opaque token for the revision returned in this response. This is the latest revision unless a specific revision was requested via `revision`.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub revision: ::std::option::Option<::std::string::String>,
///Unique skill identifier.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub skill_id: ::std::option::Option<::std::string::String>,
///Timestamp indicating when the skill was last updated.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub updated_at: ::std::option::Option<::std::string::String>,
}
impl Output {
pub fn builder() -> builder::Output {
Default::default()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Error {
code: ::std::result::Result<i64, ::std::string::String>,
message: ::std::result::Result<::std::string::String, ::std::string::String>,
param: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
type_: ::std::result::Result<::std::string::String, ::std::string::String>,
}
impl ::std::default::Default for Error {
fn default() -> Self {
Self {
code: Err("no value supplied for code".to_string()),
message: Err("no value supplied for message".to_string()),
param: Ok(Default::default()),
type_: Err("no value supplied for type_".to_string()),
}
}
}
impl Error {
pub fn code<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<i64>,
T::Error: ::std::fmt::Display,
{
self.code = value
.try_into()
.map_err(|e| format!("error converting supplied value for code: {e}"));
self
}
pub fn message<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::string::String>,
T::Error: ::std::fmt::Display,
{
self.message = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for message: {e}")
});
self
}
pub fn param<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.param = value
.try_into()
.map_err(|e| format!("error converting supplied value for param: {e}"));
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::string::String>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
}
impl ::std::convert::TryFrom<Error> for super::Error {
type Error = super::error::ConversionError;
fn try_from(
value: Error,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
code: value.code?,
message: value.message?,
param: value.param?,
type_: value.type_?,
})
}
}
impl ::std::convert::From<super::Error> for Error {
fn from(value: super::Error) -> Self {
Self {
code: Ok(value.code),
message: Ok(value.message),
param: Ok(value.param),
type_: Ok(value.type_),
}
}
}
#[derive(Clone, Debug)]
pub struct Output {
created_at: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
description: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
error: ::std::result::Result<
::std::option::Option<super::Error>,
::std::string::String,
>,
latest_revision: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
name: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
revision: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
skill_id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
updated_at: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for Output {
fn default() -> Self {
Self {
created_at: Ok(Default::default()),
description: Ok(Default::default()),
error: Ok(Default::default()),
latest_revision: Ok(Default::default()),
name: Ok(Default::default()),
revision: Ok(Default::default()),
skill_id: Ok(Default::default()),
updated_at: Ok(Default::default()),
}
}
}
impl Output {
pub fn created_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.created_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for created_at: {e}")
});
self
}
pub fn description<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.description = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for description: {e}")
});
self
}
pub fn error<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Error>>,
T::Error: ::std::fmt::Display,
{
self.error = value
.try_into()
.map_err(|e| format!("error converting supplied value for error: {e}"));
self
}
pub fn latest_revision<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.latest_revision = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for latest_revision: {e}")
});
self
}
pub fn name<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.name = value
.try_into()
.map_err(|e| format!("error converting supplied value for name: {e}"));
self
}
pub fn revision<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.revision = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for revision: {e}")
});
self
}
pub fn skill_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.skill_id = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for skill_id: {e}")
});
self
}
pub fn updated_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.updated_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for updated_at: {e}")
});
self
}
}
impl ::std::convert::TryFrom<Output> for super::Output {
type Error = super::error::ConversionError;
fn try_from(
value: Output,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
created_at: value.created_at?,
description: value.description?,
error: value.error?,
latest_revision: value.latest_revision?,
name: value.name?,
revision: value.revision?,
skill_id: value.skill_id?,
updated_at: value.updated_at?,
})
}
}
impl ::std::convert::From<super::Output> for Output {
fn from(value: super::Output) -> Self {
Self {
created_at: Ok(value.created_at),
description: Ok(value.description),
error: Ok(value.error),
latest_revision: Ok(value.latest_revision),
name: Ok(value.name),
revision: Ok(value.revision),
skill_id: Ok(value.skill_id),
updated_at: Ok(value.updated_at),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
}
/// Where each field of `Input` goes in the request.
pub const ROUTING: ::one::Routing = ::one::Routing { routes: &[::one::Route { field: "body", part: ::one::Part::Body, key: None }], required_parts: &[] };
/// Builds the `create_skill` action.
///
/// # Example input
/// ```json
/// {
/// "body": "UEsDBBQAAAAIAAAAIQAAAAAAAAAAAAAAAAAJAAAAU0tJTEwubWTLzE1VSEksSVRIzCnISFSwUshLzE1VSM7PLShKLS5WKM8vyklRSEpNTC7JzM9TKEktLgYAUEsBAhQDFAAAAAgAAAAhAAAAAAAAAAAAAAAACQAAAAAAAAAAAAAAgAEAAAAAU0tJTEwubWRQSwUGAAAAAAEAAQA3AAAALAAAAAA="
/// }
/// ```
pub fn build(input: Input) -> ::std::result::Result<Operation<output::Output>, Error> {
::std::result::Result::Ok(Operation::action("conn_mod_def::GOQ4DIbW82g::sDPpYm1SRS--29tChlbS8Q", Method::POST, "/v1/skills").with_routed(&input, &ROUTING)?
.merge_headers(::serde_json::from_str("{\"Accept\":\"application/json\",\"Content-Type\":\"application/json\"}").map_err(Error::Decode)?).returns::<output::Output>())
}
impl IntoOperation for Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
build(self)
}
}
impl IntoOperation for builder::Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
Input::try_from(self).map_err(|error| Error::InvalidInput(::std::boxed::Box::new(error))).and_then(build)
}
}
}
/// Starts building the `create_skill` action's input; pass the builder to `run`.
pub fn create_skill() -> create_skill::builder::Input {
create_skill::builder::Input::default()
}
pub mod delete_skill {
use ::one::{Error, IntoOperation, Method, Operation};
///Deletes a skill identified by its skill ID. The request uses optimistic concurrency control: the supplied expected_revision must match the skill's current revision, preventing deletion from racing with a concurrent update.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct Input {
///Opaque revision token that the skill must currently have. The deletion is applied only when this token matches the current revision, preventing races with concurrent updates. Send this value as a URL query parameter.
pub expected_revision: InputExpectedRevision,
///Skill identifier returned by skill creation or GET /v1/skills. Send this value in the URL path.
#[serde(rename = "skillId")]
pub skill_id: InputSkillId,
}
impl Input {
pub fn builder() -> builder::Input {
Default::default()
}
}
///Opaque revision token that the skill must currently have. The deletion is applied only when this token matches the current revision, preventing races with concurrent updates. Send this value as a URL query parameter.
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct InputExpectedRevision(::std::string::String);
impl ::std::ops::Deref for InputExpectedRevision {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<InputExpectedRevision> for ::std::string::String {
fn from(value: InputExpectedRevision) -> Self {
value.0
}
}
impl ::std::str::FromStr for InputExpectedRevision {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
::std::convert::TryFrom::try_from(value)
}
}
impl ::std::convert::TryFrom<&str> for InputExpectedRevision {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<::std::string::String> for InputExpectedRevision {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
::std::convert::TryFrom::try_from(value.as_str())
}
}
impl<'de> ::serde::Deserialize<'de> for InputExpectedRevision {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::convert::TryFrom::try_from(
::std::string::String::deserialize(deserializer)?,
)
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///Skill identifier returned by skill creation or GET /v1/skills. Send this value in the URL path.
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct InputSkillId(::std::string::String);
impl ::std::ops::Deref for InputSkillId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<InputSkillId> for ::std::string::String {
fn from(value: InputSkillId) -> Self {
value.0
}
}
impl ::std::str::FromStr for InputSkillId {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
::std::convert::TryFrom::try_from(value)
}
}
impl ::std::convert::TryFrom<&str> for InputSkillId {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<::std::string::String> for InputSkillId {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
::std::convert::TryFrom::try_from(value.as_str())
}
}
impl<'de> ::serde::Deserialize<'de> for InputSkillId {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::convert::TryFrom::try_from(
::std::string::String::deserialize(deserializer)?,
)
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Input {
expected_revision: ::std::result::Result<
super::InputExpectedRevision,
::std::string::String,
>,
skill_id: ::std::result::Result<super::InputSkillId, ::std::string::String>,
}
impl ::std::default::Default for Input {
fn default() -> Self {
Self {
expected_revision: Err(
"no value supplied for expected_revision".to_string(),
),
skill_id: Err("no value supplied for skill_id".to_string()),
}
}
}
impl Input {
pub fn expected_revision<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::InputExpectedRevision>,
T::Error: ::std::fmt::Display,
{
self.expected_revision = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for expected_revision: {e}")
});
self
}
pub fn skill_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::InputSkillId>,
T::Error: ::std::fmt::Display,
{
self.skill_id = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for skill_id: {e}")
});
self
}
}
impl ::std::convert::TryFrom<Input> for super::Input {
type Error = super::error::ConversionError;
fn try_from(
value: Input,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
expected_revision: value.expected_revision?,
skill_id: value.skill_id?,
})
}
}
impl ::std::convert::From<super::Input> for Input {
fn from(value: super::Input) -> Self {
Self {
expected_revision: Ok(value.expected_revision),
skill_id: Ok(value.skill_id),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
pub mod output {
///Error details returned for unsuccessful requests.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Error {
///HTTP status code associated with the error.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub code: ::std::option::Option<ErrorCode>,
///Human-readable error message.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub message: ::std::option::Option<::std::string::String>,
///Parameter that caused the error, when applicable.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub param: ::std::option::Option<::std::string::String>,
///Error type identifier.
#[serde(rename = "type", skip_serializing_if = "::std::option::Option::is_none")]
pub type_: ::std::option::Option<ErrorType>,
}
impl Error {
pub fn builder() -> builder::Error {
Default::default()
}
}
///HTTP status code associated with the error.
#[derive(::serde::Serialize, Clone, Debug)]
#[serde(transparent)]
pub struct ErrorCode(i64);
impl ::std::ops::Deref for ErrorCode {
type Target = i64;
fn deref(&self) -> &i64 {
&self.0
}
}
impl ::std::convert::From<ErrorCode> for i64 {
fn from(value: ErrorCode) -> Self {
value.0
}
}
impl ::std::str::FromStr for ErrorCode {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value
.parse::<i64>()
.map_err(|e| ::std::string::ToString::to_string(&e).into())
.and_then(Self::try_from)
}
}
impl ::std::convert::TryFrom<i64> for ErrorCode {
type Error = self::error::ConversionError;
fn try_from(
value: i64,
) -> ::std::result::Result<Self, self::error::ConversionError> {
if ![400_i64, 404_i64, 409_i64, 429_i64, 502_i64].contains(&value) {
Err("invalid value".into())
} else {
Ok(Self(value))
}
}
}
impl<'de> ::serde::Deserialize<'de> for ErrorCode {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
Self::try_from(<i64>::deserialize(deserializer)?)
.map_err(|e| { <D::Error as ::serde::de::Error>::custom(e.to_string()) })
}
}
///Error type identifier.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum ErrorType {
#[serde(rename = "invalid_request_error")]
InvalidRequestError,
#[serde(rename = "not_found_error")]
NotFoundError,
#[serde(rename = "conflict_error")]
ConflictError,
#[serde(rename = "rate_limit_error")]
RateLimitError,
#[serde(rename = "service_unavailable_error")]
ServiceUnavailableError,
}
impl ::std::fmt::Display for ErrorType {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::InvalidRequestError => f.write_str("invalid_request_error"),
Self::NotFoundError => f.write_str("not_found_error"),
Self::ConflictError => f.write_str("conflict_error"),
Self::RateLimitError => f.write_str("rate_limit_error"),
Self::ServiceUnavailableError => f.write_str("service_unavailable_error"),
}
}
}
impl ::std::str::FromStr for ErrorType {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"invalid_request_error" => Ok(Self::InvalidRequestError),
"not_found_error" => Ok(Self::NotFoundError),
"conflict_error" => Ok(Self::ConflictError),
"rate_limit_error" => Ok(Self::RateLimitError),
"service_unavailable_error" => Ok(Self::ServiceUnavailableError),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for ErrorType {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ErrorType {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Response from deleting a skill. A successful deletion returns 204 No Content with no response body. Unsuccessful requests return an error object.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Output {
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub error: ::std::option::Option<Error>,
}
impl Output {
pub fn builder() -> builder::Output {
Default::default()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Error {
code: ::std::result::Result<
::std::option::Option<super::ErrorCode>,
::std::string::String,
>,
message: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
param: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
type_: ::std::result::Result<
::std::option::Option<super::ErrorType>,
::std::string::String,
>,
}
impl ::std::default::Default for Error {
fn default() -> Self {
Self {
code: Ok(Default::default()),
message: Ok(Default::default()),
param: Ok(Default::default()),
type_: Ok(Default::default()),
}
}
}
impl Error {
pub fn code<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ErrorCode>>,
T::Error: ::std::fmt::Display,
{
self.code = value
.try_into()
.map_err(|e| format!("error converting supplied value for code: {e}"));
self
}
pub fn message<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.message = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for message: {e}")
});
self
}
pub fn param<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.param = value
.try_into()
.map_err(|e| format!("error converting supplied value for param: {e}"));
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ErrorType>>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
}
impl ::std::convert::TryFrom<Error> for super::Error {
type Error = super::error::ConversionError;
fn try_from(
value: Error,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
code: value.code?,
message: value.message?,
param: value.param?,
type_: value.type_?,
})
}
}
impl ::std::convert::From<super::Error> for Error {
fn from(value: super::Error) -> Self {
Self {
code: Ok(value.code),
message: Ok(value.message),
param: Ok(value.param),
type_: Ok(value.type_),
}
}
}
#[derive(Clone, Debug)]
pub struct Output {
error: ::std::result::Result<
::std::option::Option<super::Error>,
::std::string::String,
>,
}
impl ::std::default::Default for Output {
fn default() -> Self {
Self {
error: Ok(Default::default()),
}
}
}
impl Output {
pub fn error<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Error>>,
T::Error: ::std::fmt::Display,
{
self.error = value
.try_into()
.map_err(|e| format!("error converting supplied value for error: {e}"));
self
}
}
impl ::std::convert::TryFrom<Output> for super::Output {
type Error = super::error::ConversionError;
fn try_from(
value: Output,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self { error: value.error? })
}
}
impl ::std::convert::From<super::Output> for Output {
fn from(value: super::Output) -> Self {
Self { error: Ok(value.error) }
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
}
/// Where each field of `Input` goes in the request.
pub const ROUTING: ::one::Routing = ::one::Routing { routes: &[::one::Route { field: "skillId", part: ::one::Part::Path, key: Some("skillId") }, ::one::Route { field: "expected_revision", part: ::one::Part::Query, key: Some("expected_revision") }], required_parts: &[::one::Part::Path, ::one::Part::Query] };
/// Builds the `delete_skill` action.
///
/// # Example input
/// ```json
/// {
/// "expected_revision": "rev_01HZY8J4K7",
/// "skillId": "skill_abc123"
/// }
/// ```
pub fn build(input: Input) -> ::std::result::Result<Operation<output::Output>, Error> {
::std::result::Result::Ok(Operation::action("conn_mod_def::GOQ4DIr6ahA::g_T7ajOaRJiWdwnyT-FW1w", Method::DELETE, "/v1/skills/{{skillId}}").with_routed(&input, &ROUTING)?
.merge_headers(::serde_json::from_str("{\"Accept\":\"application/json\"}").map_err(Error::Decode)?).returns::<output::Output>())
}
impl IntoOperation for Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
build(self)
}
}
impl IntoOperation for builder::Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
Input::try_from(self).map_err(|error| Error::InvalidInput(::std::boxed::Box::new(error))).and_then(build)
}
}
}
/// Starts building the `delete_skill` action's input; pass the builder to `run`.
pub fn delete_skill() -> delete_skill::builder::Input {
delete_skill::builder::Input::default()
}
pub mod add_skill_revision {
use ::one::{Error, IntoOperation, Method, Operation};
///Uploads a new ZIP bundle as a new revision of an existing skill. The update uses optimistic concurrency control: provide the revision token that is expected to be current, and the request is rejected if the skill has been updated since that revision.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct Input {
///New ZIP bundle for the skill revision. The skill name and description are read from the bundle's `SKILL.md`. The scraped documentation does not define a structured request-body schema.
pub body: ::std::string::String,
///Opaque revision token that the skill must currently be at. The write applies only when this value matches, preventing concurrent-update races. Send in the URL query string.
pub expected_revision: ::std::string::String,
///Skill identifier returned by skill creation or `GET /v1/skills`. Send in the URL path.
#[serde(rename = "skillId")]
pub skill_id: InputSkillId,
}
impl Input {
pub fn builder() -> builder::Input {
Default::default()
}
}
///Skill identifier returned by skill creation or `GET /v1/skills`. Send in the URL path.
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct InputSkillId(::std::string::String);
impl ::std::ops::Deref for InputSkillId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<InputSkillId> for ::std::string::String {
fn from(value: InputSkillId) -> Self {
value.0
}
}
impl ::std::str::FromStr for InputSkillId {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
::std::convert::TryFrom::try_from(value)
}
}
impl ::std::convert::TryFrom<&str> for InputSkillId {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<::std::string::String> for InputSkillId {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
::std::convert::TryFrom::try_from(value.as_str())
}
}
impl<'de> ::serde::Deserialize<'de> for InputSkillId {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::convert::TryFrom::try_from(
::std::string::String::deserialize(deserializer)?,
)
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Input {
body: ::std::result::Result<::std::string::String, ::std::string::String>,
expected_revision: ::std::result::Result<
::std::string::String,
::std::string::String,
>,
skill_id: ::std::result::Result<super::InputSkillId, ::std::string::String>,
}
impl ::std::default::Default for Input {
fn default() -> Self {
Self {
body: Err("no value supplied for body".to_string()),
expected_revision: Err(
"no value supplied for expected_revision".to_string(),
),
skill_id: Err("no value supplied for skill_id".to_string()),
}
}
}
impl Input {
pub fn body<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::string::String>,
T::Error: ::std::fmt::Display,
{
self.body = value
.try_into()
.map_err(|e| format!("error converting supplied value for body: {e}"));
self
}
pub fn expected_revision<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::string::String>,
T::Error: ::std::fmt::Display,
{
self.expected_revision = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for expected_revision: {e}")
});
self
}
pub fn skill_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::InputSkillId>,
T::Error: ::std::fmt::Display,
{
self.skill_id = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for skill_id: {e}")
});
self
}
}
impl ::std::convert::TryFrom<Input> for super::Input {
type Error = super::error::ConversionError;
fn try_from(
value: Input,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
body: value.body?,
expected_revision: value.expected_revision?,
skill_id: value.skill_id?,
})
}
}
impl ::std::convert::From<super::Input> for Input {
fn from(value: super::Input) -> Self {
Self {
body: Ok(value.body),
expected_revision: Ok(value.expected_revision),
skill_id: Ok(value.skill_id),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
pub mod output {
///Error details returned for failed requests.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Error {
///HTTP status code associated with the error.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub code: ::std::option::Option<ErrorCode>,
///Human-readable error message.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub message: ::std::option::Option<::std::string::String>,
///Parameter that caused the error, when applicable.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub param: ::std::option::Option<::std::string::String>,
///Error type identifier.
#[serde(rename = "type", skip_serializing_if = "::std::option::Option::is_none")]
pub type_: ::std::option::Option<ErrorType>,
}
impl Error {
pub fn builder() -> builder::Error {
Default::default()
}
}
///HTTP status code associated with the error.
#[derive(::serde::Serialize, Clone, Debug)]
#[serde(transparent)]
pub struct ErrorCode(i64);
impl ::std::ops::Deref for ErrorCode {
type Target = i64;
fn deref(&self) -> &i64 {
&self.0
}
}
impl ::std::convert::From<ErrorCode> for i64 {
fn from(value: ErrorCode) -> Self {
value.0
}
}
impl ::std::str::FromStr for ErrorCode {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value
.parse::<i64>()
.map_err(|e| ::std::string::ToString::to_string(&e).into())
.and_then(Self::try_from)
}
}
impl ::std::convert::TryFrom<i64> for ErrorCode {
type Error = self::error::ConversionError;
fn try_from(
value: i64,
) -> ::std::result::Result<Self, self::error::ConversionError> {
if ![400_i64, 404_i64, 409_i64, 413_i64, 429_i64, 502_i64].contains(&value) {
Err("invalid value".into())
} else {
Ok(Self(value))
}
}
}
impl<'de> ::serde::Deserialize<'de> for ErrorCode {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
Self::try_from(<i64>::deserialize(deserializer)?)
.map_err(|e| { <D::Error as ::serde::de::Error>::custom(e.to_string()) })
}
}
///Error type identifier.
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd
)]
pub enum ErrorType {
#[serde(rename = "invalid_request_error")]
InvalidRequestError,
#[serde(rename = "not_found_error")]
NotFoundError,
#[serde(rename = "revision_conflict_error")]
RevisionConflictError,
#[serde(rename = "payload_too_large_error")]
PayloadTooLargeError,
#[serde(rename = "rate_limit_error")]
RateLimitError,
#[serde(rename = "service_unavailable_error")]
ServiceUnavailableError,
}
impl ::std::fmt::Display for ErrorType {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::InvalidRequestError => f.write_str("invalid_request_error"),
Self::NotFoundError => f.write_str("not_found_error"),
Self::RevisionConflictError => f.write_str("revision_conflict_error"),
Self::PayloadTooLargeError => f.write_str("payload_too_large_error"),
Self::RateLimitError => f.write_str("rate_limit_error"),
Self::ServiceUnavailableError => f.write_str("service_unavailable_error"),
}
}
}
impl ::std::str::FromStr for ErrorType {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"invalid_request_error" => Ok(Self::InvalidRequestError),
"not_found_error" => Ok(Self::NotFoundError),
"revision_conflict_error" => Ok(Self::RevisionConflictError),
"payload_too_large_error" => Ok(Self::PayloadTooLargeError),
"rate_limit_error" => Ok(Self::RateLimitError),
"service_unavailable_error" => Ok(Self::ServiceUnavailableError),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for ErrorType {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ErrorType {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Response structure for adding a new skill revision, including success and documented error responses.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Output {
///Timestamp when the skill was created.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub created_at: ::std::option::Option<::std::string::String>,
///Skill description, read from the bundle's `SKILL.md`.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub description: ::std::option::Option<::std::string::String>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub error: ::std::option::Option<Error>,
///Opaque token for the skill's current latest revision. Use this value as `expected_revision` when updating or deleting the skill.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub latest_revision: ::std::option::Option<::std::string::String>,
///Skill name, read from the bundle's `SKILL.md`.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub name: ::std::option::Option<::std::string::String>,
///Opaque token for the revision returned in this response. This is the latest revision unless a specific revision was requested.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub revision: ::std::option::Option<::std::string::String>,
///Skill identifier.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub skill_id: ::std::option::Option<::std::string::String>,
///Timestamp when the skill was last updated.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub updated_at: ::std::option::Option<::std::string::String>,
}
impl Output {
pub fn builder() -> builder::Output {
Default::default()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Error {
code: ::std::result::Result<
::std::option::Option<super::ErrorCode>,
::std::string::String,
>,
message: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
param: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
type_: ::std::result::Result<
::std::option::Option<super::ErrorType>,
::std::string::String,
>,
}
impl ::std::default::Default for Error {
fn default() -> Self {
Self {
code: Ok(Default::default()),
message: Ok(Default::default()),
param: Ok(Default::default()),
type_: Ok(Default::default()),
}
}
}
impl Error {
pub fn code<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ErrorCode>>,
T::Error: ::std::fmt::Display,
{
self.code = value
.try_into()
.map_err(|e| format!("error converting supplied value for code: {e}"));
self
}
pub fn message<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.message = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for message: {e}")
});
self
}
pub fn param<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.param = value
.try_into()
.map_err(|e| format!("error converting supplied value for param: {e}"));
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ErrorType>>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
}
impl ::std::convert::TryFrom<Error> for super::Error {
type Error = super::error::ConversionError;
fn try_from(
value: Error,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
code: value.code?,
message: value.message?,
param: value.param?,
type_: value.type_?,
})
}
}
impl ::std::convert::From<super::Error> for Error {
fn from(value: super::Error) -> Self {
Self {
code: Ok(value.code),
message: Ok(value.message),
param: Ok(value.param),
type_: Ok(value.type_),
}
}
}
#[derive(Clone, Debug)]
pub struct Output {
created_at: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
description: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
error: ::std::result::Result<
::std::option::Option<super::Error>,
::std::string::String,
>,
latest_revision: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
name: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
revision: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
skill_id: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
updated_at: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for Output {
fn default() -> Self {
Self {
created_at: Ok(Default::default()),
description: Ok(Default::default()),
error: Ok(Default::default()),
latest_revision: Ok(Default::default()),
name: Ok(Default::default()),
revision: Ok(Default::default()),
skill_id: Ok(Default::default()),
updated_at: Ok(Default::default()),
}
}
}
impl Output {
pub fn created_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.created_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for created_at: {e}")
});
self
}
pub fn description<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.description = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for description: {e}")
});
self
}
pub fn error<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Error>>,
T::Error: ::std::fmt::Display,
{
self.error = value
.try_into()
.map_err(|e| format!("error converting supplied value for error: {e}"));
self
}
pub fn latest_revision<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.latest_revision = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for latest_revision: {e}")
});
self
}
pub fn name<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.name = value
.try_into()
.map_err(|e| format!("error converting supplied value for name: {e}"));
self
}
pub fn revision<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.revision = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for revision: {e}")
});
self
}
pub fn skill_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.skill_id = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for skill_id: {e}")
});
self
}
pub fn updated_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.updated_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for updated_at: {e}")
});
self
}
}
impl ::std::convert::TryFrom<Output> for super::Output {
type Error = super::error::ConversionError;
fn try_from(
value: Output,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
created_at: value.created_at?,
description: value.description?,
error: value.error?,
latest_revision: value.latest_revision?,
name: value.name?,
revision: value.revision?,
skill_id: value.skill_id?,
updated_at: value.updated_at?,
})
}
}
impl ::std::convert::From<super::Output> for Output {
fn from(value: super::Output) -> Self {
Self {
created_at: Ok(value.created_at),
description: Ok(value.description),
error: Ok(value.error),
latest_revision: Ok(value.latest_revision),
name: Ok(value.name),
revision: Ok(value.revision),
skill_id: Ok(value.skill_id),
updated_at: Ok(value.updated_at),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
}
/// Where each field of `Input` goes in the request.
pub const ROUTING: ::one::Routing = ::one::Routing { routes: &[::one::Route { field: "skillId", part: ::one::Part::Path, key: Some("skillId") }, ::one::Route { field: "expected_revision", part: ::one::Part::Query, key: Some("expected_revision") }, ::one::Route { field: "body", part: ::one::Part::Body, key: None }], required_parts: &[::one::Part::Path, ::one::Part::Query] };
/// Builds the `add_skill_revision` action.
///
/// # Example input
/// ```json
/// {
/// "body": "UEsDBBQAAAAIAGZpcFQAAAAAAAAAAAAAAAAJAAAAU0tJTEwubWRbz0jNyclXSCvKz1XISSxJVEjOzytJzStRSM7PK0nNK1FIK8rPVShJLS5RKEiszMlPTFFISixScM7PLShKLS7OzM9TSEpV0lFQKkstKs7Mz1NISSxJVUjLL1IoLQYApY0eX1gAAAA=",
/// "expected_revision": "rev_01J4SKILLREVISION01",
/// "skillId": "skill_abc123"
/// }
/// ```
pub fn build(input: Input) -> ::std::result::Result<Operation<output::Output>, Error> {
::std::result::Result::Ok(Operation::action("conn_mod_def::GOQ4DJZcdig::YyfJSqHhRQ28MhSJ5ZrWIw", Method::PUT, "/v1/skills/{{skillId}}").with_routed(&input, &ROUTING)?
.merge_headers(::serde_json::from_str("{\"Accept\":\"application/json\",\"Content-Type\":\"application/json\"}").map_err(Error::Decode)?).returns::<output::Output>())
}
impl IntoOperation for Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
build(self)
}
}
impl IntoOperation for builder::Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
Input::try_from(self).map_err(|error| Error::InvalidInput(::std::boxed::Box::new(error))).and_then(build)
}
}
}
/// Starts building the `add_skill_revision` action's input; pass the builder to `run`.
pub fn add_skill_revision() -> add_skill_revision::builder::Input {
add_skill_revision::builder::Input::default()
}
pub mod get_skill_download_url {
use ::one::{Error, IntoOperation, Method, Operation};
///Returns a short-lived URL for downloading a skill bundle as a ZIP file. When `revision` is omitted, the endpoint returns a download URL for the skill's active revision.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct Input {
///Opaque revision token to download. Send as a URL query parameter. When omitted, the active revision is used.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub revision: ::std::option::Option<::std::string::String>,
///Skill identifier returned by skill creation or `GET /v1/skills`. Send in the URL path.
#[serde(rename = "skillId")]
pub skill_id: InputSkillId,
}
impl Input {
pub fn builder() -> builder::Input {
Default::default()
}
}
///Skill identifier returned by skill creation or `GET /v1/skills`. Send in the URL path.
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct InputSkillId(::std::string::String);
impl ::std::ops::Deref for InputSkillId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<InputSkillId> for ::std::string::String {
fn from(value: InputSkillId) -> Self {
value.0
}
}
impl ::std::str::FromStr for InputSkillId {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
::std::convert::TryFrom::try_from(value)
}
}
impl ::std::convert::TryFrom<&str> for InputSkillId {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<::std::string::String> for InputSkillId {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
::std::convert::TryFrom::try_from(value.as_str())
}
}
impl<'de> ::serde::Deserialize<'de> for InputSkillId {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::convert::TryFrom::try_from(
::std::string::String::deserialize(deserializer)?,
)
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Input {
revision: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
skill_id: ::std::result::Result<super::InputSkillId, ::std::string::String>,
}
impl ::std::default::Default for Input {
fn default() -> Self {
Self {
revision: Ok(Default::default()),
skill_id: Err("no value supplied for skill_id".to_string()),
}
}
}
impl Input {
pub fn revision<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.revision = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for revision: {e}")
});
self
}
pub fn skill_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::InputSkillId>,
T::Error: ::std::fmt::Display,
{
self.skill_id = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for skill_id: {e}")
});
self
}
}
impl ::std::convert::TryFrom<Input> for super::Input {
type Error = super::error::ConversionError;
fn try_from(
value: Input,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
revision: value.revision?,
skill_id: value.skill_id?,
})
}
}
impl ::std::convert::From<super::Input> for Input {
fn from(value: super::Input) -> Self {
Self {
revision: Ok(value.revision),
skill_id: Ok(value.skill_id),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
pub mod output {
///Error details returned for unsuccessful requests.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
pub struct Error {
///HTTP status code.
pub code: i64,
///Human-readable error message.
pub message: ::std::string::String,
///Parameter that caused the error, when applicable.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub param: ::std::option::Option<::std::string::String>,
///Error type identifier.
#[serde(rename = "type")]
pub type_: ::std::string::String,
}
impl Error {
pub fn builder() -> builder::Error {
Default::default()
}
}
///Response containing the resolved skill revision and a short-lived ZIP bundle download URL, or error details for unsuccessful requests.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Output {
///Short-lived URL for downloading the skill ZIP bundle.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub download_url: ::std::option::Option<::std::string::String>,
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub error: ::std::option::Option<Error>,
///Skill name at the downloaded revision.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub name: ::std::option::Option<::std::string::String>,
///Opaque token of the downloaded revision.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub revision: ::std::option::Option<::std::string::String>,
}
impl Output {
pub fn builder() -> builder::Output {
Default::default()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Error {
code: ::std::result::Result<i64, ::std::string::String>,
message: ::std::result::Result<::std::string::String, ::std::string::String>,
param: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
type_: ::std::result::Result<::std::string::String, ::std::string::String>,
}
impl ::std::default::Default for Error {
fn default() -> Self {
Self {
code: Err("no value supplied for code".to_string()),
message: Err("no value supplied for message".to_string()),
param: Ok(Default::default()),
type_: Err("no value supplied for type_".to_string()),
}
}
}
impl Error {
pub fn code<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<i64>,
T::Error: ::std::fmt::Display,
{
self.code = value
.try_into()
.map_err(|e| format!("error converting supplied value for code: {e}"));
self
}
pub fn message<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::string::String>,
T::Error: ::std::fmt::Display,
{
self.message = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for message: {e}")
});
self
}
pub fn param<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.param = value
.try_into()
.map_err(|e| format!("error converting supplied value for param: {e}"));
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::string::String>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
}
impl ::std::convert::TryFrom<Error> for super::Error {
type Error = super::error::ConversionError;
fn try_from(
value: Error,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
code: value.code?,
message: value.message?,
param: value.param?,
type_: value.type_?,
})
}
}
impl ::std::convert::From<super::Error> for Error {
fn from(value: super::Error) -> Self {
Self {
code: Ok(value.code),
message: Ok(value.message),
param: Ok(value.param),
type_: Ok(value.type_),
}
}
}
#[derive(Clone, Debug)]
pub struct Output {
download_url: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
error: ::std::result::Result<
::std::option::Option<super::Error>,
::std::string::String,
>,
name: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
revision: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for Output {
fn default() -> Self {
Self {
download_url: Ok(Default::default()),
error: Ok(Default::default()),
name: Ok(Default::default()),
revision: Ok(Default::default()),
}
}
}
impl Output {
pub fn download_url<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.download_url = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for download_url: {e}")
});
self
}
pub fn error<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Error>>,
T::Error: ::std::fmt::Display,
{
self.error = value
.try_into()
.map_err(|e| format!("error converting supplied value for error: {e}"));
self
}
pub fn name<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.name = value
.try_into()
.map_err(|e| format!("error converting supplied value for name: {e}"));
self
}
pub fn revision<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.revision = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for revision: {e}")
});
self
}
}
impl ::std::convert::TryFrom<Output> for super::Output {
type Error = super::error::ConversionError;
fn try_from(
value: Output,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
download_url: value.download_url?,
error: value.error?,
name: value.name?,
revision: value.revision?,
})
}
}
impl ::std::convert::From<super::Output> for Output {
fn from(value: super::Output) -> Self {
Self {
download_url: Ok(value.download_url),
error: Ok(value.error),
name: Ok(value.name),
revision: Ok(value.revision),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
}
/// Where each field of `Input` goes in the request.
pub const ROUTING: ::one::Routing = ::one::Routing { routes: &[::one::Route { field: "skillId", part: ::one::Part::Path, key: Some("skillId") }, ::one::Route { field: "revision", part: ::one::Part::Query, key: Some("revision") }], required_parts: &[::one::Part::Path] };
/// Builds the `get_skill_download_url` action.
///
/// # Example input
/// ```json
/// {
/// "revision": "rev_20251115_001",
/// "skillId": "skill_abc123"
/// }
/// ```
pub fn build(input: Input) -> ::std::result::Result<Operation<output::Output>, Error> {
::std::result::Result::Ok(Operation::action("conn_mod_def::GOQ4DJ1-dzA::KdBX1BYRQvaANmBsnzSnhw", Method::GET, "/v1/skills/{{skillId}}/download").with_routed(&input, &ROUTING)?
.merge_headers(::serde_json::from_str("{\"Accept\":\"application/json\"}").map_err(Error::Decode)?).returns::<output::Output>())
}
impl IntoOperation for Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
build(self)
}
}
impl IntoOperation for builder::Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
Input::try_from(self).map_err(|error| Error::InvalidInput(::std::boxed::Box::new(error))).and_then(build)
}
}
}
/// Starts building the `get_skill_download_url` action's input; pass the builder to `run`.
pub fn get_skill_download_url() -> get_skill_download_url::builder::Input {
get_skill_download_url::builder::Input::default()
}
pub mod list_skills {
use ::one::{Error, IntoOperation, Method, Operation};
///Lists the skills in your Project, ordered newest first.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
#[serde(deny_unknown_fields)]
pub struct Input {
///Maximum number of items to return. Minimum: 1; maximum: 200; default: 50.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub limit: ::std::option::Option<i64>,
///Opaque token from a previous response's next_page_token used to retrieve the next page.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub page_token: ::std::option::Option<::std::string::String>,
}
impl Input {
pub fn builder() -> builder::Input {
Default::default()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Input {
limit: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
page_token: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for Input {
fn default() -> Self {
Self {
limit: Ok(Default::default()),
page_token: Ok(Default::default()),
}
}
}
impl Input {
pub fn limit<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.limit = value
.try_into()
.map_err(|e| format!("error converting supplied value for limit: {e}"));
self
}
pub fn page_token<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.page_token = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for page_token: {e}")
});
self
}
}
impl ::std::convert::TryFrom<Input> for super::Input {
type Error = super::error::ConversionError;
fn try_from(
value: Input,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
limit: value.limit?,
page_token: value.page_token?,
})
}
}
impl ::std::convert::From<super::Input> for Input {
fn from(value: super::Input) -> Self {
Self {
limit: Ok(value.limit),
page_token: Ok(value.page_token),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
pub mod output {
///Error details returned for failed requests.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
pub struct Error {
///HTTP status code.
pub code: i64,
///Human-readable error message.
pub message: ::std::string::String,
///Parameter that caused the error, when applicable.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub param: ::std::option::Option<::std::string::String>,
///Error type identifier.
#[serde(rename = "type")]
pub type_: ::std::string::String,
}
impl Error {
pub fn builder() -> builder::Error {
Default::default()
}
}
///Response returned when listing skills in the Project.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
pub struct Output {
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub error: ::std::option::Option<Error>,
///Opaque token used to retrieve the next page of results. Omitted on the last page.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub next_page_token: ::std::option::Option<::std::string::String>,
///List of skills in the Project, ordered newest first.
pub skills: ::std::vec::Vec<Skill>,
}
impl Output {
pub fn builder() -> builder::Output {
Default::default()
}
}
///A skill in the Project.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
pub struct Skill {
///Timestamp when the skill was created.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub created_at: ::std::option::Option<::std::string::String>,
///Skill name read from the bundle's SKILL.md.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub name: ::std::option::Option<::std::string::String>,
///Opaque revision token for the skill. Pass this value as expected_revision when updating or deleting the skill.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub revision: ::std::option::Option<::std::string::String>,
///Skill identifier.
pub skill_id: ::std::string::String,
///Timestamp when the skill was last updated.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub updated_at: ::std::option::Option<::std::string::String>,
}
impl Skill {
pub fn builder() -> builder::Skill {
Default::default()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Error {
code: ::std::result::Result<i64, ::std::string::String>,
message: ::std::result::Result<::std::string::String, ::std::string::String>,
param: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
type_: ::std::result::Result<::std::string::String, ::std::string::String>,
}
impl ::std::default::Default for Error {
fn default() -> Self {
Self {
code: Err("no value supplied for code".to_string()),
message: Err("no value supplied for message".to_string()),
param: Ok(Default::default()),
type_: Err("no value supplied for type_".to_string()),
}
}
}
impl Error {
pub fn code<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<i64>,
T::Error: ::std::fmt::Display,
{
self.code = value
.try_into()
.map_err(|e| format!("error converting supplied value for code: {e}"));
self
}
pub fn message<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::string::String>,
T::Error: ::std::fmt::Display,
{
self.message = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for message: {e}")
});
self
}
pub fn param<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.param = value
.try_into()
.map_err(|e| format!("error converting supplied value for param: {e}"));
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::string::String>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
}
impl ::std::convert::TryFrom<Error> for super::Error {
type Error = super::error::ConversionError;
fn try_from(
value: Error,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
code: value.code?,
message: value.message?,
param: value.param?,
type_: value.type_?,
})
}
}
impl ::std::convert::From<super::Error> for Error {
fn from(value: super::Error) -> Self {
Self {
code: Ok(value.code),
message: Ok(value.message),
param: Ok(value.param),
type_: Ok(value.type_),
}
}
}
#[derive(Clone, Debug)]
pub struct Output {
error: ::std::result::Result<
::std::option::Option<super::Error>,
::std::string::String,
>,
next_page_token: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
skills: ::std::result::Result<
::std::vec::Vec<super::Skill>,
::std::string::String,
>,
}
impl ::std::default::Default for Output {
fn default() -> Self {
Self {
error: Ok(Default::default()),
next_page_token: Ok(Default::default()),
skills: Err("no value supplied for skills".to_string()),
}
}
}
impl Output {
pub fn error<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Error>>,
T::Error: ::std::fmt::Display,
{
self.error = value
.try_into()
.map_err(|e| format!("error converting supplied value for error: {e}"));
self
}
pub fn next_page_token<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.next_page_token = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for next_page_token: {e}")
});
self
}
pub fn skills<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::Skill>>,
T::Error: ::std::fmt::Display,
{
self.skills = value
.try_into()
.map_err(|e| format!("error converting supplied value for skills: {e}"));
self
}
}
impl ::std::convert::TryFrom<Output> for super::Output {
type Error = super::error::ConversionError;
fn try_from(
value: Output,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
error: value.error?,
next_page_token: value.next_page_token?,
skills: value.skills?,
})
}
}
impl ::std::convert::From<super::Output> for Output {
fn from(value: super::Output) -> Self {
Self {
error: Ok(value.error),
next_page_token: Ok(value.next_page_token),
skills: Ok(value.skills),
}
}
}
#[derive(Clone, Debug)]
pub struct Skill {
created_at: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
name: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
revision: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
skill_id: ::std::result::Result<::std::string::String, ::std::string::String>,
updated_at: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for Skill {
fn default() -> Self {
Self {
created_at: Ok(Default::default()),
name: Ok(Default::default()),
revision: Ok(Default::default()),
skill_id: Err("no value supplied for skill_id".to_string()),
updated_at: Ok(Default::default()),
}
}
}
impl Skill {
pub fn created_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.created_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for created_at: {e}")
});
self
}
pub fn name<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.name = value
.try_into()
.map_err(|e| format!("error converting supplied value for name: {e}"));
self
}
pub fn revision<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.revision = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for revision: {e}")
});
self
}
pub fn skill_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::string::String>,
T::Error: ::std::fmt::Display,
{
self.skill_id = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for skill_id: {e}")
});
self
}
pub fn updated_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.updated_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for updated_at: {e}")
});
self
}
}
impl ::std::convert::TryFrom<Skill> for super::Skill {
type Error = super::error::ConversionError;
fn try_from(
value: Skill,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
created_at: value.created_at?,
name: value.name?,
revision: value.revision?,
skill_id: value.skill_id?,
updated_at: value.updated_at?,
})
}
}
impl ::std::convert::From<super::Skill> for Skill {
fn from(value: super::Skill) -> Self {
Self {
created_at: Ok(value.created_at),
name: Ok(value.name),
revision: Ok(value.revision),
skill_id: Ok(value.skill_id),
updated_at: Ok(value.updated_at),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
}
/// Where each field of `Input` goes in the request.
pub const ROUTING: ::one::Routing = ::one::Routing { routes: &[::one::Route { field: "limit", part: ::one::Part::Query, key: Some("limit") }, ::one::Route { field: "page_token", part: ::one::Part::Query, key: Some("page_token") }], required_parts: &[] };
/// Builds the `list_skills` action.
///
/// # Example input
/// ```json
/// {
/// "limit": 25,
/// "page_token": "page_01JQ5Z2MXK8G7V4N3H6C9R1T0P"
/// }
/// ```
pub fn build(input: Input) -> ::std::result::Result<Operation<output::Output>, Error> {
::std::result::Result::Ok(Operation::action("conn_mod_def::GOQ4DRK3CoA::ISxLnkcDQQGiA-6BuB4_Ag", Method::GET, "/v1/skills").with_routed(&input, &ROUTING)?
.merge_headers(::serde_json::from_str("{\"Accept\":\"application/json\"}").map_err(Error::Decode)?).returns::<output::Output>())
}
impl IntoOperation for Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
build(self)
}
}
impl IntoOperation for builder::Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
Input::try_from(self).map_err(|error| Error::InvalidInput(::std::boxed::Box::new(error))).and_then(build)
}
}
}
/// Starts building the `list_skills` action's input; pass the builder to `run`.
pub fn list_skills() -> list_skills::builder::Input {
list_skills::builder::Input::default()
}
pub mod list_skills_revisions {
use ::one::{Error, IntoOperation, Method, Operation};
///Lists the revisions for a specified skill, ordered with the newest revision first. The response can be paginated using an opaque page token.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct Input {
///Maximum number of revisions to return. Must be from `1` to `200`. Default: `50`. Send in the URL query string.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub limit: ::std::option::Option<::std::num::NonZeroU64>,
///Opaque pagination token from a previous response's `next_page_token`. Send in the URL query string.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub page_token: ::std::option::Option<::std::string::String>,
///Skill identifier returned by creating the skill or by `GET /v1/skills`. Send in the URL path.
#[serde(rename = "skillId")]
pub skill_id: InputSkillId,
}
impl Input {
pub fn builder() -> builder::Input {
Default::default()
}
}
///Skill identifier returned by creating the skill or by `GET /v1/skills`. Send in the URL path.
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct InputSkillId(::std::string::String);
impl ::std::ops::Deref for InputSkillId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<InputSkillId> for ::std::string::String {
fn from(value: InputSkillId) -> Self {
value.0
}
}
impl ::std::str::FromStr for InputSkillId {
type Err = self::error::ConversionError;
fn from_str(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
::std::convert::TryFrom::try_from(value)
}
}
impl ::std::convert::TryFrom<&str> for InputSkillId {
type Error = self::error::ConversionError;
fn try_from(
value: &str,
) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<::std::string::String> for InputSkillId {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
::std::convert::TryFrom::try_from(value.as_str())
}
}
impl<'de> ::serde::Deserialize<'de> for InputSkillId {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::convert::TryFrom::try_from(
::std::string::String::deserialize(deserializer)?,
)
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Input {
limit: ::std::result::Result<
::std::option::Option<::std::num::NonZeroU64>,
::std::string::String,
>,
page_token: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
skill_id: ::std::result::Result<super::InputSkillId, ::std::string::String>,
}
impl ::std::default::Default for Input {
fn default() -> Self {
Self {
limit: Ok(Default::default()),
page_token: Ok(Default::default()),
skill_id: Err("no value supplied for skill_id".to_string()),
}
}
}
impl Input {
pub fn limit<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::num::NonZeroU64>>,
T::Error: ::std::fmt::Display,
{
self.limit = value
.try_into()
.map_err(|e| format!("error converting supplied value for limit: {e}"));
self
}
pub fn page_token<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.page_token = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for page_token: {e}")
});
self
}
pub fn skill_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::InputSkillId>,
T::Error: ::std::fmt::Display,
{
self.skill_id = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for skill_id: {e}")
});
self
}
}
impl ::std::convert::TryFrom<Input> for super::Input {
type Error = super::error::ConversionError;
fn try_from(
value: Input,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
limit: value.limit?,
page_token: value.page_token?,
skill_id: value.skill_id?,
})
}
}
impl ::std::convert::From<super::Input> for Input {
fn from(value: super::Input) -> Self {
Self {
limit: Ok(value.limit),
page_token: Ok(value.page_token),
skill_id: Ok(value.skill_id),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
pub mod output {
///Error details returned for unsuccessful requests.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Error {
///HTTP status code.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub code: ::std::option::Option<i64>,
///Human-readable error message.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub message: ::std::option::Option<::std::string::String>,
///Parameter that caused the error, when applicable.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub param: ::std::option::Option<::std::string::String>,
///Error type identifier.
#[serde(rename = "type", skip_serializing_if = "::std::option::Option::is_none")]
pub type_: ::std::option::Option<::std::string::String>,
}
impl Error {
pub fn builder() -> builder::Error {
Default::default()
}
}
///Response structure for listing a skill's revisions, including success and error responses.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct Output {
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub error: ::std::option::Option<Error>,
///Opaque token for retrieving the next page of results. Omitted on the last page.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub next_page_token: ::std::option::Option<::std::string::String>,
///List of skill revisions, ordered newest first.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub revisions: ::std::vec::Vec<SkillRevision>,
}
impl Output {
pub fn builder() -> builder::Output {
Default::default()
}
}
///A single skill revision entry.
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, Default)]
pub struct SkillRevision {
///Creation timestamp for the revision.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub created_at: ::std::option::Option<::std::string::String>,
///Skill name at the listed revision.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub name: ::std::option::Option<::std::string::String>,
///Opaque revision token.
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub revision: ::std::option::Option<::std::string::String>,
}
impl SkillRevision {
pub fn builder() -> builder::SkillRevision {
Default::default()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Error {
code: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
message: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
param: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
type_: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for Error {
fn default() -> Self {
Self {
code: Ok(Default::default()),
message: Ok(Default::default()),
param: Ok(Default::default()),
type_: Ok(Default::default()),
}
}
}
impl Error {
pub fn code<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.code = value
.try_into()
.map_err(|e| format!("error converting supplied value for code: {e}"));
self
}
pub fn message<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.message = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for message: {e}")
});
self
}
pub fn param<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.param = value
.try_into()
.map_err(|e| format!("error converting supplied value for param: {e}"));
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
}
impl ::std::convert::TryFrom<Error> for super::Error {
type Error = super::error::ConversionError;
fn try_from(
value: Error,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
code: value.code?,
message: value.message?,
param: value.param?,
type_: value.type_?,
})
}
}
impl ::std::convert::From<super::Error> for Error {
fn from(value: super::Error) -> Self {
Self {
code: Ok(value.code),
message: Ok(value.message),
param: Ok(value.param),
type_: Ok(value.type_),
}
}
}
#[derive(Clone, Debug)]
pub struct Output {
error: ::std::result::Result<
::std::option::Option<super::Error>,
::std::string::String,
>,
next_page_token: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
revisions: ::std::result::Result<
::std::vec::Vec<super::SkillRevision>,
::std::string::String,
>,
}
impl ::std::default::Default for Output {
fn default() -> Self {
Self {
error: Ok(Default::default()),
next_page_token: Ok(Default::default()),
revisions: Ok(Default::default()),
}
}
}
impl Output {
pub fn error<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Error>>,
T::Error: ::std::fmt::Display,
{
self.error = value
.try_into()
.map_err(|e| format!("error converting supplied value for error: {e}"));
self
}
pub fn next_page_token<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.next_page_token = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for next_page_token: {e}")
});
self
}
pub fn revisions<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::SkillRevision>>,
T::Error: ::std::fmt::Display,
{
self.revisions = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for revisions: {e}")
});
self
}
}
impl ::std::convert::TryFrom<Output> for super::Output {
type Error = super::error::ConversionError;
fn try_from(
value: Output,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
error: value.error?,
next_page_token: value.next_page_token?,
revisions: value.revisions?,
})
}
}
impl ::std::convert::From<super::Output> for Output {
fn from(value: super::Output) -> Self {
Self {
error: Ok(value.error),
next_page_token: Ok(value.next_page_token),
revisions: Ok(value.revisions),
}
}
}
#[derive(Clone, Debug)]
pub struct SkillRevision {
created_at: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
name: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
revision: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for SkillRevision {
fn default() -> Self {
Self {
created_at: Ok(Default::default()),
name: Ok(Default::default()),
revision: Ok(Default::default()),
}
}
}
impl SkillRevision {
pub fn created_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.created_at = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for created_at: {e}")
});
self
}
pub fn name<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.name = value
.try_into()
.map_err(|e| format!("error converting supplied value for name: {e}"));
self
}
pub fn revision<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.revision = value
.try_into()
.map_err(|e| {
format!("error converting supplied value for revision: {e}")
});
self
}
}
impl ::std::convert::TryFrom<SkillRevision> for super::SkillRevision {
type Error = super::error::ConversionError;
fn try_from(
value: SkillRevision,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
created_at: value.created_at?,
name: value.name?,
revision: value.revision?,
})
}
}
impl ::std::convert::From<super::SkillRevision> for SkillRevision {
fn from(value: super::SkillRevision) -> Self {
Self {
created_at: Ok(value.created_at),
name: Ok(value.name),
revision: Ok(value.revision),
}
}
}
}
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(
&self,
f: &mut ::std::fmt::Formatter<'_>,
) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
}
/// Where each field of `Input` goes in the request.
pub const ROUTING: ::one::Routing = ::one::Routing { routes: &[::one::Route { field: "skillId", part: ::one::Part::Path, key: Some("skillId") }, ::one::Route { field: "limit", part: ::one::Part::Query, key: Some("limit") }, ::one::Route { field: "page_token", part: ::one::Part::Query, key: Some("page_token") }], required_parts: &[::one::Part::Path] };
/// Builds the `list_skills_revisions` action.
///
/// # Example input
/// ```json
/// {
/// "limit": 50,
/// "page_token": "next_page_token_01HTQ4R0",
/// "skillId": "skill_01HTQ4M8ZP7K3A6N"
/// }
/// ```
pub fn build(input: Input) -> ::std::result::Result<Operation<output::Output>, Error> {
::std::result::Result::Ok(Operation::action("conn_mod_def::GOQ4DUG-wng::WtvnvCI2RZ-uo9uDz5acFw", Method::GET, "/v1/skills/{{skillId}}/revisions").with_routed(&input, &ROUTING)?
.merge_headers(::serde_json::from_str("{\"Accept\":\"application/json\"}").map_err(Error::Decode)?).returns::<output::Output>())
}
impl IntoOperation for Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
build(self)
}
}
impl IntoOperation for builder::Input {
type Output = output::Output;
fn into_operation(self) -> ::std::result::Result<Operation<output::Output>, Error> {
Input::try_from(self).map_err(|error| Error::InvalidInput(::std::boxed::Box::new(error))).and_then(build)
}
}
}
/// Starts building the `list_skills_revisions` action's input; pass the builder to `run`.
pub fn list_skills_revisions() -> list_skills_revisions::builder::Input {
list_skills_revisions::builder::Input::default()
}