mirror of
https://github.com/openai/codex.git
synced 2026-04-25 15:15:15 +00:00
Adds a `GET account/rateLimits/read` API to app-server. This calls the codex backend to fetch the user's current rate limits. This would be helpful in checking rate limits without having to send a message. For calling the codex backend usage API, I generated the types and manually copied the relevant ones into `codex-backend-openapi-types`. It'll be nice to extend our internal openapi generator to support Rust so we don't have to run these manual steps. # External (non-OpenAI) Pull Request Requirements Before opening this Pull Request, please read the dedicated "Contributing" markdown file or your PR may be closed: https://github.com/openai/codex/blob/main/docs/contributing.md If your PR conforms to our contribution guidelines, replace this text with a detailed and high quality description of your changes.
66 lines
1.4 KiB
Rust
66 lines
1.4 KiB
Rust
/*
|
|
* codex-backend
|
|
*
|
|
* codex-backend
|
|
*
|
|
* The version of the OpenAPI document: 0.0.1
|
|
*
|
|
* Generated by: https://openapi-generator.tech
|
|
*/
|
|
|
|
use crate::models;
|
|
use serde::Deserialize;
|
|
use serde::Serialize;
|
|
|
|
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
|
|
pub struct RateLimitStatusPayload {
|
|
#[serde(rename = "plan_type")]
|
|
pub plan_type: PlanType,
|
|
#[serde(
|
|
rename = "rate_limit",
|
|
default,
|
|
with = "::serde_with::rust::double_option",
|
|
skip_serializing_if = "Option::is_none"
|
|
)]
|
|
pub rate_limit: Option<Option<Box<models::RateLimitStatusDetails>>>,
|
|
}
|
|
|
|
impl RateLimitStatusPayload {
|
|
pub fn new(plan_type: PlanType) -> RateLimitStatusPayload {
|
|
RateLimitStatusPayload {
|
|
plan_type,
|
|
rate_limit: None,
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
|
|
pub enum PlanType {
|
|
#[serde(rename = "free")]
|
|
Free,
|
|
#[serde(rename = "go")]
|
|
Go,
|
|
#[serde(rename = "plus")]
|
|
Plus,
|
|
#[serde(rename = "pro")]
|
|
Pro,
|
|
#[serde(rename = "team")]
|
|
Team,
|
|
#[serde(rename = "business")]
|
|
Business,
|
|
#[serde(rename = "education")]
|
|
Education,
|
|
#[serde(rename = "quorum")]
|
|
Quorum,
|
|
#[serde(rename = "enterprise")]
|
|
Enterprise,
|
|
#[serde(rename = "edu")]
|
|
Edu,
|
|
}
|
|
|
|
impl Default for PlanType {
|
|
fn default() -> PlanType {
|
|
Self::Free
|
|
}
|
|
}
|