1 | |
2 | |
3 | * Create a job |
4 | * |
5 | */ |
6 | export async function main(auth: RT.Qovery, environmentId: string, body: Body) { |
7 | const url = new URL(`https://api.qovery.com/environment/${environmentId}/job`) |
8 |
|
9 | const response = await fetch(url, { |
10 | method: 'POST', |
11 | headers: { |
12 | 'Content-Type': 'application/json', |
13 | Authorization: 'Token ' + auth.apiKey |
14 | }, |
15 | body: JSON.stringify(body) |
16 | }) |
17 | if (!response.ok) { |
18 | const text = await response.text() |
19 | throw new Error(`${response.status} ${text}`) |
20 | } |
21 | return await response.json() |
22 | } |
23 |
|
24 | |
25 | |
26 | * This file was automatically generated by json-schema-to-typescript. |
27 | * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, |
28 | * and run json-schema-to-typescript to regenerate this file. |
29 | */ |
30 |
|
31 | export type Body = { |
32 | |
33 | * name is case insensitive |
34 | */ |
35 | name: string |
36 | description?: string |
37 | |
38 | * unit is millicores (m). 1000m = 1 cpu |
39 | */ |
40 | cpu?: number |
41 | |
42 | * unit is MB. 1024 MB = 1GB |
43 | */ |
44 | memory?: number |
45 | gpu?: number |
46 | |
47 | * Maximum number of restart allowed before the job is considered as failed |
48 | * 0 means that no restart/crash of the job is allowed |
49 | * |
50 | */ |
51 | max_nb_restart?: number |
52 | |
53 | * Maximum number of seconds allowed for the job to run before killing it and mark it as failed |
54 | * |
55 | */ |
56 | max_duration_seconds?: number |
57 | |
58 | * Indicates if the 'environment preview option' is enabled for this container. |
59 | * If enabled, a preview environment will be automatically cloned when `/preview` endpoint is called. |
60 | * If not specified, it takes the value of the `auto_preview` property from the associated environment. |
61 | * |
62 | */ |
63 | auto_preview?: boolean |
64 | |
65 | * Port where to run readiness and liveliness probes checks. The port will not be exposed externally |
66 | */ |
67 | port?: number |
68 | source?: { |
69 | image?: { |
70 | |
71 | * The image name pattern differs according to chosen container registry provider: |
72 | * * `ECR`: `repository` |
73 | * * `SCALEWAY_CR`: `namespace/image` |
74 | * * `DOCKER_HUB`: `image` or `repository/image` |
75 | * * `PUBLIC_ECR`: `registry_alias/repository` |
76 | * |
77 | */ |
78 | image_name?: string |
79 | |
80 | * tag of the image container |
81 | */ |
82 | tag?: string |
83 | |
84 | * tag of the image container |
85 | */ |
86 | registry_id?: string |
87 | [k: string]: unknown |
88 | } |
89 | docker?: { |
90 | git_repository?: { |
91 | |
92 | * application git repository URL |
93 | */ |
94 | url: string |
95 | |
96 | * Name of the branch to use. This is optional |
97 | * If not specified, then the branch used is the `main` or `master` one |
98 | * |
99 | */ |
100 | branch?: string |
101 | |
102 | * indicates the root path of the application. |
103 | */ |
104 | root_path?: string |
105 | |
106 | * The git token id on Qovery side |
107 | */ |
108 | git_token_id?: string |
109 | provider: 'BITBUCKET' | 'GITHUB' | 'GITLAB' |
110 | [k: string]: unknown |
111 | } |
112 | |
113 | * The path of the associated Dockerfile. Only if you are using build_mode = DOCKER |
114 | */ |
115 | dockerfile_path?: string |
116 | |
117 | * The content of your dockerfile if it is not stored inside your git repository |
118 | */ |
119 | dockerfile_raw?: string |
120 | |
121 | * The target build stage in the Dockerfile to build |
122 | */ |
123 | docker_target_build_stage?: string |
124 | [k: string]: unknown |
125 | } |
126 | [k: string]: unknown |
127 | } |
128 | healthchecks: { |
129 | readiness_probe?: { |
130 | type?: { |
131 | tcp?: { |
132 | port?: number |
133 | host?: string |
134 | [k: string]: unknown |
135 | } |
136 | http?: { |
137 | path?: string |
138 | scheme?: string |
139 | port?: number |
140 | [k: string]: unknown |
141 | } |
142 | exec?: { |
143 | command?: string[] |
144 | [k: string]: unknown |
145 | } |
146 | grpc?: { |
147 | service?: string |
148 | port?: number |
149 | [k: string]: unknown |
150 | } |
151 | [k: string]: unknown |
152 | } |
153 | initial_delay_seconds?: number |
154 | period_seconds?: number |
155 | timeout_seconds?: number |
156 | success_threshold?: number |
157 | failure_threshold?: number |
158 | [k: string]: unknown |
159 | } |
160 | liveness_probe?: { |
161 | type?: { |
162 | tcp?: { |
163 | port?: number |
164 | host?: string |
165 | [k: string]: unknown |
166 | } |
167 | http?: { |
168 | path?: string |
169 | scheme?: string |
170 | port?: number |
171 | [k: string]: unknown |
172 | } |
173 | exec?: { |
174 | command?: string[] |
175 | [k: string]: unknown |
176 | } |
177 | grpc?: { |
178 | service?: string |
179 | port?: number |
180 | [k: string]: unknown |
181 | } |
182 | [k: string]: unknown |
183 | } |
184 | initial_delay_seconds?: number |
185 | period_seconds?: number |
186 | timeout_seconds?: number |
187 | success_threshold?: number |
188 | failure_threshold?: number |
189 | [k: string]: unknown |
190 | } |
191 | [k: string]: unknown |
192 | } |
193 | |
194 | * If you want to define a Cron job, only the `cronjob` property must be filled |
195 | * A Lifecycle job should contain at least one property `on_XXX` among the 3 properties: `on_start`, `on_stop`, `on_delete` |
196 | * |
197 | */ |
198 | schedule?: { |
199 | on_start?: { |
200 | arguments?: string[] |
201 | |
202 | * optional entrypoint when launching container |
203 | */ |
204 | entrypoint?: string |
205 | [k: string]: unknown |
206 | } |
207 | on_stop?: { |
208 | arguments?: string[] |
209 | |
210 | * optional entrypoint when launching container |
211 | */ |
212 | entrypoint?: string |
213 | [k: string]: unknown |
214 | } |
215 | on_delete?: { |
216 | arguments?: string[] |
217 | |
218 | * optional entrypoint when launching container |
219 | */ |
220 | entrypoint?: string |
221 | [k: string]: unknown |
222 | } |
223 | cronjob?: { |
224 | arguments?: string[] |
225 | |
226 | * optional entrypoint when launching container |
227 | */ |
228 | entrypoint?: string |
229 | |
230 | * Specify a timezone identifier to run the schedule at. By default Etc/UTC |
231 | */ |
232 | timezone?: string |
233 | |
234 | * Can only be set if the event is CRON. |
235 | * Represent the cron format for the job schedule without seconds. |
236 | * For example: `* * * * *` represent the cron to launch the job every minute. |
237 | * See https://crontab.guru/ to WISIWIG interface. |
238 | * Timezone is UTC |
239 | * |
240 | */ |
241 | scheduled_at: string |
242 | [k: string]: unknown |
243 | } |
244 | lifecycle_type?: JobLifecycleTypeEnum |
245 | [k: string]: unknown |
246 | } |
247 | |
248 | * Specify if the job will be automatically updated after receiving a new image tag or a new commit according to the source type. |
249 | * The new image tag shall be communicated via the "Auto Deploy job" endpoint https://api-doc.qovery.com/#tag/Jobs/operation/autoDeployJobEnvironments |
250 | * |
251 | */ |
252 | auto_deploy?: boolean |
253 | annotations_groups?: { |
254 | id: string |
255 | [k: string]: unknown |
256 | }[] |
257 | labels_groups?: { |
258 | id: string |
259 | [k: string]: unknown |
260 | }[] |
261 | |
262 | * Icon URI representing the job. |
263 | */ |
264 | icon_uri?: string |
265 | [k: string]: unknown |
266 | } |
267 | export type JobLifecycleTypeEnum = 'GENERIC' | 'TERRAFORM' | 'CLOUDFORMATION' |
268 |
|