Skip to main content

mesa_dev/models/
repo.rs

1//! Repository models.
2
3use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Deserialize)]
6pub enum RepoStatus {
7    #[serde(rename = "syncing")]
8    Syncing,
9}
10
11/// A repository.
12#[derive(Debug, Clone, Deserialize)]
13pub struct Repo {
14    /// Unique repository identifier.
15    pub id: String,
16    /// Organization that owns this repository.
17    pub org: String,
18    /// Repository name.
19    pub name: String,
20    /// Name of the default branch.
21    pub default_branch: String,
22    /// Size in bytes.
23    pub size_bytes: u64,
24    /// Timestamp of the last push, if any.
25    pub last_push_at: Option<String>,
26    /// Creation timestamp.
27    pub created_at: String,
28    /// The current status of the repo
29    pub status: Option<RepoStatus>,
30}
31
32/// Request body for creating a repository.
33#[derive(Debug, Clone, Serialize)]
34pub struct CreateRepoRequest {
35    /// Repository name.
36    pub name: String,
37    /// Optional default branch name (defaults to `"main"` on the server).
38    #[serde(skip_serializing_if = "Option::is_none")]
39    pub default_branch: Option<String>,
40}
41
42/// Request body for renaming a repository.
43#[derive(Debug, Clone, Serialize)]
44pub struct RenameRepoRequest {
45    /// New repository name.
46    pub name: String,
47}
48
49/// Paginated list of repositories.
50#[derive(Debug, Clone, Deserialize)]
51pub struct ListReposResponse {
52    /// The repositories in this page.
53    pub repos: Vec<Repo>,
54    /// Cursor for the next page, if more results exist.
55    pub next_cursor: Option<String>,
56    /// Whether more results are available.
57    pub has_more: bool,
58}