# nucel-sdk-api

Auto-generated Rust client for the [nucel.dev](https://nucel.dev) REST API.

## Features

- 47+ builder-style methods covering the full API v1 (repos, issues, PRs,
  pipelines, releases, labels, files, orgs, webhooks, users)
- Typed request bodies and response bodies via progenitor code generation
- Bearer token authentication built in
- Reuses your own `reqwest::Client` for middleware, tracing, retries, etc.
- Zero hand-written HTTP plumbing — everything is generated from the
  OpenAPI spec shipped in this crate at `openapi/nucel.json`

## Installation

```toml
[dependencies]
nucel-sdk-api = "0.1"
```

## Usage

```rust
use nucel_sdk_api::Client;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Build a client with a bearer token.
    let client = nucel_sdk_api::new(
        "https://nucel.dev",
        Some("your-personal-access-token".into()),
    )?;

    // List repositories in an org.
    let repos = client
        .list_repos()
        .owner("acme")
        .send()
        .await?;
    println!("{}", repos.into_inner());

    // Create an issue.
    let body = nucel_sdk_api::types::CreateIssueBody::builder()
        .title("Something is broken")
        .body(Some("Details...".into()));
    let issue = client
        .create_issue()
        .owner("acme")
        .repo("widgets")
        .body(body)
        .send()
        .await?;

    // Merge a PR.
    let merge = nucel_sdk_api::types::MergePrBody::builder()
        .strategy(Some("squash".into()));
    client
        .merge_pull()
        .owner("acme")
        .repo("widgets")
        .number(42)
        .body(merge)
        .send()
        .await?;

    Ok(())
}
```

## Available methods

Every endpoint in the nucel API v1 has a corresponding builder method. The
full list is auto-generated — `cargo doc --open` to explore it, or check
the Swagger UI at `https://nucel.dev/api/docs`.

Major endpoint families:
- `list_repos`, `get_repo`, `create_repo_handler`
- `list_branches`, `create_branch`, `get_commit_status`
- `list_issues`, `create_issue`, `get_issue`, `add_comment`, `close_issue`, `update_labels`, `remove_label`
- `list_pulls`, `create_pull`, `get_pull`, `update_pull`, `merge_pull`, `list_pull_files`, `get_pull_diff`, `submit_review`, `add_pr_comment`, `compare_branches`
- `list_pipelines`, `get_pipeline`, `cancel_pipeline`, `get_pipeline_logs`
- `list_releases`, `create_release`, `get_release`, `delete_release`
- `list_labels`, `create_label`
- `get_tree`, `get_blob`, `get_raw`
- `get_org`, `list_members`
- `list_webhooks`, `create_webhook`, `delete_webhook`
- `get_current_user`, `list_user_orgs`

## How the SDK is generated

1. The `nucel-server` crate annotates every API v1 handler with `#[utoipa::path]`
2. `cargo run -p nucel-server --bin export-openapi` writes the OpenAPI spec
   to `openapi/nucel.json` (workspace-level) and to this crate's
   `openapi/nucel.json` (crate-local, shipped in the published tarball)
3. This crate's `build.rs` runs
   [progenitor](https://github.com/oxidecomputer/progenitor) against that
   spec to produce the typed builder client at build time
4. `src/lib.rs` re-exports the generated `Client` plus a `new(base_url, token)` helper

## Related packages

- [`@nucel/sdk-api`](https://www.npmjs.com/package/@nucel/sdk-api) — TypeScript
  SDK generated from the same OpenAPI spec.

## License

MIT
