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

/// McpOauthRefreshResource : Configuration used to refresh an MCP OAuth access token, excluding secret values.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct McpOauthRefreshResource {
    /// The HTTPS OAuth token endpoint used for refresh.
    #[serde(rename = "token_endpoint")]
    pub token_endpoint: String,
    /// The OAuth client ID used when requesting a new access token.
    #[serde(rename = "client_id")]
    pub client_id: String,
    /// The resource URI sent to the OAuth token endpoint during refresh, if configured.
    #[serde(rename = "resource", deserialize_with = "Option::deserialize")]
    pub resource: Option<String>,
    /// Space-separated OAuth scopes requested during refresh, if configured.
    #[serde(rename = "scope", deserialize_with = "Option::deserialize")]
    pub scope: Option<String>,
    #[serde(rename = "token_endpoint_auth")]
    pub token_endpoint_auth: Box<models::McpOauthTokenEndpointAuthResource>,
}

impl McpOauthRefreshResource {
    /// Configuration used to refresh an MCP OAuth access token, excluding secret values.
    pub fn new(
        token_endpoint: String,
        client_id: String,
        resource: Option<String>,
        scope: Option<String>,
        token_endpoint_auth: models::McpOauthTokenEndpointAuthResource,
    ) -> McpOauthRefreshResource {
        McpOauthRefreshResource {
            token_endpoint,
            client_id,
            resource,
            scope,
            token_endpoint_auth: Box::new(token_endpoint_auth),
        }
    }
}

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