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

/// CreateMcpOauthRefreshParam : Configuration for refreshing the access token of an MCP OAuth credential.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct CreateMcpOauthRefreshParam {
    /// The HTTPS OAuth token endpoint used to exchange the refresh token for a new access token.
    #[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 to send to the OAuth token endpoint during refresh, if required.
    #[serde(
        rename = "resource",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub resource: Option<Option<String>>,
    /// Space-separated OAuth scopes to request during refresh, if required.
    #[serde(
        rename = "scope",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub scope: Option<Option<String>>,
    /// The refresh token to store. This secret is never returned in credential resources.
    #[serde(rename = "refresh_token")]
    pub refresh_token: String,
    #[serde(rename = "token_endpoint_auth")]
    pub token_endpoint_auth: Box<models::CreateMcpOauthTokenEndpointAuthParam>,
}

impl CreateMcpOauthRefreshParam {
    /// Configuration for refreshing the access token of an MCP OAuth credential.
    pub fn new(
        token_endpoint: String,
        client_id: String,
        refresh_token: String,
        token_endpoint_auth: models::CreateMcpOauthTokenEndpointAuthParam,
    ) -> CreateMcpOauthRefreshParam {
        CreateMcpOauthRefreshParam {
            token_endpoint,
            client_id,
            resource: None,
            scope: None,
            refresh_token,
            token_endpoint_auth: Box::new(token_endpoint_auth),
        }
    }
}

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