@@ -129,6 +129,19 @@ for instance, `"#datasetOwner"` requires that a dataset be passed.
129
129
> services to external users. Please consider the security model carefully when
130
130
> configuring jobs.
131
131
132
+ # ## Templates
133
+
134
+ Many actions can be configured using templates, which get filled when the action runs.
135
+ Template strings use [Handlebars](https://handlebarsjs.com/) syntax. The following
136
+ top-level variables are availabe in the handlebars context :
137
+
138
+ | Top-level variable | Type | Examples | Description |
139
+ |---|---|---|---|
140
+ | `request` | `CreateJobDto` or<br/>`UpdateJobDto` | `{{request.type}}`<br/>`{{request.jobParams}}` | HTTP Request body |
141
+ | `job` | `JobClass` | `{{job.id}}` | The job, as stored in the database. Not available for validate actions. |
142
+ | `datasets` | `DatasetClass[]` | `{{#each datasets}}{{pid}}{{/each}}` | All datasets referenced in `job.jobParams.datasetsList`. |
143
+ | `env` | `object` | `{{env.SECRET_TOKEN}}` | Access environmental variables |
144
+
132
145
# ## Actions Configuration
133
146
134
147
The following actions are built-in to SciCat and can be included in the `actions` array.
@@ -145,7 +158,7 @@ For example:
145
158
146
159
` ` ` yaml
147
160
- actionType: url
148
- url: http://localhost:3000/api/v3/health?jobid={{id}}
161
+ url: http://localhost:3000/api/v3/health?jobid={{request. id}}
149
162
method: GET
150
163
headers:
151
164
accept: application/json
@@ -212,8 +225,8 @@ jobs:
212
225
jobParams.subject:
213
226
type: string
214
227
- actionType: email
215
- to: "{{contactEmail}}"
216
- subject: "[SciCat] {{jobParams.subject}}"
228
+ to: "{{job. contactEmail}}"
229
+ subject: "[SciCat] {{job. jobParams.subject}}"
217
230
bodyTemplate: demo_email.html
218
231
update:
219
232
auth: admin
@@ -344,9 +357,9 @@ Example:
344
357
345
358
` ` ` yaml
346
359
- actionType: email
347
- to: "{{contactEmail}}"
360
+ to: "{{job. contactEmail}}"
348
361
349
- subject: "[SciCat] Your {{type}} job was submitted successfully."
362
+ subject: "[SciCat] Your {{job. type}} job was submitted successfully."
350
363
bodyTemplateFile: "path/to/job-template-file.html"
351
364
` ` `
352
365
@@ -368,7 +381,7 @@ You can create your own template for the email's body, which should be a valid h
368
381
</head>
369
382
<body>
370
383
<p>
371
- Your {{type}} job with id {{id}} has been submitted ...
384
+ Your {{job. type}} job with id {{job. id}} has been submitted ...
372
385
</p>
373
386
</body>
374
387
</html>
0 commit comments