47 lines
1.3 KiB
Rust
47 lines
1.3 KiB
Rust
//! A tenant's projects, owned by the platform registry.
|
|
//!
|
|
//! A project groups targets organisationally: a customer's product or
|
|
//! machine, or a topic such as the CRA or the Data Act. It never changes what
|
|
//! gets checked. Targets refer to projects by the registry's id.
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
/// What a project stands for.
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum ProjectKind {
|
|
/// A customer's product or machine.
|
|
Product,
|
|
/// A topic such as the CRA or the Data Act.
|
|
Topic,
|
|
}
|
|
|
|
/// One of a tenant's projects, as the registry lists it
|
|
/// (`GET /v1/tenants/{id}/projects`).
|
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
pub struct Project {
|
|
/// The registry's id (a UUID).
|
|
pub id: String,
|
|
pub name: String,
|
|
pub kind: ProjectKind,
|
|
#[serde(default)]
|
|
pub description: String,
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn a_registry_project_reads() {
|
|
let p: Project = serde_json::from_value(serde_json::json!({
|
|
"id": "0b7d51aa-9f1c-4e33-8a1f-2d8c1e0f9a77",
|
|
"name": "Rangierlok 3000",
|
|
"kind": "product"
|
|
}))
|
|
.expect("deserialize");
|
|
assert_eq!(p.kind, ProjectKind::Product);
|
|
assert_eq!(p.description, "");
|
|
}
|
|
}
|