openai-client-base 0.16.0

Auto-generated Rust client for the OpenAI API
/*
 * OpenAI API
 *
 * The OpenAI REST API. Please see https://platform.openai.com/docs/api-reference for more details.
 *
 * The version of the OpenAPI document: 2.3.0
 *
 * Generated by: https://openapi-generator.tech
 */

use crate::models;
use serde::{Deserialize, Serialize};

/// SessionEventAgentSessionTurnCancelled : Emitted when a turn is cancelled.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct SessionEventAgentSessionTurnCancelled {
    /// The type of the object. Always `agent.session.turn.cancelled`.
    #[serde(rename = "type")]
    pub r#type: Type,
    /// The unique ID of the event.
    #[serde(rename = "event_id")]
    pub event_id: String,
    /// The ID of the session associated with the event.
    #[serde(rename = "session_id")]
    pub session_id: String,
    /// The ID of the turn associated with the event.
    #[serde(rename = "turn_id")]
    pub turn_id: String,
    #[serde(rename = "turn")]
    pub turn: models::TurnResource,
    #[serde(rename = "usage", deserialize_with = "Option::deserialize")]
    pub usage: Option<models::TokenUsageResource>,
}

impl SessionEventAgentSessionTurnCancelled {
    /// Emitted when a turn is cancelled.
    pub fn new(
        r#type: Type,
        event_id: String,
        session_id: String,
        turn_id: String,
        turn: models::TurnResource,
        usage: Option<models::TokenUsageResource>,
    ) -> SessionEventAgentSessionTurnCancelled {
        SessionEventAgentSessionTurnCancelled {
            r#type,
            event_id,
            session_id,
            turn_id,
            turn,
            usage,
        }
    }
}
/// The type of the object. Always `agent.session.turn.cancelled`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "agent.session.turn.cancelled")]
    AgentSessionTurnCancelled,
}

impl Default for Type {
    fn default() -> Type {
        Self::AgentSessionTurnCancelled
    }
}

impl std::fmt::Display for SessionEventAgentSessionTurnCancelled {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match serde_json::to_string(self) {
            Ok(s) => write!(f, "{}", s),
            Err(_) => Err(std::fmt::Error),
        }
    }
}