Skip to content

Commit

Permalink
add workflow jobs viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
MauricioUyaguari committed Nov 1, 2021
1 parent 7318c22 commit eecb5d6
Show file tree
Hide file tree
Showing 7 changed files with 922 additions and 47 deletions.
5 changes: 5 additions & 0 deletions .changeset/coffee-morning-sunshine.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@finos/legend-server-sdlc': patch
---

Add workflow jobs apis to retry/cancel/run jobs as well as to view job logs.
5 changes: 5 additions & 0 deletions .changeset/orange-apricots-refuse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@finos/legend-studio': patch
---

Add workflow jobs viewer and ability to retry/run/cancel individual jobs.
109 changes: 107 additions & 2 deletions packages/legend-server-sdlc/src/SDLCServerClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import type { CreateVersionCommand } from './models/version/VersionCommands';
import type { ProjectStructureVersion } from './models/configuration/ProjectStructureVersion';
import type { User } from './models/User';
import type { PlainObject, TraceData } from '@finos/legend-shared';
import { AbstractServerClient } from '@finos/legend-shared';
import { AbstractServerClient, ContentType } from '@finos/legend-shared';
import type { Entity } from '@finos/legend-model-storage';
import type {
CreateProjectCommand,
Expand All @@ -44,6 +44,7 @@ import type {
CommitReviewCommand,
CreateReviewCommand,
} from './models/review/ReviewCommands';
import type { WorkflowJob } from './models/workflow/WorkflowJob';

enum SDLC_TRACER_SPAN {
IMPORT_PROJECT = 'import project',
Expand Down Expand Up @@ -343,7 +344,31 @@ export class SDLCServerClient extends AbstractServerClient {
projectId: string,
workspace: Workspace | undefined,
): string => `${this._adaptiveWorkspace(projectId, workspace)}/workflows`;
private _workflow = (
projectId: string,
workspace: Workspace | undefined,
workflowId: string,
): string =>
`${this._adaptiveWorkspace(projectId, workspace)}/workflows/${workflowId}`;
private _workflowJobs = (
projectId: string,
workspace: Workspace | undefined,
workflowId: string,
): string => `${this._workflow(projectId, workspace, workflowId)}/jobs`;
private _workflowJob = (
projectId: string,
workspace: Workspace | undefined,
workflowId: string,
workflowJobId: string,
): string =>
`${this._workflow(projectId, workspace, workflowId)}/jobs/${workflowJobId}`;

getWorkflow = (
projectId: string,
workspace: Workspace | undefined,
workflowId: string,
): Promise<PlainObject<Workflow>[]> =>
this.networkClient.get(this._workflow(projectId, workspace, workflowId));
getWorkflows = (
projectId: string,
workspace: Workspace | undefined,
Expand All @@ -357,6 +382,20 @@ export class SDLCServerClient extends AbstractServerClient {
undefined,
{ status, revisionIds, limit },
);
getWorkflowJobs = (
projectId: string,
workspace: Workspace | undefined,
workflowId: string,
status: WorkflowStatus | undefined,
revisionIds: string[] | undefined,
limit: number | undefined,
): Promise<PlainObject<Workflow>[]> =>
this.networkClient.get(
this._workflowJobs(projectId, workspace, workflowId),
undefined,
undefined,
{ status, revisionIds, limit },
);
getWorkflowsByRevision = (
projectId: string,
workspace: Workspace | undefined,
Expand All @@ -368,7 +407,73 @@ export class SDLCServerClient extends AbstractServerClient {
undefined,
{ revisionId },
);

getWorkflowJob = (
projectId: string,
workspace: Workspace | undefined,
workflowJob: WorkflowJob,
): Promise<PlainObject<WorkflowJob>> =>
this.networkClient.get(
`${this._workflowJob(
projectId,
workspace,
workflowJob.workflowId,
workflowJob.id,
)}`,
);
getWorkflowJobLogs = (
projectId: string,
workspace: Workspace | undefined,
workflowJob: WorkflowJob,
): Promise<string> =>
this.networkClient.get(
`${this._workflowJob(
projectId,
workspace,
workflowJob.workflowId,
workflowJob.id,
)}/logs`,
{},
{ Accept: ContentType.TEXT_PLAIN },
);
cancelWorkflowJob = (
projectId: string,
workspace: Workspace | undefined,
workflowJob: WorkflowJob,
): Promise<PlainObject<Workflow>[]> =>
this.networkClient.post(
`${this._workflowJob(
projectId,
workspace,
workflowJob.workflowId,
workflowJob.id,
)}/cancel`,
);
retryWorkflowJob = (
projectId: string,
workspace: Workspace | undefined,
workflowJob: WorkflowJob,
): Promise<PlainObject<Workflow>[]> =>
this.networkClient.post(
`${this._workflowJob(
projectId,
workspace,
workflowJob.workflowId,
workflowJob.id,
)}/retry`,
);
runManualWorkflowJob = (
projectId: string,
workspace: Workspace | undefined,
workflowJob: WorkflowJob,
): Promise<PlainObject<Workflow>[]> =>
this.networkClient.post(
`${this._workflowJob(
projectId,
workspace,
workflowJob.workflowId,
workflowJob.id,
)}/run`,
);
// ------------------------------------------- Entity -------------------------------------------

private _entities = (
Expand Down
1 change: 1 addition & 0 deletions packages/legend-server-sdlc/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export * from './models/review/Review';
export * from './models/review/ReviewCommands';

export * from './models/workflow/Workflow';
export * from './models/workflow/WorkflowJob';

export * from './models/project/Project';
export * from './models/project/ImportReport';
Expand Down
Loading

0 comments on commit eecb5d6

Please sign in to comment.