Skip to content

Commit 1ee6822

Browse files
authored
Return owner in batch actions API response (#686)
1 parent 00acdaf commit 1ee6822

3 files changed

Lines changed: 10 additions & 0 deletions

File tree

broker/oapi/open-api.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,6 +1176,9 @@ components:
11761176
id:
11771177
type: string
11781178
description: Unique identifier of the batch action
1179+
owner:
1180+
type: string
1181+
description: Symbol of the institution that owns the batch action. Empty for unrestricted actions created with master access.
11791182
schedule:
11801183
type: string
11811184
description: RRULE schedule expression, e.g. "FREQ=WEEKLY;BYDAY=MO;BYHOUR=6;BYMINUTE=0" (every Monday at 06:00)
@@ -1211,6 +1214,7 @@ components:
12111214
description: Link to execution events for this batch action
12121215
required:
12131216
- id
1217+
- owner
12141218
- schedule
12151219
- actionName
12161220
- createdAt

broker/scheduler/api/api_handler.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ func toBatchAction(r *http.Request, task sched_db.ScheduledTask) schedoapi.Batch
349349
active := task.Status != sched_db.ScheduledTaskStatusStopped
350350
resp := schedoapi.BatchAction{
351351
Id: task.ID,
352+
Owner: task.Owner,
352353
Schedule: task.Schedule,
353354
ActionName: schedoapi.BatchActionName(actionData.ActionName),
354355
CreatedAt: task.CreatedAt.Time,

broker/scheduler/api/api_handler_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ func TestGetBatchActions_OK(t *testing.T) {
152152
assert.Equal(t, int64(2), resp.About.Count)
153153
assert.Len(t, resp.Items, 2)
154154
assert.Equal(t, "task-1", resp.Items[0].Id)
155+
assert.Equal(t, testSymbol, resp.Items[0].Owner)
155156
assert.Equal(t, "https://example.com/batch_actions/task-1/events", resp.Items[0].EventsLink)
156157
assert.Equal(t, schedoapi.EmailPullslips, resp.Items[0].ActionName)
157158
assert.Equal(t, "title=test", resp.Items[0].BatchQuery)
@@ -360,6 +361,7 @@ func TestPostBatchActions_OK(t *testing.T) {
360361
var resp schedoapi.BatchAction
361362
assert.NoError(t, json.Unmarshal(rr.Body.Bytes(), &resp))
362363
assert.NotEmpty(t, resp.Id)
364+
assert.Equal(t, testSymbol, resp.Owner)
363365
assert.Equal(t, validRrule, resp.Schedule)
364366
assert.Equal(t, "title=test", resp.BatchQuery)
365367
assert.True(t, resp.Active)
@@ -427,6 +429,7 @@ func TestPostBatchActions_MasterWithoutSymbolCreatesUnrestrictedAction(t *testin
427429
var resp schedoapi.BatchAction
428430
assert.NoError(t, json.Unmarshal(rr.Body.Bytes(), &resp))
429431
assert.Equal(t, schedoapi.RequestAging, resp.ActionName)
432+
assert.Empty(t, resp.Owner)
430433
repo.AssertExpectations(t)
431434
}
432435

@@ -555,6 +558,7 @@ func TestGetBatchActionsId_OK(t *testing.T) {
555558
var resp schedoapi.BatchAction
556559
assert.NoError(t, json.Unmarshal(rr.Body.Bytes(), &resp))
557560
assert.Equal(t, "task-1", resp.Id)
561+
assert.Equal(t, testSymbol, resp.Owner)
558562
assert.Equal(t, "title=test", resp.BatchQuery)
559563
assert.True(t, resp.Active)
560564
assert.NotNil(t, resp.UpdatedAt)
@@ -614,6 +618,7 @@ func TestPutBatchActionsId_OK_RecomputesRunAtAndPersistsActionData(t *testing.T)
614618
assert.Equal(t, http.StatusOK, rr.Code)
615619
var resp schedoapi.BatchAction
616620
assert.NoError(t, json.Unmarshal(rr.Body.Bytes(), &resp))
621+
assert.Equal(t, testSymbol, resp.Owner)
617622
assert.Equal(t, newSchedule, resp.Schedule)
618623
assert.Equal(t, "author=doe", resp.BatchQuery)
619624
assert.NotNil(t, resp.NextRun)

0 commit comments

Comments
 (0)