# Harbor API Rust Client
A Rust client library for the [Harbor](https://harbor.gg) API, automatically generated from their OpenAPI specification.
## Features
- Fully typed API client generated from Harbor's OpenAPI spec
- Async/await support with tokio
- Automatic retry and error handling via progenitor
- Builder pattern for constructing API requests
## Installation
Add this to your `Cargo.toml`:
```toml
[dependencies]
harbor-api = { git = "https://github.com/AprilNEA/harbor-api" }
```
## Usage
```rust
use harbor_api::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a new client instance
let client = Client::new("https://api.harbor.gg");
// Make API calls using the generated methods
// Example (adjust based on actual API endpoints):
// let response = client.get_something().send().await?;
Ok(())
}
```
## Building from Source
This project uses a build script to generate the API client from Harbor's OpenAPI specification.
### Prerequisites
- Rust 1.70 or later
- Internet connection (for fetching the OpenAPI spec during build)
### Build
```bash
cargo build
```
### Custom API Spec
You can override the default API specification URL by setting the `SPEC_URL` environment variable:
```bash
SPEC_URL=https://your-harbor-instance.com/api/swagger.json cargo build
```
## Development
The API client is generated at build time using [progenitor](https://github.com/oxidecomputer/progenitor). The build script:
1. Fetches the OpenAPI specification from Harbor's API
2. Ensures all operations have unique operation IDs
3. Filters out unsupported operations (e.g., multipart/form-data)
4. Generates type-safe Rust code
### Project Structure
```
harbor-api/
├── Cargo.toml # Project dependencies
├── build.rs # Build script for code generation
├── src/
│ └── lib.rs # Library entry point (includes generated code)
└── target/
└── debug/
└── build/.../out/
└── codegen.rs # Generated API client code
```
## Known Limitations
- Operations that use `multipart/form-data` content type are not supported and are filtered out during code generation
- The generated client requires an active internet connection during the build process to fetch the API specification
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
## License
This project is open source. Please check the repository for license details.
## Author
- **AprilNEA** - [GitHub](https://github.com/AprilNEA)
## Acknowledgments
- [Harbor](https://harbor.gg) for providing the API
- [progenitor](https://github.com/oxidecomputer/progenitor) for the excellent OpenAPI code generation tools