@@ -129,6 +129,22 @@ 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
+
145
+ Environmental variables are particularly useful for secrets that should not be stored in
146
+ the config file.
147
+
132
148
# ## Actions Configuration
133
149
134
150
The following actions are built-in to SciCat and can be included in the `actions` array.
@@ -145,10 +161,11 @@ For example:
145
161
146
162
` ` ` yaml
147
163
- actionType: url
148
- url: http://localhost:3000/api/v3/health?jobid={{id}}
164
+ url: http://localhost:3000/api/v3/health?jobid={{request. id}}
149
165
method: GET
150
166
headers:
151
167
accept: application/json
168
+ Authorization: "Bearer {{env.ARCHIVER_AUTH_TOKEN}}",
152
169
` ` `
153
170
154
171
Where :
@@ -158,6 +175,9 @@ Where:
158
175
- `headers` (optional) : An object containing HTTP headers to be included in the request.
159
176
- `body` (optional) : The body of the request, for methods like "POST" or "PUT".
160
177
178
+ It is recommended that authorization tokens be stored as environmental variables rather
179
+ than included directly in the jobConfig.yaml file.
180
+
161
181
# ### Validate
162
182
163
183
The `validate` action is used to validate requests to the job endpoints. It is used to
@@ -212,8 +232,8 @@ jobs:
212
232
jobParams.subject:
213
233
type: string
214
234
- actionType: email
215
- to: "{{contactEmail}}"
216
- subject: "[SciCat] {{jobParams.subject}}"
235
+ to: "{{job. contactEmail}}"
236
+ subject: "[SciCat] {{job. jobParams.subject}}"
217
237
bodyTemplate: demo_email.html
218
238
update:
219
239
auth: admin
@@ -344,9 +364,9 @@ Example:
344
364
345
365
` ` ` yaml
346
366
- actionType: email
347
- to: "{{contactEmail}}"
367
+ to: "{{job. contactEmail}}"
348
368
349
- subject: "[SciCat] Your {{type}} job was submitted successfully."
369
+ subject: "[SciCat] Your {{job. type}} job was submitted successfully."
350
370
bodyTemplateFile: "path/to/job-template-file.html"
351
371
` ` `
352
372
@@ -368,7 +388,7 @@ You can create your own template for the email's body, which should be a valid h
368
388
</head>
369
389
<body>
370
390
<p>
371
- Your {{type}} job with id {{id}} has been submitted ...
391
+ Your {{job. type}} job with id {{job. id}} has been submitted ...
372
392
</p>
373
393
</body>
374
394
</html>
0 commit comments