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 #[serde(default)]
35 pub platforms: Vec<String>,
36}
37
38#[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)]
40pub struct BuildStatus {
41 pub id: String,
43 pub status: BuildStateEnum,
45 #[serde(skip_serializing_if = "Option::is_none")]
47 pub image_id: Option<String>,
48 #[serde(skip_serializing_if = "Option::is_none")]
50 pub error: Option<String>,
51 pub started_at: String,
53 #[serde(skip_serializing_if = "Option::is_none")]
55 pub completed_at: Option<String>,
56}
57
58#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, utoipa::ToSchema)]
60#[serde(rename_all = "snake_case")]
61pub enum BuildStateEnum {
62 Pending,
64 Running,
66 Complete,
68 Failed,
70}
71
72#[derive(Debug, Serialize, utoipa::ToSchema)]
74pub struct TemplateInfo {
75 pub name: String,
77 pub description: String,
79 pub detect_files: Vec<String>,
81}
82
83#[derive(Debug, Serialize, utoipa::ToSchema)]
85pub struct TriggerBuildResponse {
86 pub build_id: String,
88 pub message: String,
90}
91
92#[derive(Debug, Clone, Serialize)]
94pub struct BuildEventWrapper {
95 #[serde(rename = "type")]
97 pub event_type: String,
98 pub data: serde_json::Value,
100}
101
102#[derive(Debug, Deserialize, utoipa::ToSchema)]
104pub struct BuildRequestWithContext {
105 pub context_path: String,
107 #[serde(default)]
109 pub runtime: Option<String>,
110 #[serde(default)]
112 pub build_args: HashMap<String, String>,
113 #[serde(default)]
115 pub target: Option<String>,
116 #[serde(default)]
118 pub tags: Vec<String>,
119 #[serde(default)]
121 pub no_cache: bool,
122 #[serde(default)]
124 pub push: bool,
125 #[serde(default)]
129 pub platforms: Vec<String>,
130}
131
132impl From<BuildRequestWithContext> for BuildRequest {
133 fn from(req: BuildRequestWithContext) -> Self {
134 Self {
135 runtime: req.runtime,
136 build_args: req.build_args,
137 target: req.target,
138 tags: req.tags,
139 no_cache: req.no_cache,
140 push: req.push,
141 platforms: req.platforms,
142 }
143 }
144}