Skip to content

Commit

Permalink
Add getWorkflows query options for leaning out the response (#53)
Browse files Browse the repository at this point in the history
* WAG updates

* make generate

* Implementation

* Fix lint
  • Loading branch information
kofi-clever authored Oct 3, 2017
1 parent 1122869 commit d5339e2
Show file tree
Hide file tree
Showing 13 changed files with 256 additions and 223 deletions.
207 changes: 83 additions & 124 deletions gen-go/client/mock_client.go

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions gen-go/models/inputs.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ type GetWorkflowsInput struct {
OldestFirst *bool
PageToken *string
Status *string
SummaryOnly *bool
WorkflowDefinitionName string
}

Expand Down Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions gen-go/server/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
160 changes: 64 additions & 96 deletions gen-go/server/mock_controller.go
Original file line number Diff line number Diff line change
@@ -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)
}
2 changes: 2 additions & 0 deletions gen-js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ Get the latest versions of all available WorkflowDefinitions
| [params.oldestFirst] | <code>boolean</code> | |
| [params.pageToken] | <code>string</code> | |
| [params.status] | <code>string</code> | |
| [params.summaryOnly] | <code>boolean</code> | Limits workflow data to the bare minimum - omits the full workflow definition and job data. |
| params.workflowDefinitionName | <code>string</code> | |
| [options] | <code>object</code> | |
| [options.timeout] | <code>number</code> | A request specific timeout |
Expand All @@ -316,6 +317,7 @@ Get the latest versions of all available WorkflowDefinitions
| [params.oldestFirst] | <code>boolean</code> | |
| [params.pageToken] | <code>string</code> | |
| [params.status] | <code>string</code> | |
| [params.summaryOnly] | <code>boolean</code> | Limits workflow data to the bare minimum - omits the full workflow definition and job data. |
| params.workflowDefinitionName | <code>string</code> | |
| [options] | <code>object</code> | |
| [options.timeout] | <code>number</code> | A request specific timeout |
Expand Down
10 changes: 10 additions & 0 deletions gen-js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1528,6 +1529,10 @@ class WorkflowManager {
query["status"] = params.status;
}

if (typeof params.summaryOnly !== "undefined") {
query["summaryOnly"] = params.summaryOnly;
}

query["workflowDefinitionName"] = params.workflowDefinitionName;


Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1661,6 +1667,10 @@ class WorkflowManager {
query["status"] = params.status;
}

if (typeof params.summaryOnly !== "undefined") {
query["summaryOnly"] = params.summaryOnly;
}

query["workflowDefinitionName"] = params.workflowDefinitionName;


Expand Down
2 changes: 1 addition & 1 deletion gen-js/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
Loading

0 comments on commit d5339e2

Please sign in to comment.