tangled-api 0.1.0

Lexicon-generated XRPC client for Tangled and AT Protocol APIs
Documentation
// @generated by `cargo xtask codegen` — do not edit.
// source: lexicons/repo/languages.json (sh.tangled.repo.languages)

#![allow(clippy::all)]

#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
pub struct Language {
    /// Hex color code for this language
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub color: Option<String>,
    /// File extensions associated with this language
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub extensions: Option<Vec<String>>,
    /// Number of files in this language
    #[serde(
        rename = "fileCount",
        skip_serializing_if = "Option::is_none",
        default
    )]
    pub file_count: Option<i64>,
    /// Programming language name
    pub name: String,
    /// Percentage of total codebase (0-100)
    pub percentage: i64,
    /// Total size of files in this language (bytes)
    pub size: i64,
    /// Unknown fields, preserved across read-modify-write round-trips.
    #[serde(flatten)]
    pub extra: serde_json::Map<String, serde_json::Value>,
}

pub const NSID: &str = "sh.tangled.repo.languages";

#[derive(Debug, Clone, Default, serde::Serialize)]
pub struct Params {
    /// Git reference (branch, tag, or commit SHA)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub r#ref: Option<String>,
    /// Repository identifier in format 'did:plc:.../repoName'
    pub repo: String,
}

#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
pub struct Output {
    pub languages: Vec<crate::lexicon::sh::tangled::repo::languages::Language>,
    /// The git reference used
    pub r#ref: String,
    /// Total number of files analyzed
    #[serde(
        rename = "totalFiles",
        skip_serializing_if = "Option::is_none",
        default
    )]
    pub total_files: Option<i64>,
    /// Total size of all analyzed files in bytes
    #[serde(
        rename = "totalSize",
        skip_serializing_if = "Option::is_none",
        default
    )]
    pub total_size: Option<i64>,
}

///
/// Errors:
/// - `RepoNotFound`: Repository not found or access denied
/// - `RefNotFound`: Git reference not found
/// - `InvalidRequest`: Invalid request parameters
pub fn languages(
    http: &reqwest::Client,
    base: &str,
    params: &Params,
) -> reqwest::RequestBuilder {
    let rb = http.get(crate::xrpc::xrpc_url(base, NSID));
    let rb = rb.header(reqwest::header::ACCEPT, "application/json");
    let rb = crate::xrpc::push_query(rb, params);
    rb
}