diff --git a/src/sdk/gitea.rs b/src/sdk/gitea.rs new file mode 100644 index 0000000..48983f6 --- /dev/null +++ b/src/sdk/gitea.rs @@ -0,0 +1,732 @@ +use std::sync::Arc; + +use reqwest::Client as HttpClient; +use serde::{Deserialize, Serialize}; +use tracing::{debug, info, warn}; +use url::form_urlencoded; + +use super::tokens::TokenStore; + +const SERVICE: &str = "gitea"; +const TOKEN_NAME: &str = "sol-agent"; +const TOKEN_SCOPES: &[&str] = &[ + "read:issue", + "write:issue", + "read:repository", + "read:user", + "read:organization", +]; + +pub struct GiteaClient { + base_url: String, + admin_username: String, + admin_password: String, + http: HttpClient, + token_store: Arc, +} + +// ── Response types ────────────────────────────────────────────────────────── + +#[derive(Debug, Serialize, Deserialize)] +pub struct RepoSummary { + pub full_name: String, + pub description: String, + #[serde(default)] + pub html_url: String, + #[serde(default)] + pub open_issues_count: u32, + #[serde(default)] + pub stars_count: u32, + #[serde(default)] + pub updated_at: String, + #[serde(default)] + pub private: bool, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct Repo { + pub full_name: String, + pub description: String, + pub html_url: String, + pub default_branch: String, + pub open_issues_count: u32, + pub stars_count: u32, + pub forks_count: u32, + pub updated_at: String, + pub private: bool, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct Issue { + pub number: u64, + pub title: String, + #[serde(default)] + pub body: String, + pub state: String, + pub html_url: String, + pub user: UserRef, + #[serde(default)] + pub labels: Vec