openai-client-base 0.12.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};

/// McpApprovalResponseResource : A response to an MCP approval request.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct McpApprovalResponseResource {
    /// The type of the item. Always `mcp_approval_response`.
    #[serde(rename = "type")]
    pub r#type: Type,
    /// The unique ID of the approval response
    #[serde(rename = "id")]
    pub id: String,
    /// The ID of the approval request being answered.
    #[serde(rename = "approval_request_id")]
    pub approval_request_id: String,
    /// Whether the request was approved.
    #[serde(rename = "approve")]
    pub approve: bool,
    /// Optional reason for the decision.
    #[serde(
        rename = "reason",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub reason: Option<Option<String>>,
}

impl McpApprovalResponseResource {
    /// A response to an MCP approval request.
    pub fn new(
        r#type: Type,
        id: String,
        approval_request_id: String,
        approve: bool,
    ) -> McpApprovalResponseResource {
        McpApprovalResponseResource {
            r#type,
            id,
            approval_request_id,
            approve,
            reason: None,
        }
    }
}
/// The type of the item. Always `mcp_approval_response`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "mcp_approval_response")]
    McpApprovalResponse,
}

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

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