-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathjobConfig.example.yaml
More file actions
196 lines (186 loc) · 6.01 KB
/
jobConfig.example.yaml
File metadata and controls
196 lines (186 loc) · 6.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# Example job configurations
# This file collects useful examples. It should be copied to `jobConfig.yaml` and
# customized for your use case. Set JOB_CONFIGURATION_PATH=jobConfig.yaml in your
# environment. See jobConfig.recommended.yaml for a minimal working config file.
# Config version. Free-form, but should be updated when the config changes.
configVersion: v1.0 2024-03-01 6f3f38
# Main array defining job types
# jobType can be arbitrary, but 'archive', 'retrieve' and 'public' are conventional
jobs:
- # jobType can be arbitrary, but 'archive', 'retrieve', and 'public' are conventional
jobType: template_job
# actions for POST requests
create:
# user, @group, #all, #authenticated, #datasetPublic, #datasetAccess, or #datasetOwner
auth: "#authenticated"
actions:
- actionType: log
# actions for PATCH requests
update:
# user, @group, #all, #jobOwnerUser, #jobOwnerGroup
auth: "#jobOwnerUser"
actions:
- actionType: log
- # Request data to be moved into the archive
jobType: archive
create:
# Authorization to create this job type
auth: "#datasetOwner"
# List of actions to run sequentially
actions:
- # Validate properties of datasets listed in jobParams.datasetList
actionType: validate
datasets:
"datasetlifecycle.archivable":
const: true
update:
auth: archivemanager
actions:
- actionType: rabbitmq
exchange: jobs.write
queue: client.jobs.write
key: jobqueue
- # Request data to be moved out of the archive
jobType: retrieve
create:
auth: "#datasetOwner"
actions:
- actionType: validate
datasets:
"datasetlifecycle.retrievable":
const: true
update:
auth: "archivemanager"
actions: []
- # Retrieve published datasets to a public location
jobType: public
create:
auth: "#all"
actions:
- actionType: validate
request:
jobParams.datasetList[*]:
type: object
required:
- pid
- files
datasets:
isPublished:
const: true
update:
auth: "archivemanager"
- jobType: email_demo
create:
auth: admin
actions:
- actionType: validate
request:
jobParams.subject:
type: string
- &email
# Send an email. Requires email to be configured
actionType: email
ignoreErrors: true
to: "{{{ job.contactEmail }}}"
subject: |-
[SciCatLive] {{ default job.jobParams.subject "Job has been updated"}}
bodyTemplateFile: src/common/email-templates/job-template-simplified.html
update:
auth: "#jobOwnerUser"
actions:
- # Only send emails for updates to status 'finished*'
actionType: switch
phase: perform
property: job.statusCode
cases:
- regex: "/^finished/"
actions:
- *email
- actions:
- actionType: log
perform: "(Job {{job.id}} Skip email notification for status {{job.statusCode}}"
- jobType: url_demo
create:
auth: admin
actions:
- # Call a REST endpoint
actionType: url
ignoreErrors: true
url: http://localhost:3000/api/v3/health?jobid={{ job.id }}
method: GET
headers:
accept: application/json
update:
auth: "#jobOwnerUser"
actions: []
- jobType: rabbitmq_demo
create:
auth: admin
actions:
- # Send a RabbitMQ message. Requires RABBITMQ_ENABLED and configured
actionType: rabbitmq
exchange: jobs.write
queue: client.jobs.write
key: jobqueue
update:
auth: "#jobOwnerUser"
actions: []
- jobType: switch_demo
create:
auth: admin
update:
auth: "#jobOwnerUser"
actions:
- # Use 'switch' for conditional actions
actionType: switch
phase: perform
property: request.statusCode
cases:
- # Literal match
match: finishedSuccessful
actions:
- actionType: email
to: "{{{ job.contactEmail }}}"
subject: "[SciCat] Your {{ job.type }} job was successful!"
bodyTemplateFile: retrieve-success.html
- # regex match. Requires a string property
regex: /unsuccessful|error/i
actions:
- actionType: email
to: "{{{ job.contactEmail }}}"
subject: "[SciCat] Your {{ job.type }} job has state {{ job.statusCode }}"
bodyTemplateFile: retrieve-failure.html
- # Apply a JSON Schema
schema:
type: "number"
actions:
- actionType: log
validate: "Error. statusCode ({{ job.statusCode }}) should be a string!"
- # default condition
actions:
- # Raise an HTTP exception
actionType: error
message: "No matching case found for statusCode {{ job.statusCode }}"
- jobType: validate_demo
create:
auth: '#datasetAccess'
actions:
- actionType: validate
request: # validate properties of the request body
jobParams.requiredParam:
type: string
jobParams.arrayOfStrings:
type: array
items:
type: string
datasets: # validate properties of datasets listed in jobParams.datasetList
"datasetlifecycle.archivable":
const: true
update:
auth: "#jobOwnerUser"
actions:
- actionType: validate
request:
jobResultObject.response:
type: string
# No `datasets` validation for the update operation