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};

/// SessionEnvironmentStateResource : The current state of a session environment.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct SessionEnvironmentStateResource {
    /// The public ID of the environment.
    #[serde(rename = "id")]
    pub id: String,
    /// The environment type.
    #[serde(rename = "type")]
    pub r#type: String,
    #[serde(rename = "status")]
    pub status: models::SessionEnvironmentStatusResource,
    #[serde(rename = "error", deserialize_with = "Option::deserialize")]
    pub error: Option<models::SessionEnvironmentErrorResource>,
}

impl SessionEnvironmentStateResource {
    /// The current state of a session environment.
    pub fn new(
        id: String,
        r#type: String,
        status: models::SessionEnvironmentStatusResource,
        error: Option<models::SessionEnvironmentErrorResource>,
    ) -> SessionEnvironmentStateResource {
        SessionEnvironmentStateResource {
            id,
            r#type,
            status,
            error,
        }
    }
}

impl std::fmt::Display for SessionEnvironmentStateResource {
    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),
        }
    }
}