Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions api-contracts/openapi/components/schemas/_index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,8 @@ V2TaskSummaryList:
$ref: "./v2/task.yaml#/V2TaskSummaryList"
V2TaskSummary:
$ref: "./v2/task.yaml#/V2TaskSummary"
V2DagChildren:
$ref: "./v2/task.yaml#/V2DagChildren"
V2Task:
$ref: "./v2/task.yaml#/V2Task"
V2TaskEventList:
Expand All @@ -310,3 +312,7 @@ V2TaskPointMetric:
$ref: "./v2/task.yaml#/V2TaskPointMetric"
V2TaskPointMetrics:
$ref: "./v2/task.yaml#/V2TaskPointMetrics"
V2WorkflowRun:
$ref: "./v2/workflow_run.yaml#/V2WorkflowRun"
V2WorkflowRunList:
$ref: "./v2/workflow_run.yaml#/V2WorkflowRunList"
19 changes: 7 additions & 12 deletions api-contracts/openapi/components/schemas/v2/task.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
V2TaskSummarySingle:
V2TaskSummary:
properties:
metadata:
$ref: ".././metadata.yaml#/APIResourceMeta"
Expand Down Expand Up @@ -55,21 +55,16 @@ V2TaskSummarySingle:
- workflowId
- output

V2TaskSummary:
V2DagChildren:
type: object
properties:
metadata:
$ref: ".././metadata.yaml#/APIResourceMeta"
parent:
$ref: "#/V2TaskSummarySingle"
dagId:
type: string
format: uuid
children:
type: array
items:
$ref: "#/V2TaskSummarySingle"
description: The list of child tasks
required:
- metadata
- parent
- children
$ref: "#/V2TaskSummary"

V2TaskSummaryList:
type: object
Expand Down
61 changes: 61 additions & 0 deletions api-contracts/openapi/components/schemas/v2/workflow_run.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
V2WorkflowRun:
properties:
metadata:
$ref: ".././metadata.yaml#/APIResourceMeta"
status:
$ref: "./task.yaml#/V2TaskStatus"
startedAt:
type: string
format: date-time
description: The timestamp the task run started.
finishedAt:
type: string
format: date-time
description: The timestamp the task run finished.
duration:
type: integer
description: The duration of the task run, in milliseconds.
tenantId:
type: string
description: The ID of the tenant.
example: bb214807-246e-43a5-a25d-41761d1cff9e
minLength: 36
maxLength: 36
format: uuid
additionalMetadata:
type: object
description: Additional metadata for the task run.
displayName:
type: string
description: The display name of the task run.
workflowId:
type: string
format: uuid
output:
type: object
description: The output of the task run (for the latest run)
errorMessage:
type: string
description: The error message of the task run (for the latest run)
required:
- metadata
- id
- status
- tenantId
- displayName
- workflowId
- output

V2WorkflowRunList:
type: object
properties:
pagination:
$ref: ".././metadata.yaml#/PaginationResponse"
rows:
type: array
items:
$ref: "#/V2WorkflowRun"
description: The list of workflow runs
required:
- pagination
- rows
4 changes: 4 additions & 0 deletions api-contracts/openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ paths:
$ref: "./paths/v2/tasks/tasks.yaml#/getTask"
/api/v2/tasks/{task}/task-events:
$ref: "./paths/v2/tasks/tasks.yaml#/listTaskEvents"
/api/v2/dags/tasks:
$ref: "./paths/v2/tasks/tasks.yaml#/listTasksByDAGIds"
/api/v2/tenants/{tenant}/workflow-runs:
$ref: "./paths/v2/workflow-runs/workflow_run.yaml#/listWorkflowRuns"
/api/v2/tenants/{tenant}/task-metrics:
$ref: "./paths/v2/tasks/tasks.yaml#/getTaskStatusMetrics"
/api/v2/tenants/{tenant}/task-point-metrics:
Expand Down
51 changes: 51 additions & 0 deletions api-contracts/openapi/paths/v2/tasks/tasks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,57 @@ listTasks:
tags:
- Task

