-
Notifications
You must be signed in to change notification settings - Fork 18
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
Implement workflow dags endpoint #1330
Merged
Merged
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a458ce6
works
likawind f81c065
lint
likawind ec94379
comments
likawind 8cb356c
Merge branch 'main' of https://github.com/aqueducthq/aqueduct into en…
likawind e08dfb7
Merge branch 'main' into eng-2847-m1-implement-wfiddags-endpoint-with
likawind 50fa075
Merge branch 'main' of https://github.com/aqueducthq/aqueduct into en…
likawind ad3b740
Implement RTK mutations for workflow trigger / edit endpoints (#1332)
likawind 27796b6
tests
likawind 5e730bd
RTK
likawind c649d37
Implement node hooks (#1340)
likawind File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package v2 | ||
|
||
import ( | ||
"context" | ||
"net/http" | ||
|
||
"github.com/aqueducthq/aqueduct/cmd/server/handler" | ||
"github.com/aqueducthq/aqueduct/cmd/server/request/parser" | ||
aq_context "github.com/aqueducthq/aqueduct/lib/context" | ||
"github.com/aqueducthq/aqueduct/lib/database" | ||
"github.com/aqueducthq/aqueduct/lib/functional/slices" | ||
"github.com/aqueducthq/aqueduct/lib/models" | ||
"github.com/aqueducthq/aqueduct/lib/repos" | ||
"github.com/aqueducthq/aqueduct/lib/response" | ||
"github.com/dropbox/godropbox/errors" | ||
"github.com/google/uuid" | ||
) | ||
|
||
// This file should map directly to | ||
// src/ui/common/src/handlers/v2/DagsGet.tsx | ||
// | ||
// Route: /v2/workflow/{workflowId}/dags | ||
// Method: GET | ||
// Params: | ||
// `workflowId`: ID for `workflow` object | ||
// Request: | ||
// Headers: | ||
// `api-key`: user's API Key | ||
// | ||
// Response: | ||
// Body: | ||
// serialized `[]response.DAGResult` | ||
|
||
type dagsGetArgs struct { | ||
*aq_context.AqContext | ||
workflowID uuid.UUID | ||
} | ||
|
||
type DAGsGetHandler struct { | ||
handler.GetHandler | ||
|
||
Database database.Database | ||
|
||
WorkflowRepo repos.Workflow | ||
DAGRepo repos.DAG | ||
} | ||
|
||
func (*DAGsGetHandler) Name() string { | ||
return "DAGsGet" | ||
} | ||
|
||
func (h *DAGsGetHandler) Prepare(r *http.Request) (interface{}, int, error) { | ||
aqContext, statusCode, err := aq_context.ParseAqContext(r.Context()) | ||
if err != nil { | ||
return nil, statusCode, err | ||
} | ||
|
||
workflowID, err := (parser.WorkflowIDParser{}).Parse(r) | ||
if err != nil { | ||
return nil, http.StatusBadRequest, err | ||
} | ||
|
||
return &dagsGetArgs{ | ||
AqContext: aqContext, | ||
workflowID: workflowID, | ||
}, http.StatusOK, nil | ||
} | ||
|
||
func (h *DAGsGetHandler) Perform(ctx context.Context, interfaceArgs interface{}) (interface{}, int, error) { | ||
args := interfaceArgs.(*dagsGetArgs) | ||
|
||
ok, err := h.WorkflowRepo.ValidateOrg( | ||
ctx, | ||
args.workflowID, | ||
args.OrgID, | ||
h.Database, | ||
) | ||
if err != nil { | ||
return nil, http.StatusInternalServerError, errors.Wrap(err, "Unexpected error during workflow ownership validation.") | ||
} | ||
|
||
if !ok { | ||
return nil, http.StatusBadRequest, errors.Wrap(err, "The organization does not own this workflow.") | ||
} | ||
|
||
dbDAGs, err := h.DAGRepo.GetByWorkflow(ctx, args.workflowID, h.Database) | ||
if err != nil { | ||
return nil, http.StatusInternalServerError, errors.Wrap(err, "Unexpected error reading dag results.") | ||
} | ||
|
||
return slices.Map(dbDAGs, func(dbDAG models.DAG) response.DAG { | ||
return *response.NewDAGFromDBObject(&dbDAG) | ||
}), http.StatusOK, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// This file should map exactly to | ||
// src/golang/cmd/server/handler/v2/dags_get.go | ||
|
||
import { APIKeyParameter } from '../parameters/Header'; | ||
import { WorkflowIdParameter } from '../parameters/Path'; | ||
import { DagResponse } from '../responses/workflow'; | ||
|
||
export type DagsGetRequest = APIKeyParameter & WorkflowIdParameter; | ||
|
||
export type DagsGetResponse = DagResponse[]; | ||
|
||
export const dagsGetQuery = (req: DagsGetRequest) => ({ | ||
url: `workflow/${req.workflowId}/dags`, | ||
headers: { 'api-key': req.apiKey }, | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To check the format of the response, I cast to a Response class object. I think you can do that for this too. As bonus, it will be easier for me to integrate into the SDK if the Response classes are already written up.