From d5339e2997eb90da4f572b130fcf619f778af070 Mon Sep 17 00:00:00 2001 From: Kofi Ohene-Adu Date: Mon, 2 Oct 2017 17:34:22 -0700 Subject: [PATCH] Add getWorkflows query options for leaning out the response (#53) * WAG updates * make generate * Implementation * Fix lint --- gen-go/client/mock_client.go | 207 +++++++++++++------------------ gen-go/models/inputs.go | 5 + gen-go/server/handlers.go | 15 +++ gen-go/server/mock_controller.go | 160 ++++++++++-------------- gen-js/README.md | 2 + gen-js/index.js | 10 ++ gen-js/package.json | 2 +- handler.go | 2 +- store/dynamodb/dynamodb_store.go | 11 ++ store/memory/memory_store.go | 8 ++ store/store.go | 1 + store/tests/tests.go | 47 +++++++ swagger.yml | 9 +- 13 files changed, 256 insertions(+), 223 deletions(-) diff --git a/gen-go/client/mock_client.go b/gen-go/client/mock_client.go index 61e71669..53452d72 100644 --- a/gen-go/client/mock_client.go +++ b/gen-go/client/mock_client.go @@ -1,275 +1,234 @@ -// Code generated by MockGen. DO NOT EDIT. +// Automatically generated by MockGen. DO NOT EDIT! // Source: interface.go -// Package client is a generated GoMock package. package client import ( context "context" - reflect "reflect" - models "github.com/Clever/workflow-manager/gen-go/models" gomock "github.com/golang/mock/gomock" ) -// MockClient is a mock of Client interface +// Mock of Client interface type MockClient struct { ctrl *gomock.Controller - recorder *MockClientMockRecorder + recorder *_MockClientRecorder } -// MockClientMockRecorder is the mock recorder for MockClient -type MockClientMockRecorder struct { +// Recorder for MockClient (not exported) +type _MockClientRecorder struct { mock *MockClient } -// NewMockClient creates a new mock instance func NewMockClient(ctrl *gomock.Controller) *MockClient { mock := &MockClient{ctrl: ctrl} - mock.recorder = &MockClientMockRecorder{mock} + mock.recorder = &_MockClientRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use -func (m *MockClient) EXPECT() *MockClientMockRecorder { - return m.recorder +func (_m *MockClient) EXPECT() *_MockClientRecorder { + return _m.recorder } -// HealthCheck mocks base method -func (m *MockClient) HealthCheck(ctx context.Context) error { - ret := m.ctrl.Call(m, "HealthCheck", ctx) +func (_m *MockClient) HealthCheck(ctx context.Context) error { + ret := _m.ctrl.Call(_m, "HealthCheck", ctx) ret0, _ := ret[0].(error) return ret0 } -// HealthCheck indicates an expected call of HealthCheck -func (mr *MockClientMockRecorder) HealthCheck(ctx interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HealthCheck", reflect.TypeOf((*MockClient)(nil).HealthCheck), ctx) +func (_mr *_MockClientRecorder) HealthCheck(arg0 interface{}) *gomock.Call { + return _mr.mock.ctrl.RecordCall(_mr.mock, "HealthCheck", arg0) } -// PostStateResource mocks base method -func (m *MockClient) PostStateResource(ctx context.Context, i *models.NewStateResource) (*models.StateResource, error) { - ret := m.ctrl.Call(m, "PostStateResource", ctx, i) +func (_m *MockClient) PostStateResource(ctx context.Context, i *models.NewStateResource) (*models.StateResource, error) { + ret := _m.ctrl.Call(_m, "PostStateResource", ctx, i) ret0, _ := ret[0].(*models.StateResource) ret1, _ := ret[1].(error) return ret0, ret1 } -// PostStateResource indicates an expected call of PostStateResource -func (mr *MockClientMockRecorder) PostStateResource(ctx, i interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PostStateResource", reflect.TypeOf((*MockClient)(nil).PostStateResource), ctx, i) +func (_mr *_MockClientRecorder) PostStateResource(arg0, arg1 interface{}) *gomock.Call { + return _mr.mock.ctrl.RecordCall(_mr.mock, "PostStateResource", arg0, arg1) } -// DeleteStateResource mocks base method -func (m *MockClient) DeleteStateResource(ctx context.Context, i *models.DeleteStateResourceInput) error { - ret := m.ctrl.Call(m, "DeleteStateResource", ctx, i) +func (_m *MockClient) DeleteStateResource(ctx context.Context, i *models.DeleteStateResourceInput) error { + ret := _m.ctrl.Call(_m, "DeleteStateResource", ctx, i) ret0, _ := ret[0].(error) return ret0 } -// DeleteStateResource indicates an expected call of DeleteStateResource -func (mr *MockClientMockRecorder) DeleteStateResource(ctx, i interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteStateResource", reflect.TypeOf((*MockClient)(nil).DeleteStateResource), ctx, i) +func (_mr *_MockClientRecorder) DeleteStateResource(arg0, arg1 interface{}) *gomock.Call { + return _mr.mock.ctrl.RecordCall(_mr.mock, "DeleteStateResource", arg0, arg1) } -// GetStateResource mocks base method -func (m *MockClient) GetStateResource(ctx context.Context, i *models.GetStateResourceInput) (*models.StateResource, error) { - ret := m.ctrl.Call(m, "GetStateResource", ctx, i) +func (_m *MockClient) GetStateResource(ctx context.Context, i *models.GetStateResourceInput) (*models.StateResource, error) { + ret := _m.ctrl.Call(_m, "GetStateResource", ctx, i) ret0, _ := ret[0].(*models.StateResource) ret1, _ := ret[1].(error) return ret0, ret1 } -// GetStateResource indicates an expected call of GetStateResource -func (mr *MockClientMockRecorder) GetStateResource(ctx, i interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStateResource", reflect.TypeOf((*MockClient)(nil).GetStateResource), ctx, i) +func (_mr *_MockClientRecorder) GetStateResource(arg0, arg1 interface{}) *gomock.Call { + return _mr.mock.ctrl.RecordCall(_mr.mock, "GetStateResource", arg0, arg1) } -// PutStateResource mocks base method -func (m *MockClient) PutStateResource(ctx context.Context, i *models.PutStateResourceInput) (*models.StateResource, error) { - ret := m.ctrl.Call(m, "PutStateResource", ctx, i) +func (_m *MockClient) PutStateResource(ctx context.Context, i *models.PutStateResourceInput) (*models.StateResource, error) { + ret := _m.ctrl.Call(_m, "PutStateResource", ctx, i) ret0, _ := ret[0].(*models.StateResource) ret1, _ := ret[1].(error) return ret0, ret1 } -// PutStateResource indicates an expected call of PutStateResource -func (mr *MockClientMockRecorder) PutStateResource(ctx, i interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PutStateResource", reflect.TypeOf((*MockClient)(nil).PutStateResource), ctx, i) +func (_mr *_MockClientRecorder) PutStateResource(arg0, arg1 interface{}) *gomock.Call { + return _mr.mock.ctrl.RecordCall(_mr.mock, "PutStateResource", arg0, arg1) } -// GetWorkflowDefinitions mocks base method -func (m *MockClient) GetWorkflowDefinitions(ctx context.Context) ([]models.WorkflowDefinition, error) { - ret := m.ctrl.Call(m, "GetWorkflowDefinitions", ctx) +func (_m *MockClient) GetWorkflowDefinitions(ctx context.Context) ([]models.WorkflowDefinition, error) { + ret := _m.ctrl.Call(_m, "GetWorkflowDefinitions", ctx) ret0, _ := ret[0].([]models.WorkflowDefinition) ret1, _ := ret[1].(error) return ret0, ret1 } -// GetWorkflowDefinitions indicates an expected call of GetWorkflowDefinitions -func (mr *MockClientMockRecorder) GetWorkflowDefinitions(ctx interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetWorkflowDefinitions", reflect.TypeOf((*MockClient)(nil).GetWorkflowDefinitions), ctx) +func (_mr *_MockClientRecorder) GetWorkflowDefinitions(arg0 interface{}) *gomock.Call { + return _mr.mock.ctrl.RecordCall(_mr.mock, "GetWorkflowDefinitions", arg0) } -// NewWorkflowDefinition mocks base method -func (m *MockClient) NewWorkflowDefinition(ctx context.Context, i *models.NewWorkflowDefinitionRequest) (*models.WorkflowDefinition, error) { - ret := m.ctrl.Call(m, "NewWorkflowDefinition", ctx, i) +func (_m *MockClient) NewWorkflowDefinition(ctx context.Context, i *models.NewWorkflowDefinitionRequest) (*models.WorkflowDefinition, error) { + ret := _m.ctrl.Call(_m, "NewWorkflowDefinition", ctx, i) ret0, _ := ret[0].(*models.WorkflowDefinition) ret1, _ := ret[1].(error) return ret0, ret1 } -// NewWorkflowDefinition indicates an expected call of NewWorkflowDefinition -func (mr *MockClientMockRecorder) NewWorkflowDefinition(ctx, i interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NewWorkflowDefinition", reflect.TypeOf((*MockClient)(nil).NewWorkflowDefinition), ctx, i) +func (_mr *_MockClientRecorder) NewWorkflowDefinition(arg0, arg1 interface{}) *gomock.Call { + return _mr.mock.ctrl.RecordCall(_mr.mock, "NewWorkflowDefinition", arg0, arg1) } -// GetWorkflowDefinitionVersionsByName mocks base method -func (m *MockClient) GetWorkflowDefinitionVersionsByName(ctx context.Context, i *models.GetWorkflowDefinitionVersionsByNameInput) ([]models.WorkflowDefinition, error) { - ret := m.ctrl.Call(m, "GetWorkflowDefinitionVersionsByName", ctx, i) +func (_m *MockClient) GetWorkflowDefinitionVersionsByName(ctx context.Context, i *models.GetWorkflowDefinitionVersionsByNameInput) ([]models.WorkflowDefinition, error) { + ret := _m.ctrl.Call(_m, "GetWorkflowDefinitionVersionsByName", ctx, i) ret0, _ := ret[0].([]models.WorkflowDefinition) ret1, _ := ret[1].(error) return ret0, ret1 } -// GetWorkflowDefinitionVersionsByName indicates an expected call of GetWorkflowDefinitionVersionsByName -func (mr *MockClientMockRecorder) GetWorkflowDefinitionVersionsByName(ctx, i interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetWorkflowDefinitionVersionsByName", reflect.TypeOf((*MockClient)(nil).GetWorkflowDefinitionVersionsByName), ctx, i) +func (_mr *_MockClientRecorder) GetWorkflowDefinitionVersionsByName(arg0, arg1 interface{}) *gomock.Call { + return _mr.mock.ctrl.RecordCall(_mr.mock, "GetWorkflowDefinitionVersionsByName", arg0, arg1) } -// UpdateWorkflowDefinition mocks base method -func (m *MockClient) UpdateWorkflowDefinition(ctx context.Context, i *models.UpdateWorkflowDefinitionInput) (*models.WorkflowDefinition, error) { - ret := m.ctrl.Call(m, "UpdateWorkflowDefinition", ctx, i) +func (_m *MockClient) UpdateWorkflowDefinition(ctx context.Context, i *models.UpdateWorkflowDefinitionInput) (*models.WorkflowDefinition, error) { + ret := _m.ctrl.Call(_m, "UpdateWorkflowDefinition", ctx, i) ret0, _ := ret[0].(*models.WorkflowDefinition) ret1, _ := ret[1].(error) return ret0, ret1 } -// UpdateWorkflowDefinition indicates an expected call of UpdateWorkflowDefinition -func (mr *MockClientMockRecorder) UpdateWorkflowDefinition(ctx, i interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateWorkflowDefinition", reflect.TypeOf((*MockClient)(nil).UpdateWorkflowDefinition), ctx, i) +func (_mr *_MockClientRecorder) UpdateWorkflowDefinition(arg0, arg1 interface{}) *gomock.Call { + return _mr.mock.ctrl.RecordCall(_mr.mock, "UpdateWorkflowDefinition", arg0, arg1) } -// GetWorkflowDefinitionByNameAndVersion mocks base method -func (m *MockClient) GetWorkflowDefinitionByNameAndVersion(ctx context.Context, i *models.GetWorkflowDefinitionByNameAndVersionInput) (*models.WorkflowDefinition, error) { - ret := m.ctrl.Call(m, "GetWorkflowDefinitionByNameAndVersion", ctx, i) +func (_m *MockClient) GetWorkflowDefinitionByNameAndVersion(ctx context.Context, i *models.GetWorkflowDefinitionByNameAndVersionInput) (*models.WorkflowDefinition, error) { + ret := _m.ctrl.Call(_m, "GetWorkflowDefinitionByNameAndVersion", ctx, i) ret0, _ := ret[0].(*models.WorkflowDefinition) ret1, _ := ret[1].(error) return ret0, ret1 } -// GetWorkflowDefinitionByNameAndVersion indicates an expected call of GetWorkflowDefinitionByNameAndVersion -func (mr *MockClientMockRecorder) GetWorkflowDefinitionByNameAndVersion(ctx, i interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetWorkflowDefinitionByNameAndVersion", reflect.TypeOf((*MockClient)(nil).GetWorkflowDefinitionByNameAndVersion), ctx, i) +func (_mr *_MockClientRecorder) GetWorkflowDefinitionByNameAndVersion(arg0, arg1 interface{}) *gomock.Call { + return _mr.mock.ctrl.RecordCall(_mr.mock, "GetWorkflowDefinitionByNameAndVersion", arg0, arg1) } -// GetWorkflows mocks base method -func (m *MockClient) GetWorkflows(ctx context.Context, i *models.GetWorkflowsInput) ([]models.Workflow, error) { - ret := m.ctrl.Call(m, "GetWorkflows", ctx, i) +func (_m *MockClient) GetWorkflows(ctx context.Context, i *models.GetWorkflowsInput) ([]models.Workflow, error) { + ret := _m.ctrl.Call(_m, "GetWorkflows", ctx, i) ret0, _ := ret[0].([]models.Workflow) ret1, _ := ret[1].(error) return ret0, ret1 } -// GetWorkflows indicates an expected call of GetWorkflows -func (mr *MockClientMockRecorder) GetWorkflows(ctx, i interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetWorkflows", reflect.TypeOf((*MockClient)(nil).GetWorkflows), ctx, i) +func (_mr *_MockClientRecorder) GetWorkflows(arg0, arg1 interface{}) *gomock.Call { + return _mr.mock.ctrl.RecordCall(_mr.mock, "GetWorkflows", arg0, arg1) } -// NewGetWorkflowsIter mocks base method -func (m *MockClient) NewGetWorkflowsIter(ctx context.Context, i *models.GetWorkflowsInput) (GetWorkflowsIter, error) { - ret := m.ctrl.Call(m, "NewGetWorkflowsIter", ctx, i) +func (_m *MockClient) NewGetWorkflowsIter(ctx context.Context, i *models.GetWorkflowsInput) (GetWorkflowsIter, error) { + ret := _m.ctrl.Call(_m, "NewGetWorkflowsIter", ctx, i) ret0, _ := ret[0].(GetWorkflowsIter) ret1, _ := ret[1].(error) return ret0, ret1 } -// NewGetWorkflowsIter indicates an expected call of NewGetWorkflowsIter -func (mr *MockClientMockRecorder) NewGetWorkflowsIter(ctx, i interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NewGetWorkflowsIter", reflect.TypeOf((*MockClient)(nil).NewGetWorkflowsIter), ctx, i) +func (_mr *_MockClientRecorder) NewGetWorkflowsIter(arg0, arg1 interface{}) *gomock.Call { + return _mr.mock.ctrl.RecordCall(_mr.mock, "NewGetWorkflowsIter", arg0, arg1) } -// StartWorkflow mocks base method -func (m *MockClient) StartWorkflow(ctx context.Context, i *models.StartWorkflowRequest) (*models.Workflow, error) { - ret := m.ctrl.Call(m, "StartWorkflow", ctx, i) +func (_m *MockClient) StartWorkflow(ctx context.Context, i *models.StartWorkflowRequest) (*models.Workflow, error) { + ret := _m.ctrl.Call(_m, "StartWorkflow", ctx, i) ret0, _ := ret[0].(*models.Workflow) ret1, _ := ret[1].(error) return ret0, ret1 } -// StartWorkflow indicates an expected call of StartWorkflow -func (mr *MockClientMockRecorder) StartWorkflow(ctx, i interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StartWorkflow", reflect.TypeOf((*MockClient)(nil).StartWorkflow), ctx, i) +func (_mr *_MockClientRecorder) StartWorkflow(arg0, arg1 interface{}) *gomock.Call { + return _mr.mock.ctrl.RecordCall(_mr.mock, "StartWorkflow", arg0, arg1) } -// CancelWorkflow mocks base method -func (m *MockClient) CancelWorkflow(ctx context.Context, i *models.CancelWorkflowInput) error { - ret := m.ctrl.Call(m, "CancelWorkflow", ctx, i) +func (_m *MockClient) CancelWorkflow(ctx context.Context, i *models.CancelWorkflowInput) error { + ret := _m.ctrl.Call(_m, "CancelWorkflow", ctx, i) ret0, _ := ret[0].(error) return ret0 } -// CancelWorkflow indicates an expected call of CancelWorkflow -func (mr *MockClientMockRecorder) CancelWorkflow(ctx, i interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CancelWorkflow", reflect.TypeOf((*MockClient)(nil).CancelWorkflow), ctx, i) +func (_mr *_MockClientRecorder) CancelWorkflow(arg0, arg1 interface{}) *gomock.Call { + return _mr.mock.ctrl.RecordCall(_mr.mock, "CancelWorkflow", arg0, arg1) } -// GetWorkflowByID mocks base method -func (m *MockClient) GetWorkflowByID(ctx context.Context, workflowID string) (*models.Workflow, error) { - ret := m.ctrl.Call(m, "GetWorkflowByID", ctx, workflowID) +func (_m *MockClient) GetWorkflowByID(ctx context.Context, workflowID string) (*models.Workflow, error) { + ret := _m.ctrl.Call(_m, "GetWorkflowByID", ctx, workflowID) ret0, _ := ret[0].(*models.Workflow) ret1, _ := ret[1].(error) return ret0, ret1 } -// GetWorkflowByID indicates an expected call of GetWorkflowByID -func (mr *MockClientMockRecorder) GetWorkflowByID(ctx, workflowID interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetWorkflowByID", reflect.TypeOf((*MockClient)(nil).GetWorkflowByID), ctx, workflowID) +func (_mr *_MockClientRecorder) GetWorkflowByID(arg0, arg1 interface{}) *gomock.Call { + return _mr.mock.ctrl.RecordCall(_mr.mock, "GetWorkflowByID", arg0, arg1) } -// MockGetWorkflowsIter is a mock of GetWorkflowsIter interface +// Mock of GetWorkflowsIter interface type MockGetWorkflowsIter struct { ctrl *gomock.Controller - recorder *MockGetWorkflowsIterMockRecorder + recorder *_MockGetWorkflowsIterRecorder } -// MockGetWorkflowsIterMockRecorder is the mock recorder for MockGetWorkflowsIter -type MockGetWorkflowsIterMockRecorder struct { +// Recorder for MockGetWorkflowsIter (not exported) +type _MockGetWorkflowsIterRecorder struct { mock *MockGetWorkflowsIter } -// NewMockGetWorkflowsIter creates a new mock instance func NewMockGetWorkflowsIter(ctrl *gomock.Controller) *MockGetWorkflowsIter { mock := &MockGetWorkflowsIter{ctrl: ctrl} - mock.recorder = &MockGetWorkflowsIterMockRecorder{mock} + mock.recorder = &_MockGetWorkflowsIterRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use -func (m *MockGetWorkflowsIter) EXPECT() *MockGetWorkflowsIterMockRecorder { - return m.recorder +func (_m *MockGetWorkflowsIter) EXPECT() *_MockGetWorkflowsIterRecorder { + return _m.recorder } -// Next mocks base method -func (m *MockGetWorkflowsIter) Next(arg0 *models.Workflow) bool { - ret := m.ctrl.Call(m, "Next", arg0) +func (_m *MockGetWorkflowsIter) Next(_param0 *models.Workflow) bool { + ret := _m.ctrl.Call(_m, "Next", _param0) ret0, _ := ret[0].(bool) return ret0 } -// Next indicates an expected call of Next -func (mr *MockGetWorkflowsIterMockRecorder) Next(arg0 interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Next", reflect.TypeOf((*MockGetWorkflowsIter)(nil).Next), arg0) +func (_mr *_MockGetWorkflowsIterRecorder) Next(arg0 interface{}) *gomock.Call { + return _mr.mock.ctrl.RecordCall(_mr.mock, "Next", arg0) } -// Err mocks base method -func (m *MockGetWorkflowsIter) Err() error { - ret := m.ctrl.Call(m, "Err") +func (_m *MockGetWorkflowsIter) Err() error { + ret := _m.ctrl.Call(_m, "Err") ret0, _ := ret[0].(error) return ret0 } -// Err indicates an expected call of Err -func (mr *MockGetWorkflowsIterMockRecorder) Err() *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Err", reflect.TypeOf((*MockGetWorkflowsIter)(nil).Err)) +func (_mr *_MockGetWorkflowsIterRecorder) Err() *gomock.Call { + return _mr.mock.ctrl.RecordCall(_mr.mock, "Err") } diff --git a/gen-go/models/inputs.go b/gen-go/models/inputs.go index 1c5e888b..1ab083fb 100644 --- a/gen-go/models/inputs.go +++ b/gen-go/models/inputs.go @@ -290,6 +290,7 @@ type GetWorkflowsInput struct { OldestFirst *bool PageToken *string Status *string + SummaryOnly *bool WorkflowDefinitionName string } @@ -321,6 +322,10 @@ func (i GetWorkflowsInput) Path() (string, error) { urlVals.Add("status", *i.Status) } + if i.SummaryOnly != nil { + urlVals.Add("summaryOnly", strconv.FormatBool(*i.SummaryOnly)) + } + urlVals.Add("workflowDefinitionName", i.WorkflowDefinitionName) return path + "?" + urlVals.Encode(), nil diff --git a/gen-go/server/handlers.go b/gen-go/server/handlers.go index b0c90794..57db6e26 100644 --- a/gen-go/server/handlers.go +++ b/gen-go/server/handlers.go @@ -1262,6 +1262,21 @@ func newGetWorkflowsInput(r *http.Request) (*models.GetWorkflowsInput, error) { input.Status = &statusTmp } + summaryOnlyStrs := r.URL.Query()["summaryOnly"] + + if len(summaryOnlyStrs) == 0 { + summaryOnlyStrs = []string{"false"} + } + if len(summaryOnlyStrs) > 0 { + var summaryOnlyTmp bool + summaryOnlyStr := summaryOnlyStrs[0] + summaryOnlyTmp, err = strconv.ParseBool(summaryOnlyStr) + if err != nil { + return nil, err + } + input.SummaryOnly = &summaryOnlyTmp + } + workflowDefinitionNameStrs := r.URL.Query()["workflowDefinitionName"] if len(workflowDefinitionNameStrs) == 0 { return nil, errors.New("parameter must be specified") diff --git a/gen-go/server/mock_controller.go b/gen-go/server/mock_controller.go index 36d0d66b..82050cc4 100644 --- a/gen-go/server/mock_controller.go +++ b/gen-go/server/mock_controller.go @@ -1,215 +1,183 @@ -// Code generated by MockGen. DO NOT EDIT. +// Automatically generated by MockGen. DO NOT EDIT! // Source: interface.go -// Package server is a generated GoMock package. package server import ( context "context" models "github.com/Clever/workflow-manager/gen-go/models" gomock "github.com/golang/mock/gomock" - reflect "reflect" ) -// MockController is a mock of Controller interface +// Mock of Controller interface type MockController struct { ctrl *gomock.Controller - recorder *MockControllerMockRecorder + recorder *_MockControllerRecorder } -// MockControllerMockRecorder is the mock recorder for MockController -type MockControllerMockRecorder struct { +// Recorder for MockController (not exported) +type _MockControllerRecorder struct { mock *MockController } -// NewMockController creates a new mock instance func NewMockController(ctrl *gomock.Controller) *MockController { mock := &MockController{ctrl: ctrl} - mock.recorder = &MockControllerMockRecorder{mock} + mock.recorder = &_MockControllerRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use -func (m *MockController) EXPECT() *MockControllerMockRecorder { - return m.recorder +func (_m *MockController) EXPECT() *_MockControllerRecorder { + return _m.recorder } -// HealthCheck mocks base method -func (m *MockController) HealthCheck(ctx context.Context) error { - ret := m.ctrl.Call(m, "HealthCheck", ctx) +func (_m *MockController) HealthCheck(ctx context.Context) error { + ret := _m.ctrl.Call(_m, "HealthCheck", ctx) ret0, _ := ret[0].(error) return ret0 } -// HealthCheck indicates an expected call of HealthCheck -func (mr *MockControllerMockRecorder) HealthCheck(ctx interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HealthCheck", reflect.TypeOf((*MockController)(nil).HealthCheck), ctx) +func (_mr *_MockControllerRecorder) HealthCheck(arg0 interface{}) *gomock.Call { + return _mr.mock.ctrl.RecordCall(_mr.mock, "HealthCheck", arg0) } -// PostStateResource mocks base method -func (m *MockController) PostStateResource(ctx context.Context, i *models.NewStateResource) (*models.StateResource, error) { - ret := m.ctrl.Call(m, "PostStateResource", ctx, i) +func (_m *MockController) PostStateResource(ctx context.Context, i *models.NewStateResource) (*models.StateResource, error) { + ret := _m.ctrl.Call(_m, "PostStateResource", ctx, i) ret0, _ := ret[0].(*models.StateResource) ret1, _ := ret[1].(error) return ret0, ret1 } -// PostStateResource indicates an expected call of PostStateResource -func (mr *MockControllerMockRecorder) PostStateResource(ctx, i interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PostStateResource", reflect.TypeOf((*MockController)(nil).PostStateResource), ctx, i) +func (_mr *_MockControllerRecorder) PostStateResource(arg0, arg1 interface{}) *gomock.Call { + return _mr.mock.ctrl.RecordCall(_mr.mock, "PostStateResource", arg0, arg1) } -// DeleteStateResource mocks base method -func (m *MockController) DeleteStateResource(ctx context.Context, i *models.DeleteStateResourceInput) error { - ret := m.ctrl.Call(m, "DeleteStateResource", ctx, i) +func (_m *MockController) DeleteStateResource(ctx context.Context, i *models.DeleteStateResourceInput) error { + ret := _m.ctrl.Call(_m, "DeleteStateResource", ctx, i) ret0, _ := ret[0].(error) return ret0 } -// DeleteStateResource indicates an expected call of DeleteStateResource -func (mr *MockControllerMockRecorder) DeleteStateResource(ctx, i interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteStateResource", reflect.TypeOf((*MockController)(nil).DeleteStateResource), ctx, i) +func (_mr *_MockControllerRecorder) DeleteStateResource(arg0, arg1 interface{}) *gomock.Call { + return _mr.mock.ctrl.RecordCall(_mr.mock, "DeleteStateResource", arg0, arg1) } -// GetStateResource mocks base method -func (m *MockController) GetStateResource(ctx context.Context, i *models.GetStateResourceInput) (*models.StateResource, error) { - ret := m.ctrl.Call(m, "GetStateResource", ctx, i) +func (_m *MockController) GetStateResource(ctx context.Context, i *models.GetStateResourceInput) (*models.StateResource, error) { + ret := _m.ctrl.Call(_m, "GetStateResource", ctx, i) ret0, _ := ret[0].(*models.StateResource) ret1, _ := ret[1].(error) return ret0, ret1 } -// GetStateResource indicates an expected call of GetStateResource -func (mr *MockControllerMockRecorder) GetStateResource(ctx, i interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStateResource", reflect.TypeOf((*MockController)(nil).GetStateResource), ctx, i) +func (_mr *_MockControllerRecorder) GetStateResource(arg0, arg1 interface{}) *gomock.Call { + return _mr.mock.ctrl.RecordCall(_mr.mock, "GetStateResource", arg0, arg1) } -// PutStateResource mocks base method -func (m *MockController) PutStateResource(ctx context.Context, i *models.PutStateResourceInput) (*models.StateResource, error) { - ret := m.ctrl.Call(m, "PutStateResource", ctx, i) +func (_m *MockController) PutStateResource(ctx context.Context, i *models.PutStateResourceInput) (*models.StateResource, error) { + ret := _m.ctrl.Call(_m, "PutStateResource", ctx, i) ret0, _ := ret[0].(*models.StateResource) ret1, _ := ret[1].(error) return ret0, ret1 } -// PutStateResource indicates an expected call of PutStateResource -func (mr *MockControllerMockRecorder) PutStateResource(ctx, i interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PutStateResource", reflect.TypeOf((*MockController)(nil).PutStateResource), ctx, i) +func (_mr *_MockControllerRecorder) PutStateResource(arg0, arg1 interface{}) *gomock.Call { + return _mr.mock.ctrl.RecordCall(_mr.mock, "PutStateResource", arg0, arg1) } -// GetWorkflowDefinitions mocks base method -func (m *MockController) GetWorkflowDefinitions(ctx context.Context) ([]models.WorkflowDefinition, error) { - ret := m.ctrl.Call(m, "GetWorkflowDefinitions", ctx) +func (_m *MockController) GetWorkflowDefinitions(ctx context.Context) ([]models.WorkflowDefinition, error) { + ret := _m.ctrl.Call(_m, "GetWorkflowDefinitions", ctx) ret0, _ := ret[0].([]models.WorkflowDefinition) ret1, _ := ret[1].(error) return ret0, ret1 } -// GetWorkflowDefinitions indicates an expected call of GetWorkflowDefinitions -func (mr *MockControllerMockRecorder) GetWorkflowDefinitions(ctx interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetWorkflowDefinitions", reflect.TypeOf((*MockController)(nil).GetWorkflowDefinitions), ctx) +func (_mr *_MockControllerRecorder) GetWorkflowDefinitions(arg0 interface{}) *gomock.Call { + return _mr.mock.ctrl.RecordCall(_mr.mock, "GetWorkflowDefinitions", arg0) } -// NewWorkflowDefinition mocks base method -func (m *MockController) NewWorkflowDefinition(ctx context.Context, i *models.NewWorkflowDefinitionRequest) (*models.WorkflowDefinition, error) { - ret := m.ctrl.Call(m, "NewWorkflowDefinition", ctx, i) +func (_m *MockController) NewWorkflowDefinition(ctx context.Context, i *models.NewWorkflowDefinitionRequest) (*models.WorkflowDefinition, error) { + ret := _m.ctrl.Call(_m, "NewWorkflowDefinition", ctx, i) ret0, _ := ret[0].(*models.WorkflowDefinition) ret1, _ := ret[1].(error) return ret0, ret1 } -// NewWorkflowDefinition indicates an expected call of NewWorkflowDefinition -func (mr *MockControllerMockRecorder) NewWorkflowDefinition(ctx, i interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NewWorkflowDefinition", reflect.TypeOf((*MockController)(nil).NewWorkflowDefinition), ctx, i) +func (_mr *_MockControllerRecorder) NewWorkflowDefinition(arg0, arg1 interface{}) *gomock.Call { + return _mr.mock.ctrl.RecordCall(_mr.mock, "NewWorkflowDefinition", arg0, arg1) } -// GetWorkflowDefinitionVersionsByName mocks base method -func (m *MockController) GetWorkflowDefinitionVersionsByName(ctx context.Context, i *models.GetWorkflowDefinitionVersionsByNameInput) ([]models.WorkflowDefinition, error) { - ret := m.ctrl.Call(m, "GetWorkflowDefinitionVersionsByName", ctx, i) +func (_m *MockController) GetWorkflowDefinitionVersionsByName(ctx context.Context, i *models.GetWorkflowDefinitionVersionsByNameInput) ([]models.WorkflowDefinition, error) { + ret := _m.ctrl.Call(_m, "GetWorkflowDefinitionVersionsByName", ctx, i) ret0, _ := ret[0].([]models.WorkflowDefinition) ret1, _ := ret[1].(error) return ret0, ret1 } -// GetWorkflowDefinitionVersionsByName indicates an expected call of GetWorkflowDefinitionVersionsByName -func (mr *MockControllerMockRecorder) GetWorkflowDefinitionVersionsByName(ctx, i interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetWorkflowDefinitionVersionsByName", reflect.TypeOf((*MockController)(nil).GetWorkflowDefinitionVersionsByName), ctx, i) +func (_mr *_MockControllerRecorder) GetWorkflowDefinitionVersionsByName(arg0, arg1 interface{}) *gomock.Call { + return _mr.mock.ctrl.RecordCall(_mr.mock, "GetWorkflowDefinitionVersionsByName", arg0, arg1) } -// UpdateWorkflowDefinition mocks base method -func (m *MockController) UpdateWorkflowDefinition(ctx context.Context, i *models.UpdateWorkflowDefinitionInput) (*models.WorkflowDefinition, error) { - ret := m.ctrl.Call(m, "UpdateWorkflowDefinition", ctx, i) +func (_m *MockController) UpdateWorkflowDefinition(ctx context.Context, i *models.UpdateWorkflowDefinitionInput) (*models.WorkflowDefinition, error) { + ret := _m.ctrl.Call(_m, "UpdateWorkflowDefinition", ctx, i) ret0, _ := ret[0].(*models.WorkflowDefinition) ret1, _ := ret[1].(error) return ret0, ret1 } -// UpdateWorkflowDefinition indicates an expected call of UpdateWorkflowDefinition -func (mr *MockControllerMockRecorder) UpdateWorkflowDefinition(ctx, i interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateWorkflowDefinition", reflect.TypeOf((*MockController)(nil).UpdateWorkflowDefinition), ctx, i) +func (_mr *_MockControllerRecorder) UpdateWorkflowDefinition(arg0, arg1 interface{}) *gomock.Call { + return _mr.mock.ctrl.RecordCall(_mr.mock, "UpdateWorkflowDefinition", arg0, arg1) } -// GetWorkflowDefinitionByNameAndVersion mocks base method -func (m *MockController) GetWorkflowDefinitionByNameAndVersion(ctx context.Context, i *models.GetWorkflowDefinitionByNameAndVersionInput) (*models.WorkflowDefinition, error) { - ret := m.ctrl.Call(m, "GetWorkflowDefinitionByNameAndVersion", ctx, i) +func (_m *MockController) GetWorkflowDefinitionByNameAndVersion(ctx context.Context, i *models.GetWorkflowDefinitionByNameAndVersionInput) (*models.WorkflowDefinition, error) { + ret := _m.ctrl.Call(_m, "GetWorkflowDefinitionByNameAndVersion", ctx, i) ret0, _ := ret[0].(*models.WorkflowDefinition) ret1, _ := ret[1].(error) return ret0, ret1 } -// GetWorkflowDefinitionByNameAndVersion indicates an expected call of GetWorkflowDefinitionByNameAndVersion -func (mr *MockControllerMockRecorder) GetWorkflowDefinitionByNameAndVersion(ctx, i interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetWorkflowDefinitionByNameAndVersion", reflect.TypeOf((*MockController)(nil).GetWorkflowDefinitionByNameAndVersion), ctx, i) +func (_mr *_MockControllerRecorder) GetWorkflowDefinitionByNameAndVersion(arg0, arg1 interface{}) *gomock.Call { + return _mr.mock.ctrl.RecordCall(_mr.mock, "GetWorkflowDefinitionByNameAndVersion", arg0, arg1) } -// GetWorkflows mocks base method -func (m *MockController) GetWorkflows(ctx context.Context, i *models.GetWorkflowsInput) ([]models.Workflow, string, error) { - ret := m.ctrl.Call(m, "GetWorkflows", ctx, i) +func (_m *MockController) GetWorkflows(ctx context.Context, i *models.GetWorkflowsInput) ([]models.Workflow, string, error) { + ret := _m.ctrl.Call(_m, "GetWorkflows", ctx, i) ret0, _ := ret[0].([]models.Workflow) ret1, _ := ret[1].(string) ret2, _ := ret[2].(error) return ret0, ret1, ret2 } -// GetWorkflows indicates an expected call of GetWorkflows -func (mr *MockControllerMockRecorder) GetWorkflows(ctx, i interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetWorkflows", reflect.TypeOf((*MockController)(nil).GetWorkflows), ctx, i) +func (_mr *_MockControllerRecorder) GetWorkflows(arg0, arg1 interface{}) *gomock.Call { + return _mr.mock.ctrl.RecordCall(_mr.mock, "GetWorkflows", arg0, arg1) } -// StartWorkflow mocks base method -func (m *MockController) StartWorkflow(ctx context.Context, i *models.StartWorkflowRequest) (*models.Workflow, error) { - ret := m.ctrl.Call(m, "StartWorkflow", ctx, i) +func (_m *MockController) StartWorkflow(ctx context.Context, i *models.StartWorkflowRequest) (*models.Workflow, error) { + ret := _m.ctrl.Call(_m, "StartWorkflow", ctx, i) ret0, _ := ret[0].(*models.Workflow) ret1, _ := ret[1].(error) return ret0, ret1 } -// StartWorkflow indicates an expected call of StartWorkflow -func (mr *MockControllerMockRecorder) StartWorkflow(ctx, i interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StartWorkflow", reflect.TypeOf((*MockController)(nil).StartWorkflow), ctx, i) +func (_mr *_MockControllerRecorder) StartWorkflow(arg0, arg1 interface{}) *gomock.Call { + return _mr.mock.ctrl.RecordCall(_mr.mock, "StartWorkflow", arg0, arg1) } -// CancelWorkflow mocks base method -func (m *MockController) CancelWorkflow(ctx context.Context, i *models.CancelWorkflowInput) error { - ret := m.ctrl.Call(m, "CancelWorkflow", ctx, i) +func (_m *MockController) CancelWorkflow(ctx context.Context, i *models.CancelWorkflowInput) error { + ret := _m.ctrl.Call(_m, "CancelWorkflow", ctx, i) ret0, _ := ret[0].(error) return ret0 } -// CancelWorkflow indicates an expected call of CancelWorkflow -func (mr *MockControllerMockRecorder) CancelWorkflow(ctx, i interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CancelWorkflow", reflect.TypeOf((*MockController)(nil).CancelWorkflow), ctx, i) +func (_mr *_MockControllerRecorder) CancelWorkflow(arg0, arg1 interface{}) *gomock.Call { + return _mr.mock.ctrl.RecordCall(_mr.mock, "CancelWorkflow", arg0, arg1) } -// GetWorkflowByID mocks base method -func (m *MockController) GetWorkflowByID(ctx context.Context, workflowID string) (*models.Workflow, error) { - ret := m.ctrl.Call(m, "GetWorkflowByID", ctx, workflowID) +func (_m *MockController) GetWorkflowByID(ctx context.Context, workflowID string) (*models.Workflow, error) { + ret := _m.ctrl.Call(_m, "GetWorkflowByID", ctx, workflowID) ret0, _ := ret[0].(*models.Workflow) ret1, _ := ret[1].(error) return ret0, ret1 } -// GetWorkflowByID indicates an expected call of GetWorkflowByID -func (mr *MockControllerMockRecorder) GetWorkflowByID(ctx, workflowID interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetWorkflowByID", reflect.TypeOf((*MockController)(nil).GetWorkflowByID), ctx, workflowID) +func (_mr *_MockControllerRecorder) GetWorkflowByID(arg0, arg1 interface{}) *gomock.Call { + return _mr.mock.ctrl.RecordCall(_mr.mock, "GetWorkflowByID", arg0, arg1) } diff --git a/gen-js/README.md b/gen-js/README.md index 23943c7b..b3d4b28a 100644 --- a/gen-js/README.md +++ b/gen-js/README.md @@ -296,6 +296,7 @@ Get the latest versions of all available WorkflowDefinitions | [params.oldestFirst] | boolean | | | [params.pageToken] | string | | | [params.status] | string | | +| [params.summaryOnly] | boolean | Limits workflow data to the bare minimum - omits the full workflow definition and job data. | | params.workflowDefinitionName | string | | | [options] | object | | | [options.timeout] | number | A request specific timeout | @@ -316,6 +317,7 @@ Get the latest versions of all available WorkflowDefinitions | [params.oldestFirst] | boolean | | | [params.pageToken] | string | | | [params.status] | string | | +| [params.summaryOnly] | boolean | Limits workflow data to the bare minimum - omits the full workflow definition and job data. | | params.workflowDefinitionName | string | | | [options] | object | | | [options.timeout] | number | A request specific timeout | diff --git a/gen-js/index.js b/gen-js/index.js index e6f5db4e..4455cc28 100644 --- a/gen-js/index.js +++ b/gen-js/index.js @@ -1465,6 +1465,7 @@ class WorkflowManager { * @param {boolean} [params.oldestFirst] * @param {string} [params.pageToken] * @param {string} [params.status] + * @param {boolean} [params.summaryOnly] - Limits workflow data to the bare minimum - omits the full workflow definition and job data. * @param {string} params.workflowDefinitionName * @param {object} [options] * @param {number} [options.timeout] - A request specific timeout @@ -1528,6 +1529,10 @@ class WorkflowManager { query["status"] = params.status; } + if (typeof params.summaryOnly !== "undefined") { + query["summaryOnly"] = params.summaryOnly; + } + query["workflowDefinitionName"] = params.workflowDefinitionName; @@ -1609,6 +1614,7 @@ class WorkflowManager { * @param {boolean} [params.oldestFirst] * @param {string} [params.pageToken] * @param {string} [params.status] + * @param {boolean} [params.summaryOnly] - Limits workflow data to the bare minimum - omits the full workflow definition and job data. * @param {string} params.workflowDefinitionName * @param {object} [options] * @param {number} [options.timeout] - A request specific timeout @@ -1661,6 +1667,10 @@ class WorkflowManager { query["status"] = params.status; } + if (typeof params.summaryOnly !== "undefined") { + query["summaryOnly"] = params.summaryOnly; + } + query["workflowDefinitionName"] = params.workflowDefinitionName; diff --git a/gen-js/package.json b/gen-js/package.json index c6de35f1..2aee3b50 100644 --- a/gen-js/package.json +++ b/gen-js/package.json @@ -1,6 +1,6 @@ { "name": "workflow-manager", - "version": "0.6.0", + "version": "0.6.1", "description": "Minimal Workflow orchestrator for AWS Batch", "main": "index.js", "dependencies": { diff --git a/handler.go b/handler.go index c52573ae..7095bc36 100644 --- a/handler.go +++ b/handler.go @@ -201,6 +201,7 @@ func (h Handler) GetWorkflows( OldestFirst: swag.BoolValue(input.OldestFirst), PageToken: swag.StringValue(input.PageToken), Status: swag.StringValue(input.Status), + SummaryOnly: swag.BoolValue(input.SummaryOnly), }) if err != nil { if _, ok := err.(store.InvalidPageTokenError); ok { @@ -214,7 +215,6 @@ func (h Handler) GetWorkflows( results := []models.Workflow{} for _, workflow := range workflows { - h.manager.UpdateWorkflowStatus(&workflow) results = append(results, workflow) } return results, nextPageToken, nil diff --git a/store/dynamodb/dynamodb_store.go b/store/dynamodb/dynamodb_store.go index 468e0759..76b07f61 100644 --- a/store/dynamodb/dynamodb_store.go +++ b/store/dynamodb/dynamodb_store.go @@ -584,6 +584,17 @@ func (d DynamoDB) GetWorkflows(query *store.WorkflowQuery) ([]models.Workflow, s if err != nil { return workflows, nextPageToken, err } + + // TODO: Optimization - use a projection expression instead to limit which fields are returned + // by the dynamodb query. + if query.SummaryOnly { + workflow.Jobs = []*models.Job{} + workflow.WorkflowDefinition = &models.WorkflowDefinition{ + Name: workflow.WorkflowDefinition.Name, + Version: workflow.WorkflowDefinition.Version, + } + } + workflows = append(workflows, workflow) } diff --git a/store/memory/memory_store.go b/store/memory/memory_store.go index 71d81ec9..b2d6f48e 100644 --- a/store/memory/memory_store.go +++ b/store/memory/memory_store.go @@ -166,6 +166,14 @@ func (s MemoryStore) GetWorkflows( workflows := []models.Workflow{} for _, workflow := range s.workflows { if s.matchesQuery(workflow, query) { + if query.SummaryOnly { + workflow.Jobs = []*models.Job{} + workflow.WorkflowDefinition = &models.WorkflowDefinition{ + Name: workflow.WorkflowDefinition.Name, + Version: workflow.WorkflowDefinition.Version, + } + } + workflows = append(workflows, workflow) } } diff --git a/store/store.go b/store/store.go index 959b7b70..759db5e1 100644 --- a/store/store.go +++ b/store/store.go @@ -36,6 +36,7 @@ type WorkflowQuery struct { OldestFirst bool PageToken string Status string + SummaryOnly bool } // ErrWorkflowLocked is returned from LockWorfklow in the case of the workflow already being locked. diff --git a/store/tests/tests.go b/store/tests/tests.go index 2b91f48b..fe4a61bf 100644 --- a/store/tests/tests.go +++ b/store/tests/tests.go @@ -24,6 +24,7 @@ func RunStoreTests(t *testing.T, storeFactory func() store.Store) { t.Run("UpdateWorkflow", UpdateWorkflow(storeFactory(), t)) t.Run("GetWorkflowByID", GetWorkflowByID(storeFactory(), t)) t.Run("GetWorkflows", GetWorkflows(storeFactory(), t)) + t.Run("GetWorkflowsSummaryOnly", GetWorkflowsSummaryOnly(storeFactory(), t)) t.Run("GetWorkflowsPagination", GetWorkflowsPagination(storeFactory(), t)) t.Run("GetPendingWorkflowIDs", GetPendingWorkflowIDs(storeFactory(), t)) t.Run("LockWorkflow/UnlockWorkflow", LockUnlockWorkflow(storeFactory(), t)) @@ -268,6 +269,52 @@ func GetWorkflows(s store.Store, t *testing.T) func(t *testing.T) { } } +func GetWorkflowsSummaryOnly(s store.Store, t *testing.T) func(t *testing.T) { + return func(t *testing.T) { + definition := resources.KitchenSinkWorkflowDefinition(t) + require.NoError(t, s.SaveWorkflowDefinition(*definition)) + + tags := map[string]interface{}{"team": "infra", "tag2": "value2"} + workflow := resources.NewWorkflow(definition, `["input"]`, "ns", "queue", tags) + workflow.Jobs = []*models.Job{{ + ID: "job1", + Input: `["job input"]`, + }} + require.NoError(t, s.SaveWorkflow(*workflow)) + + // Verify details are excluded if SummaryOnly == true: + workflows, _, err := s.GetWorkflows(&store.WorkflowQuery{ + DefinitionName: definition.Name, + SummaryOnly: true, + Limit: 10, + }) + require.NoError(t, err) + require.Equal(t, []*models.Job{}, workflows[0].Jobs) + + definitionSummary := &models.WorkflowDefinition{ + Name: definition.Name, + Version: definition.Version, + } + require.Equal(t, definitionSummary, workflows[0].WorkflowDefinition) + + // Verify details are included if SummaryOnly == false: + workflows, _, err = s.GetWorkflows(&store.WorkflowQuery{ + DefinitionName: definition.Name, + SummaryOnly: false, + Limit: 10, + }) + require.NoError(t, err) + require.Equal(t, workflow.Jobs, workflows[0].Jobs) + require.Equal(t, definition.Name, workflows[0].WorkflowDefinition.Name) + require.Equal(t, definition.Version, workflows[0].WorkflowDefinition.Version) + require.Equal( + t, + len(definition.StateMachine.States), + len(workflows[0].WorkflowDefinition.StateMachine.States), + ) + } +} + func GetWorkflowsPagination(s store.Store, t *testing.T) func(t *testing.T) { return func(t *testing.T) { definition := resources.KitchenSinkWorkflowDefinition(t) diff --git a/swagger.yml b/swagger.yml index c72bcd1b..47cad315 100644 --- a/swagger.yml +++ b/swagger.yml @@ -7,7 +7,7 @@ info: # 2. merge the new clients, and, after merging, tag the commit with the version: # git tag -a vX.Y.Z -m "vX.Y.Z" # git push origin --tags - version: 0.6.0 + version: 0.6.1 x-npm-package: workflow-manager schemes: - http @@ -168,6 +168,13 @@ paths: - name: status in: query type: string + - name: summaryOnly + description: + Limits workflow data to the bare minimum - omits the full workflow definition and job + data. + in: query + type: boolean + default: false - name: workflowDefinitionName in: query type: string