Skip to content

Update docs for scicatproject/scicat-backend-next#1855 #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions Development/v4.x/backend/configuration/jobconfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,19 @@ for instance, `"#datasetOwner"` requires that a dataset be passed.
> services to external users. Please consider the security model carefully when
> configuring jobs.

### Templates

Many actions can be configured using templates, which get filled when the action runs.
Template strings use [Handlebars](https://handlebarsjs.com/) syntax. The following
top-level variables are availabe in the handlebars context:

| Top-level variable | Type | Examples | Description |
|---|---|---|---|
| `request` | `CreateJobDto` or<br/>`UpdateJobDto` | `{{request.type}}`<br/>`{{request.jobParams}}` | HTTP Request body |
| `job` | `JobClass` | `{{job.id}}` | The job, as stored in the database. Not available for validate actions. |
| `datasets` | `DatasetClass[]` | `{{#each datasets}}{{pid}}{{/each}}` | All datasets referenced in `job.jobParams.datasetsList`. |
| `env` | `object` | `{{env.SECRET_TOKEN}}` | Access environmental variables |

### Actions Configuration

The following actions are built-in to SciCat and can be included in the `actions` array.
Expand All @@ -145,7 +158,7 @@ For example:

```yaml
- actionType: url
url: http://localhost:3000/api/v3/health?jobid={{id}}
url: http://localhost:3000/api/v3/health?jobid={{request.id}}
method: GET
headers:
accept: application/json
Expand Down Expand Up @@ -212,8 +225,8 @@ jobs:
jobParams.subject:
type: string
- actionType: email
to: "{{contactEmail}}"
subject: "[SciCat] {{jobParams.subject}}"
to: "{{job.contactEmail}}"
subject: "[SciCat] {{job.jobParams.subject}}"
bodyTemplate: demo_email.html
update:
auth: admin
Expand Down Expand Up @@ -344,9 +357,9 @@ Example:

```yaml
- actionType: email
to: "{{contactEmail}}"
to: "{{job.contactEmail}}"
from: "[email protected]",
subject: "[SciCat] Your {{type}} job was submitted successfully."
subject: "[SciCat] Your {{job.type}} job was submitted successfully."
bodyTemplateFile: "path/to/job-template-file.html"
```

Expand All @@ -368,7 +381,7 @@ You can create your own template for the email's body, which should be a valid h
</head>
<body>
<p>
Your {{type}} job with id {{id}} has been submitted ...
Your {{job.type}} job with id {{job.id}} has been submitted ...
</p>
</body>
</html>
Expand Down