# devops-models
[](https://crates.io/crates/devops-models)
[](https://docs.rs/devops-models)
[](LICENSE-MIT)
Typed `serde` models for common DevOps configuration formats.
Zero browser dependencies — works in any Rust target: native CLIs, CI/CD plugins, cloud functions, and WASM.
## Supported formats
| **Kubernetes** | Deployment, Service, ConfigMap, Secret, Ingress, HPA, CronJob, Job, PVC, NetworkPolicy, StatefulSet, DaemonSet, Role, ClusterRole, RoleBinding, ClusterRoleBinding, ServiceAccount |
| **CI/CD** | GitLab CI pipelines, GitHub Actions workflows |
| **Containers** | Docker Compose |
| **Monitoring** | Prometheus, Alertmanager |
| **Configuration** | Helm values, Ansible playbooks |
| **API** | OpenAPI 3.x |
| **LLM** | ChatMessage, ChatRequest/Response, LlmProvider, LlmConfig |
## Quick start
```toml
[dependencies]
devops-models = "0.1"
```
### Parse a Kubernetes Deployment
```rust
use devops_models::models::k8s::K8sDeployment;
let yaml = r#"
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
namespace: production
spec:
replicas: 3
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: app
image: my-app:v1.2.3
resources:
limits:
memory: "256Mi"
cpu: "500m"
"#;
let deployment: K8sDeployment = serde_yaml::from_str(yaml).unwrap();
println!("Replicas: {:?}", deployment.spec.replicas);
```
### Validate with the `ConfigValidator` trait
All models implement `ConfigValidator`, which provides structure + semantic validation:
```rust,ignore
use devops_models::models::validation::ConfigValidator;
use devops_models::models::k8s_workloads::K8sCronJob;
let cronjob: K8sCronJob = serde_yaml::from_str(yaml).unwrap();
let result = cronjob.validate();
if !result.valid {
for err in &result.errors {
eprintln!("Error: {}", err);
}
}
for warn in &result.warnings {
println!("Warning: {}", warn);
}
```
### Parse a Docker Compose file
```rust,ignore
use devops_models::models::docker_compose::DockerCompose;
let compose: DockerCompose = serde_yaml::from_str(yaml).unwrap();
```
### LLM configuration
```rust
use devops_models::llm::provider::{LlmConfig, LlmProvider};
let config = LlmConfig {
provider: LlmProvider::Anthropic,
api_key: "sk-ant-...".to_string(),
model: "claude-sonnet-4-20250514".to_string(),
base_url: None,
};
println!("Endpoint: {}", config.endpoint());
```
## Error handling
```rust
use devops_models::{DevopsError, Result};
fn parse_k8s(yaml: &str) -> Result<()> {
serde_yaml::from_str::<serde_json::Value>(yaml)
.map_err(|e| DevopsError::YamlParse(e.to_string()))?;
Ok(())
}
```
## Feature flags
This crate has no optional feature flags — all types are always available and have no platform-specific dependencies.
## Relationship to other crates
- **[devops-validate](https://crates.io/crates/devops-validate)** — YAML validation and auto-repair engine built on top of these models.
- **[devops-toolkit](https://crates.io/crates/devops-toolkit)** — Meta-crate that re-exports both.
## License
Licensed under either of [MIT](LICENSE-MIT) or [Apache-2.0](LICENSE-APACHE), at your option.