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/blob.json (sh.tangled.repo.blob)

#![allow(clippy::all)]

#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
pub struct LastCommit {
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub author: Option<crate::lexicon::sh::tangled::repo::blob::Signature>,
    /// Commit hash
    pub hash: String,
    /// Commit message
    pub message: String,
    /// Commit timestamp
    pub when: String,
    /// 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.blob";

#[derive(Debug, Clone, Default, serde::Serialize)]
pub struct Params {
    /// Path to the file within the repository
    pub path: String,
    /// Return raw file content instead of JSON response
    #[serde(skip_serializing_if = "Option::is_none")]
    pub raw: Option<bool>,
    /// Git reference (branch, tag, or commit SHA)
    pub r#ref: String,
    /// DID of the repository
    pub repo: String,
}

#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
pub struct Output {
    /// File content (base64 encoded for binary files)
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub content: Option<String>,
    /// Content encoding
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub encoding: Option<String>,
    #[serde(
        rename = "fileTooLarge",
        skip_serializing_if = "Option::is_none",
        default
    )]
    pub file_too_large: Option<bool>,
    /// Whether the file is binary
    #[serde(
        rename = "isBinary",
        skip_serializing_if = "Option::is_none",
        default
    )]
    pub is_binary: Option<bool>,
    #[serde(
        rename = "lastCommit",
        skip_serializing_if = "Option::is_none",
        default
    )]
    pub last_commit:
        Option<crate::lexicon::sh::tangled::repo::blob::LastCommit>,
    /// MIME type of the file
    #[serde(
        rename = "mimeType",
        skip_serializing_if = "Option::is_none",
        default
    )]
    pub mime_type: Option<String>,
    /// The file path
    pub path: String,
    /// The git reference used
    pub r#ref: String,
    /// File size in bytes
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub size: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub submodule: Option<crate::lexicon::sh::tangled::repo::blob::Submodule>,
}

///
/// Errors:
/// - `RepoNotFound`: Repository not found or access denied
/// - `RefNotFound`: Git reference not found
/// - `FileNotFound`: File not found at the specified path
/// - `InvalidRequest`: Invalid request parameters
pub fn blob(
    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
}

#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
pub struct Signature {
    /// Author email
    pub email: String,
    /// Author name
    pub name: String,
    /// Author timestamp
    pub when: String,
    /// Unknown fields, preserved across read-modify-write round-trips.
    #[serde(flatten)]
    pub extra: serde_json::Map<String, serde_json::Value>,
}

#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
pub struct Submodule {
    /// Branch to track in the submodule
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub branch: Option<String>,
    /// Submodule name
    pub name: String,
    /// Submodule repository URL
    pub url: String,
    /// Unknown fields, preserved across read-modify-write round-trips.
    #[serde(flatten)]
    pub extra: serde_json::Map<String, serde_json::Value>,
}