zlayer_types/api/
build.rs1use std::collections::HashMap;
7
8use serde::{Deserialize, Serialize};
9
10#[derive(Debug, Default, Deserialize, utoipa::ToSchema)]
12pub struct BuildRequest {
13 #[serde(default)]
15 pub runtime: Option<String>,
16 #[serde(default)]
18 pub build_args: HashMap<String, String>,
19 #[serde(default)]
21 pub target: Option<String>,
22 #[serde(default)]
24 pub tags: Vec<String>,
25 #[serde(default)]
27 pub no_cache: bool,
28 #[serde(default)]
30 pub push: bool,
31}
32
33#[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)]
35pub struct BuildStatus {
36 pub id: String,
38 pub status: BuildStateEnum,
40 #[serde(skip_serializing_if = "Option::is_none")]
42 pub image_id: Option<String>,
43 #[serde(skip_serializing_if = "Option::is_none")]
45 pub error: Option<String>,
46 pub started_at: String,
48 #[serde(skip_serializing_if = "Option::is_none")]
50 pub completed_at: Option<String>,
51}
52
53#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, utoipa::ToSchema)]
55#[serde(rename_all = "snake_case")]
56pub enum BuildStateEnum {
57 Pending,
59 Running,
61 Complete,
63 Failed,
65}
66
67#[derive(Debug, Serialize, utoipa::ToSchema)]
69pub struct TemplateInfo {
70 pub name: String,
72 pub description: String,
74 pub detect_files: Vec<String>,
76}
77
78#[derive(Debug, Serialize, utoipa::ToSchema)]
80pub struct TriggerBuildResponse {
81 pub build_id: String,
83 pub message: String,
85}
86
87#[derive(Debug, Clone, Serialize)]
89pub struct BuildEventWrapper {
90 #[serde(rename = "type")]
92 pub event_type: String,
93 pub data: serde_json::Value,
95}
96
97#[derive(Debug, Deserialize, utoipa::ToSchema)]
99pub struct BuildRequestWithContext {
100 pub context_path: String,
102 #[serde(default)]
104 pub runtime: Option<String>,
105 #[serde(default)]
107 pub build_args: HashMap<String, String>,
108 #[serde(default)]
110 pub target: Option<String>,
111 #[serde(default)]
113 pub tags: Vec<String>,
114 #[serde(default)]
116 pub no_cache: bool,
117 #[serde(default)]
119 pub push: bool,
120}
121
122impl From<BuildRequestWithContext> for BuildRequest {
123 fn from(req: BuildRequestWithContext) -> Self {
124 Self {
125 runtime: req.runtime,
126 build_args: req.build_args,
127 target: req.target,
128 tags: req.tags,
129 no_cache: req.no_cache,
130 push: req.push,
131 }
132 }
133}