@@ -129,6 +129,22 @@ for instance, `"#datasetOwner"` requires that a dataset be passed.
129129> services to external users. Please consider the security model carefully when
130130> configuring jobs.
131131
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+
132148# ## Actions Configuration
133149
134150The following actions are built-in to SciCat and can be included in the `actions` array.
@@ -145,10 +161,11 @@ For example:
145161
146162` ` ` yaml
147163- actionType: url
148- url: http://localhost:3000/api/v3/health?jobid={{id}}
164+ url: http://localhost:3000/api/v3/health?jobid={{request. id}}
149165 method: GET
150166 headers:
151167 accept: application/json
168+ Authorization: "Bearer {{env.ARCHIVER_AUTH_TOKEN}}",
152169` ` `
153170
154171Where :
@@ -158,6 +175,9 @@ Where:
158175- `headers` (optional) : An object containing HTTP headers to be included in the request.
159176- `body` (optional) : The body of the request, for methods like "POST" or "PUT".
160177
178+ It is recommended that authorization tokens be stored as environmental variables rather
179+ than included directly in the jobConfig.yaml file.
180+
161181# ### Validate
162182
163183The `validate` action is used to validate requests to the job endpoints. It is used to
@@ -212,8 +232,8 @@ jobs:
212232 jobParams.subject:
213233 type: string
214234 - actionType: email
215- to: "{{contactEmail}}"
216- subject: "[SciCat] {{jobParams.subject}}"
235+ to: "{{job. contactEmail}}"
236+ subject: "[SciCat] {{job. jobParams.subject}}"
217237 bodyTemplate: demo_email.html
218238 update:
219239 auth: admin
@@ -344,9 +364,9 @@ Example:
344364
345365` ` ` yaml
346366- actionType: email
347- to: "{{contactEmail}}"
367+ to: "{{job. contactEmail}}"
348368349- subject: "[SciCat] Your {{type}} job was submitted successfully."
369+ subject: "[SciCat] Your {{job. type}} job was submitted successfully."
350370 bodyTemplateFile: "path/to/job-template-file.html"
351371` ` `
352372
@@ -368,7 +388,7 @@ You can create your own template for the email's body, which should be a valid h
368388</head>
369389 <body>
370390 <p>
371- Your {{type}} job with id {{id}} has been submitted ...
391+ Your {{job. type}} job with id {{job. id}} has been submitted ...
372392 </p>
373393 </body>
374394</html>
0 commit comments