listTasksByDAGIds:
get:
description: Lists all tasks that belong a specific list of dags
operationId: v2-dag:list:tasks
parameters:
- description: The external id of the DAG
in: query
name: dag_ids
required: true
schema:
type: array
items:
type: string
format: uuid
minLength: 36
maxLength: 36
- description: The tenant id
in: query
name: tenant
required: true
schema:
type: string
format: uuid
minLength: 36
maxLength: 36
responses:
"200":
content:
application/json:
schema:
type: array
items:
$ref: "../../../components/schemas/_index.yaml#/V2DagChildren"
description: The list of tasks
description: Successfully listed the tasks
"400":
content:
application/json:
schema:
$ref: "../../../components/schemas/_index.yaml#/APIErrors"
description: A malformed or bad request
"403":
content:
application/json:
schema:
$ref: "../../../components/schemas/_index.yaml#/APIErrors"
description: Forbidden
summary: List tasks
tags:
- Task

getTask:
get:
x-resources: ["tenant", "task"]
Expand Down
92 changes: 92 additions & 0 deletions api-contracts/openapi/paths/v2/workflow-runs/workflow_run.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
listWorkflowRuns:
get:
x-resources: ["tenant"]
description: Lists workflow runs for a tenant.
operationId: v2-workflow-run:list
parameters:
- description: The tenant id
in: path
name: tenant
required: true
schema:
type: string
format: uuid
minLength: 36
maxLength: 36
- description: The number to skip
in: query
name: offset
required: false
schema:
type: integer
format: int64
- description: The number to limit by
in: query
name: limit
required: false
schema:
type: integer
format: int64
- description: A list of statuses to filter by
in: query
name: statuses
required: false
schema:
type: array
items:
$ref: "../../../components/schemas/_index.yaml#/V2TaskStatus"
- description: The earliest date to filter by
in: query
name: since
required: true
schema:
type: string
format: date-time
- description: The latest date to filter by
in: query
name: until
required: false
schema:
type: string
format: date-time
- description: Additional metadata k-v pairs to filter by
in: query
name: additional_metadata
required: false
schema:
type: array
items:
type: string
- description: The workflow ids to find runs for
in: query
name: workflow_ids
required: false
schema:
type: array
items:
type: string
format: uuid
minLength: 36
maxLength: 36
responses:
"200":
content:
application/json:
schema:
$ref: "../../../components/schemas/_index.yaml#/V2WorkflowRunList"
description: Successfully listed the tasks
"400":
content:
application/json:
schema:
$ref: "../../../components/schemas/_index.yaml#/APIErrors"
description: A malformed or bad request
"403":
content:
application/json:
schema:
$ref: "../../../components/schemas/_index.yaml#/APIErrors"
description: Forbidden
summary: List workflow runs
tags:
- Workflow Runs
2 changes: 1 addition & 1 deletion api/v1/server/handlers/v2/tasks/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (t *TasksService) V2TaskList(ctx echo.Context, request gen.V2TaskListReques
opts.FinishedBefore = request.Params.Until
}

tasks, total, err := t.config.EngineRepository.OLAP().ListTaskRuns(
tasks, total, err := t.config.EngineRepository.OLAP().ListTasks(
ctx.Request().Context(),
tenant.ID,
opts,
Expand Down
37 changes: 37 additions & 0 deletions api/v1/server/handlers/v2/tasks/list_by_dag_id.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package tasks

import (
"github.com/jackc/pgx/v5/pgtype"
"github.com/labstack/echo/v4"

"github.com/hatchet-dev/hatchet/api/v1/server/oas/gen"
"github.com/hatchet-dev/hatchet/api/v1/server/oas/transformers/v2"
"github.com/hatchet-dev/hatchet/pkg/repository/prisma/sqlchelpers"
)

func (t *TasksService) V2DagListTasks(ctx echo.Context, request gen.V2DagListTasksRequestObject) (gen.V2DagListTasksResponseObject, error) {
tenant := request.Params.Tenant
dagIds := request.Params.DagIds

pguuids := make([]pgtype.UUID, 0)
for _, dagId := range dagIds {
pguuids = append(pguuids, sqlchelpers.UUIDFromStr(dagId.String()))
}

tasks, err := t.config.EngineRepository.OLAP().ListTasksByDAGId(
ctx.Request().Context(),
tenant.String(),
pguuids,
)

if err != nil {
return nil, err
}

result := transformers.ToDagChildren(tasks)

// Search for api errors to see how we handle errors in other cases
return gen.V2DagListTasks200JSONResponse(
result,
), nil
}
Loading
Loading