Skip to main content

gproxy_protocol/gemini/model_list/
response.rs

1use http::StatusCode;
2use serde::{Deserialize, Serialize};
3
4use crate::gemini::types::{GeminiApiErrorResponse, GeminiModelInfo, GeminiResponseHeaders};
5
6/// Successful body for Gemini `models.list` endpoint.
7#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
8pub struct ResponseBody {
9    /// List of models in this page.
10    #[serde(default, skip_serializing_if = "Vec::is_empty")]
11    pub models: Vec<GeminiModelInfo>,
12    /// Token to fetch next page.
13    #[serde(
14        rename = "nextPageToken",
15        default,
16        skip_serializing_if = "Option::is_none"
17    )]
18    pub next_page_token: Option<String>,
19}
20
21/// Full HTTP response for Gemini `models.list` endpoint.
22#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
23#[serde(untagged)]
24pub enum GeminiModelListResponse {
25    Success {
26        /// HTTP status code returned by server (should be `200 OK`).
27        #[serde(with = "crate::gemini::types::status_code_serde")]
28        stats_code: StatusCode,
29        /// Response headers.
30        headers: GeminiResponseHeaders,
31        /// Successful body.
32        body: ResponseBody,
33    },
34    Error {
35        /// HTTP status code returned by server (typically non-2xx).
36        #[serde(with = "crate::gemini::types::status_code_serde")]
37        stats_code: StatusCode,
38        /// Response headers.
39        headers: GeminiResponseHeaders,
40        /// Error body.
41        body: GeminiApiErrorResponse,
42    },
43}