zlayer_types/api/environments.rs
1//! Environment DTOs.
2//!
3//! Request/response types for the `/api/v1/environments` CRUD endpoints. The
4//! runtime state structs (`EnvironmentsState`, `EnvironmentsRouterState`) and
5//! the axum handler functions remain in the API crate.
6
7use serde::{Deserialize, Serialize};
8
9/// Query for `GET /api/v1/environments`.
10///
11/// `project` selects the namespace:
12/// - omitted → list global environments only (`project_id IS NULL`).
13/// - `*` → list every environment across all projects + global.
14/// - any other value → list environments owned by that project id.
15#[derive(Debug, Deserialize, Default)]
16pub struct ListEnvironmentsQuery {
17 #[serde(default)]
18 pub project: Option<String>,
19}
20
21/// Body for `POST /api/v1/environments`.
22#[derive(Debug, Serialize, Deserialize, utoipa::ToSchema)]
23pub struct CreateEnvironmentRequest {
24 /// Display name. Must be unique within the chosen `project_id` namespace.
25 pub name: String,
26 /// Owning project id. `None` = global environment.
27 #[serde(default)]
28 pub project_id: Option<String>,
29 /// Free-form description shown in the UI.
30 #[serde(default)]
31 pub description: Option<String>,
32}
33
34/// Body for `PATCH /api/v1/environments/{id}`. All fields are optional.
35#[derive(Debug, Serialize, Deserialize, utoipa::ToSchema)]
36pub struct UpdateEnvironmentRequest {
37 /// New display name. Will be re-checked for uniqueness.
38 #[serde(default)]
39 pub name: Option<String>,
40 /// New description. Pass `Some("")` to clear, omit to leave unchanged.
41 #[serde(default)]
42 pub description: Option<String>,
43}