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

#![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::tree::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.tree";

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

#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
pub struct Output {
    /// Parent directory path
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub dotdot: Option<String>,
    pub files: Vec<crate::lexicon::sh::tangled::repo::tree::TreeEntry>,
    #[serde(
        rename = "lastCommit",
        skip_serializing_if = "Option::is_none",
        default
    )]
    pub last_commit:
        Option<crate::lexicon::sh::tangled::repo::tree::LastCommit>,
    /// The parent path in the tree
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub parent: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub readme: Option<crate::lexicon::sh::tangled::repo::tree::Readme>,
    /// The git reference used
    pub r#ref: String,
}

///
/// Errors:
/// - `RepoNotFound`: Repository not found or access denied
/// - `RefNotFound`: Git reference not found
/// - `PathNotFound`: Path not found in repository tree
/// - `InvalidRequest`: Invalid request parameters
pub fn tree(
    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 Readme {
    /// Contents of the readme file
    pub contents: String,
    /// Name of the readme file
    pub filename: 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 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 TreeEntry {
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub last_commit:
        Option<crate::lexicon::sh::tangled::repo::tree::LastCommit>,
    /// File mode
    pub mode: String,
    /// Relative file or directory name
    pub name: String,
    /// File size in bytes
    pub size: i64,
    /// Unknown fields, preserved across read-modify-write round-trips.
    #[serde(flatten)]
    pub extra: serde_json::Map<String, serde_json::Value>,
}