fix(http): use task id from path, not params
Squashed commit - includes fixes for comments on PR.pull/10616/head
parent
d756083890
commit
44df62891c
|
@ -374,11 +374,13 @@ paths:
|
|||
name: afterTime
|
||||
schema:
|
||||
type: string
|
||||
format: date-time
|
||||
description: filter runs to those queued after this time
|
||||
- in: query
|
||||
name: beforeTime
|
||||
schema:
|
||||
type: string
|
||||
format: date-time
|
||||
description: filter runs to those queued before this time
|
||||
responses:
|
||||
'200':
|
||||
|
@ -474,11 +476,6 @@ paths:
|
|||
type: string
|
||||
required: true
|
||||
description: ID of task to get logs for
|
||||
- in: query
|
||||
name: run
|
||||
schema:
|
||||
type: string
|
||||
description: Filters logs to a specific run.
|
||||
responses:
|
||||
'200':
|
||||
description: all logs for a task
|
||||
|
@ -491,6 +488,48 @@ paths:
|
|||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/Link"
|
||||
default:
|
||||
description: unexpected error
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Error"
|
||||
'/tasks/{taskId}/runs/{runId}/logs':
|
||||
get:
|
||||
tags:
|
||||
- Tasks
|
||||
summary: Retrieve all logs for a run
|
||||
parameters:
|
||||
- in: path
|
||||
name: taskId
|
||||
schema:
|
||||
type: string
|
||||
required: true
|
||||
description: ID of task to get logs for.
|
||||
- in: path
|
||||
name: runId
|
||||
schema:
|
||||
type: string
|
||||
required: true
|
||||
description: ID of run to get logs for.
|
||||
responses:
|
||||
'200':
|
||||
description: all logs for a run
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
logs:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/Link"
|
||||
default:
|
||||
description: unexpected error
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Error"
|
||||
/users:
|
||||
get:
|
||||
tags:
|
||||
|
@ -655,15 +694,15 @@ components:
|
|||
queuedAt:
|
||||
readOnly: true
|
||||
type: string
|
||||
format: dateTime
|
||||
format: date-time
|
||||
startTime:
|
||||
readOnly: true
|
||||
type: string
|
||||
format: dateTime
|
||||
format: date-time
|
||||
endTime:
|
||||
readOnly: true
|
||||
type: string
|
||||
format: dateTime
|
||||
format: date-time
|
||||
error:
|
||||
$ref: "#/components/schemas/Error"
|
||||
log:
|
||||
|
@ -688,6 +727,7 @@ components:
|
|||
]
|
||||
owner:
|
||||
$ref: "#/components/schemas/User"
|
||||
<<<<<<< HEAD
|
||||
flux:
|
||||
description: The Flux script to run for this task.
|
||||
type: string
|
||||
|
@ -698,6 +738,18 @@ components:
|
|||
cron:
|
||||
readOnly: true
|
||||
description: A task repetition schedule in the form '* * * * * *'; parsed from Flux.
|
||||
=======
|
||||
query:
|
||||
description: The ifql query to run for this task.
|
||||
type: string
|
||||
every:
|
||||
readOnly: true
|
||||
description: A simple task repetition schedule; parsed from query.
|
||||
type: string
|
||||
cron:
|
||||
readOnly: true
|
||||
description: A task repetition schedule in the form '* * * * * *'; parsed from query.
|
||||
>>>>>>> update swagger
|
||||
type: string
|
||||
last:
|
||||
$ref: "#/components/schemas/Run"
|
||||
|
|
|
@ -199,7 +199,7 @@ func decodeUpdateTaskRequest(ctx context.Context, r *http.Request) (*updateTaskR
|
|||
params := httprouter.ParamsFromContext(ctx)
|
||||
id := params.ByName("tid")
|
||||
if id == "" {
|
||||
return nil, kerrors.InvalidDataf("url missing id")
|
||||
return nil, kerrors.InvalidDataf("you must provide a task ID")
|
||||
}
|
||||
|
||||
var i platform.ID
|
||||
|
@ -243,7 +243,7 @@ func decodeDeleteTaskRequest(ctx context.Context, r *http.Request) (*deleteTaskR
|
|||
params := httprouter.ParamsFromContext(ctx)
|
||||
id := params.ByName("tid")
|
||||
if id == "" {
|
||||
return nil, kerrors.InvalidDataf("url missing id")
|
||||
return nil, kerrors.InvalidDataf("you must provide a task ID")
|
||||
}
|
||||
|
||||
var i platform.ID
|
||||
|
@ -282,16 +282,20 @@ type getLogsRequest struct {
|
|||
}
|
||||
|
||||
func decodeGetLogsRequest(ctx context.Context, r *http.Request) (*getLogsRequest, error) {
|
||||
qp := r.URL.Query()
|
||||
req := &getLogsRequest{}
|
||||
|
||||
if id := qp.Get("task"); id != "" {
|
||||
req.filter.Task = &platform.ID{}
|
||||
if err := req.filter.Task.DecodeFromString(id); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
params := httprouter.ParamsFromContext(ctx)
|
||||
id := params.ByName("tid")
|
||||
if id == "" {
|
||||
return nil, kerrors.InvalidDataf("you must provide a task ID")
|
||||
}
|
||||
|
||||
req := &getLogsRequest{}
|
||||
req.filter.Task = &platform.ID{}
|
||||
if err := req.filter.Task.DecodeFromString(id); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
qp := r.URL.Query()
|
||||
|
||||
if id := qp.Get("run"); id != "" {
|
||||
req.filter.Run = &platform.ID{}
|
||||
if err := req.filter.Run.DecodeFromString(id); err != nil {
|
||||
|
@ -328,16 +332,20 @@ type getRunsRequest struct {
|
|||
}
|
||||
|
||||
func decodeGetRunsRequest(ctx context.Context, r *http.Request) (*getRunsRequest, error) {
|
||||
qp := r.URL.Query()
|
||||
req := &getRunsRequest{}
|
||||
|
||||
if id := qp.Get("task"); id != "" {
|
||||
req.filter.Task = &platform.ID{}
|
||||
if err := req.filter.Task.DecodeFromString(id); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
params := httprouter.ParamsFromContext(ctx)
|
||||
id := params.ByName("tid")
|
||||
if id == "" {
|
||||
return nil, kerrors.InvalidDataf("you must provide a task ID")
|
||||
}
|
||||
|
||||
req := &getRunsRequest{}
|
||||
req.filter.Task = &platform.ID{}
|
||||
if err := req.filter.Task.DecodeFromString(id); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
qp := r.URL.Query()
|
||||
|
||||
if id := qp.Get("after"); id != "" {
|
||||
req.filter.After = &platform.ID{}
|
||||
if err := req.filter.After.DecodeFromString(id); err != nil {
|
||||
|
|
6
task.go
6
task.go
|
@ -8,7 +8,7 @@ type Task struct {
|
|||
Name string `json:"name"`
|
||||
Status string `json:"status"`
|
||||
Owner User `json:"owner"`
|
||||
IFQL string `json:"ifql"`
|
||||
Flux string `json:"flux"`
|
||||
Every string `json:"every,omitempty"`
|
||||
Cron string `json:"cron,omitempty"`
|
||||
Last Run `json:"last,omitempty"`
|
||||
|
@ -29,6 +29,7 @@ type Log string
|
|||
|
||||
// TaskService represents a service for managing one-off and recurring tasks.
|
||||
type TaskService interface {
|
||||
// Returns a single task
|
||||
FindTaskByID(ctx context.Context, id ID) (*Task, error)
|
||||
|
||||
// Returns a list of tasks that match a filter (limit 100) and the total count
|
||||
|
@ -50,6 +51,7 @@ type TaskService interface {
|
|||
// Returns a list of runs that match a filter and the total count of returned runs.
|
||||
FindRuns(ctx context.Context, filter RunFilter) ([]*Run, int, error)
|
||||
|
||||
// Returns a single run
|
||||
FindRunByID(ctx context.Context, id ID) (*Run, error)
|
||||
|
||||
// Creates and returns a new run (which is a retry of another run)
|
||||
|
@ -58,7 +60,7 @@ type TaskService interface {
|
|||
|
||||
// TaskUpdate represents updates to a task
|
||||
type TaskUpdate struct {
|
||||
Name *string `json:"name"`
|
||||
Flux *string `json:"flux"`
|
||||
}
|
||||
|
||||
// TaskFilter represents a set of filters that restrict the returned results
|
||||
|
|
Loading…
Reference in New Issue