nv-redfish 0.4.2

Rust implementation of Redfish API for BMC management
Documentation
# nv-redfish

A modular Redfish client stack for Rust.

## Repository structure

- core: Semantic-unaware foundation used by code generated from CSDL
  - Primitives and traits: `Bmc`, `EntityTypeRef`, `Expandable`, `NavProperty<T>`, `Action<T,R>`, `ODataId`, `ODataETag`, `EdmDateTimeOffset`, `EdmDuration`, `Empty`
  - Optional HTTP client behind the `reqwest` feature (enabled by default) in `core::http` (`ReqwestClient`, `HttpBmc`)
  - Goal: provide the minimum building blocks for generated code; no service-specific logic

- redfish: High-level ergonomic wrappers over generated Redfish schema types
  - Feature-gated services (enable only what you need)
  - OEM extensions are feature-gated by vendor/product
  - Patch support (`redfish::patch_support`) to handle vendor quirks while maintaining compatibility
  - Uses generated types included via `redfish::schema` (autogenerated by the CSDL compiler)

- csdl-compiler: CSDL (OData) schema compiler and Rust code generator
  - Reads Redfish (and OEM) CSDL XML, compiles a subset, and generates Rust code
  - Two primary compilation modes:
    - Compile: compile a subset rooted at specific singletons (e.g., `Service`)
    - CompileOem: compile OEM schemas and include them in the root set
  - Entity type inclusion can be controlled with wildcard patterns; only needed types are compiled
  - The generator produces Rust modules and types consumed by the `redfish` crate
  - CLI: `csdl-compiler` with subcommands in `csdl-compiler/src/commands.rs`

## How the pieces fit together

1. Choose features in `nv-redfish` (services, OEM flags). The selected features determine which schemas to include (see `features.toml`) and which high-level wrappers are built.
2. The build uses `csdl-compiler` to generate only the required schema types into the `redfish` crate (via `build.rs`), keeping the binary lightweight.
3. The high-level `nv-redfish` APIs (e.g., `ServiceRoot`, `accounts`) operate over the generated types and the `core` primitives.
4. Provide a `Bmc` implementation. With `core`’s `reqwest` feature, use `HttpBmc<ReqwestClient>`; otherwise, plug in your own transport.

## Feature flags

- core: `reqwest` (default) enables the HTTP client implementation.
- redfish:
  - `std-redfish`: convenience bundle of common service features.
  - Service features: `accounts`, `assembly`, `bios`, `boot-options`, `chassis`, `computer-systems`, `ethernet-interfaces`, `event-service`, `log-services`, `managers`, `memory`, `network-adapters`, `pcie-devices`, `power`, `power-supplies`, `processors`, `secure-boot`, `sensors`, `storages`, `thermal`, `update-service` (plus helper `resource-status`).
  - OEM vendor features: `oem`, `oem-ami`, `oem-dell`, `oem-hpe`, `oem-lenovo`, `oem-supermicro`, `oem-nvidia`.
  - OEM product features: `oem-nvidia-bluefield`, `oem-nvidia-baseboard`.

Use `std-redfish` for broad support and fast onboarding.
For smaller binaries and faster compilation, enable only the specific service/OEM features your client needs.

## Example

Minimal shape:

```rust
// Recursion limit is need to be increased because Redfish has deep
// tree of types reference to each other.
#![recursion_limit = "256"]

use nv_redfish::ServiceRoot;
use nv_redfish_bmc_http::reqwest::Client;
use nv_redfish_bmc_http::{BmcCredentials, CacheSettings, HttpBmc};
use std::sync::Arc;
use url::Url;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let http_client = Client::new()?;
    let bmc = Arc::new(HttpBmc::new(
        http_client,
        Url::parse("https://example.com")?,
        BmcCredentials::new("admin".into(), "password".into()),
        CacheSettings::default(),
    ));

    let root = ServiceRoot::new(Arc::clone(&bmc)).await?;
    println!("BMC vendor: {:?}", root.vendor());
    Ok(())
}
```

## Goals

- Be as lightweight as possible:
  - Compile only schemas referenced by enabled features (`features.toml` driven).
  - Keep the core minimal and transport-agnostic.
- Support a variety of vendors compatibly:
  - Feature-gated OEM extensions.
  - Patch support for schema deviations in real-world BMCs.

## License

See workspace `Cargo.toml`.

This project includes Redfish schema files as submodule from DMTF’s [Redfish-Publications repository](https://github.com/DMTF/Redfish-Publications/tree/main), licensed under the [BSD-3-Clause license](https://github.com/DMTF/Redfish-Publications/blob/main/LICENSE.md).

This project includes Swordfish schema files as submodule from SNIA’s [Swordfish-Publications repository](https://github.com/SNIA/Swordfish-Publications), licensed under the [BSD-3-Clause license](https://github.com/SNIA/Swordfish-Publications/blob/main/LICENSE).

## Contributing

Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.