From 2bfcbbfdcf361b4fd895bf44aee3bcfb0cff025b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Fri, 10 May 2019 14:07:36 +0200 Subject: [PATCH 01/41] split aggregation and key switching; function names more generic --- medco/i2b2_medco_query.go | 15 +++++-- unlynx/client.go | 87 ++++++++++++++++++++++----------------- unlynx/client_test.go | 2 +- 3 files changed, 63 insertions(+), 41 deletions(-) diff --git a/medco/i2b2_medco_query.go b/medco/i2b2_medco_query.go index d35913cd..757e98e8 100644 --- a/medco/i2b2_medco_query.go +++ b/medco/i2b2_medco_query.go @@ -17,7 +17,7 @@ func I2b2MedCoQuery(queryName string, query *models.QueryI2b2Medco) (result *mod // todo: put user + query type + unique ID in query name // tag query terms - taggedQueryTerms, err := unlynx.GetQueryTermsDDT(queryName, extractEncryptedQueryTerms(query.Panels)) + taggedQueryTerms, err := unlynx.DDTagValues(queryName, extractEncryptedQueryTerms(query.Panels)) if err != nil { return } @@ -42,8 +42,17 @@ func I2b2MedCoQuery(queryName string, query *models.QueryI2b2Medco) (result *mod } logrus.Info(queryName, ": got ", len(patientIDs), " patient IDs and ", len(patientDummyFlags), " dummy flags with i2b2") - // aggregate and key-switch the result - encCount, err := unlynx.AggregateAndKeySwitchDummyFlags(queryName, patientDummyFlags, query.UserPublicKey) + // aggregate patient dummy flags + aggPatientFlags, err := unlynx.AggregateValues(patientDummyFlags) + if err != nil { + return + } + + // key switch aggregated flags + encCount, err := unlynx.KeySwitchValue(queryName, aggPatientFlags, query.UserPublicKey) + if err != nil { + return + } result = &models.QueryResultElement{ EncryptedCount: encCount, diff --git a/unlynx/client.go b/unlynx/client.go index 092afb45..218ea0f4 100644 --- a/unlynx/client.go +++ b/unlynx/client.go @@ -13,19 +13,18 @@ import ( "time" ) -// GetQueryTermsDDT makes request through unlynx to compute distributed deterministic tags -func GetQueryTermsDDT(queryName string, encQueryTerms []string) (taggedQueryTerms map[string]string, err error) { +// DDTagValues makes request through unlynx to compute distributed deterministic tags of encrypted values +func DDTagValues(queryName string, values []string) (taggedValues map[string]string, err error) { unlynxClient, cothorityRoster := newUnlynxClient() - // todo: wrap ddt in go routine, have channel for result + error, select with result / error / timeout // todo: get time measurements // tr.DDTRequestTimeCommunication = totalTime - tr.DDTRequestTimeExec // tr.DDTParsingTime = parsingTime // tr.DDTRequestTimeExec += tr.DDTParsingTime // totalTime = around request - // deserialize query terms - deserializedEncQueryTerms, err := deserializeCipherVector(encQueryTerms) + // deserialize values + desValues, err := deserializeCipherVector(values) if err != nil { return } @@ -37,14 +36,14 @@ func GetQueryTermsDDT(queryName string, encQueryTerms []string) (taggedQueryTerm _, ddtResults, _, ddtErr := unlynxClient.SendSurveyDDTRequestTerms( cothorityRoster, servicesmedco.SurveyID(queryName + "_DDT"), - deserializedEncQueryTerms, + desValues, false, false, ) if ddtErr != nil { ddtErrChan <- ddtErr - } else if len(ddtResults) == 0 || len(ddtResults) != len(encQueryTerms) { - ddtErrChan <- errors.New("unlynx inconsistent DDT results: #results=" + strconv.Itoa(len(ddtResults)) + ", #terms=" + strconv.Itoa(len(encQueryTerms))) + } else if len(ddtResults) == 0 || len(ddtResults) != len(values) { + ddtErrChan <- errors.New("unlynx inconsistent DDT results: #results=" + strconv.Itoa(len(ddtResults)) + ", #terms=" + strconv.Itoa(len(values))) } else { ddtResultsChan <- ddtResults } @@ -52,9 +51,9 @@ func GetQueryTermsDDT(queryName string, encQueryTerms []string) (taggedQueryTerm select { case ddtResults := <-ddtResultsChan: - taggedQueryTerms = make(map[string]string) + taggedValues = make(map[string]string) for i, result := range ddtResults { - taggedQueryTerms[encQueryTerms[i]] = string(result) + taggedValues[values[i]] = string(result) } case err = <-ddtErrChan: @@ -67,10 +66,27 @@ func GetQueryTermsDDT(queryName string, encQueryTerms []string) (taggedQueryTerm return } -// AggregateAndKeySwitchDummyFlags makes request through unlynx to aggregate and key switch encrypted values -func AggregateAndKeySwitchDummyFlags(queryName string, dummyFlags []string, clientPubKey string) (agg string, err error) { - unlynxClient, cothorityRoster := newUnlynxClient() +// AggregateValues adds together several encrypted values homomorphically +func AggregateValues(values []string) (agg string, err error) { + + // deserialize values + deserialized, err := deserializeCipherVector(values) + if err != nil { + return + } + // local aggregation + aggregate := &deserialized[0] + for i := 1; i < len(deserialized); i++ { + aggregate.Add(*aggregate, deserialized[i]) + } + + return aggregate.Serialize(), nil +} + +// KeySwitchValue makes request through unlynx to key switch encrypted values +func KeySwitchValue(queryName string, value string, targetPubKey string) (keySwitchedValue string, err error) { + unlynxClient, cothorityRoster := newUnlynxClient() // todo: get time measurements // tr.AggRequestTimeCommunication = totalTime - tr.DDTRequestTimeExec @@ -78,47 +94,44 @@ func AggregateAndKeySwitchDummyFlags(queryName string, dummyFlags []string, clie // tr.AggParsingTime = parsingTime // tr.AggRequestTimeExec += tr.AggParsingTime + tr.LocalAggregationTime - // deserialize dummy flags and client public key - deserializedDummyFlags, err := deserializeCipherVector(dummyFlags) + // deserialize value and target public key + desValue := libunlynx.CipherText{} + err = desValue.Deserialize(value) if err != nil { + logrus.Error("unlynx error deserializing cipher text: ", err) return } - deserializedClientPubKey, err := libunlynx.DeserializePoint(clientPubKey) + + desTargetKey, err := libunlynx.DeserializePoint(targetPubKey) if err != nil { - logrus.Error("unlynx error deserializing client public key: ", err) + logrus.Error("unlynx error deserializing target public key: ", err) return } - // local aggregation - aggregate := &deserializedDummyFlags[0] - for i := 1; i < len(deserializedDummyFlags); i++ { - aggregate.Add(*aggregate, deserializedDummyFlags[i]) - } - - // execute aggregate request - aggResultChan := make(chan libunlynx.CipherText) - aggErrChan := make(chan error) + // execute key switching request + ksResultChan := make(chan libunlynx.CipherText) + ksErrChan := make(chan error) go func() { - _, aggResult, _, aggErr := unlynxClient.SendSurveyAggRequest( + _, ksResult, _, ksErr := unlynxClient.SendSurveyAggRequest( cothorityRoster, - servicesmedco.SurveyID(queryName + "_AGG"), - deserializedClientPubKey, - *aggregate, + servicesmedco.SurveyID(queryName + "_KS"), + desTargetKey, + desValue, false, ) - if aggErr != nil { - aggErrChan <- aggErr + if ksErr != nil { + ksErrChan <- ksErr } else { - aggResultChan <- aggResult + ksResultChan <- ksResult } }() select { - case aggResult := <-aggResultChan: - agg = aggResult.Serialize() + case ksResult := <-ksResultChan: + keySwitchedValue = ksResult.Serialize() - case err = <-aggErrChan: - logrus.Error("unlynx error executing aggregation: ", err) + case err = <-ksErrChan: + logrus.Error("unlynx error executing key switching: ", err) case <-time.After(time.Duration(util.UnlynxTimeoutSeconds) * time.Second): err = errors.New("unlynx timeout") diff --git a/unlynx/client_test.go b/unlynx/client_test.go index f6662c19..1fe9ea53 100644 --- a/unlynx/client_test.go +++ b/unlynx/client_test.go @@ -41,7 +41,7 @@ func TestGetQueryTermsDDT(t *testing.T) { encryptedInt1 := libunlynx.EncryptInt(cothorityRoster.Aggregate, 2).Serialize() t.Log(encryptedInt0, encryptedInt1) - tags, err := GetQueryTermsDDT("test query " + time.Now().Format(time.RFC3339Nano), []string{ + tags, err := DDTagValues("test query " + time.Now().Format(time.RFC3339Nano), []string{ encryptedInt0, encryptedInt1, }) From 1e12156444c5faebf113b9b3c4374cf2d11f0283 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Tue, 14 May 2019 18:53:27 +0200 Subject: [PATCH 02/41] swagger: modify patient list response --- swagger/models/query_result_element.go | 74 ++------------------------ swagger/restapi/embedded_spec.go | 30 ++++------- swagger/swagger.yml | 7 +-- 3 files changed, 15 insertions(+), 96 deletions(-) diff --git a/swagger/models/query_result_element.go b/swagger/models/query_result_element.go index 44ea66dd..6760c0f8 100644 --- a/swagger/models/query_result_element.go +++ b/swagger/models/query_result_element.go @@ -6,11 +6,8 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - "strconv" - strfmt "github.com/go-openapi/strfmt" - "github.com/go-openapi/errors" "github.com/go-openapi/swag" ) @@ -21,49 +18,15 @@ type QueryResultElement struct { // encrypted count EncryptedCount string `json:"encryptedCount,omitempty"` + // encrypted patient list + EncryptedPatientList []string `json:"encryptedPatientList"` + // encryption key EncryptionKey string `json:"encryptionKey,omitempty"` - - // patient list - PatientList []*QueryResultElementPatientListItems0 `json:"patientList"` } // Validate validates this query result element func (m *QueryResultElement) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validatePatientList(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *QueryResultElement) validatePatientList(formats strfmt.Registry) error { - - if swag.IsZero(m.PatientList) { // not required - return nil - } - - for i := 0; i < len(m.PatientList); i++ { - if swag.IsZero(m.PatientList[i]) { // not required - continue - } - - if m.PatientList[i] != nil { - if err := m.PatientList[i].Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("patientList" + "." + strconv.Itoa(i)) - } - return err - } - } - - } - return nil } @@ -84,34 +47,3 @@ func (m *QueryResultElement) UnmarshalBinary(b []byte) error { *m = res return nil } - -// QueryResultElementPatientListItems0 query result element patient list items0 -// swagger:model QueryResultElementPatientListItems0 -type QueryResultElementPatientListItems0 struct { - - // id - ID string `json:"id,omitempty"` -} - -// Validate validates this query result element patient list items0 -func (m *QueryResultElementPatientListItems0) Validate(formats strfmt.Registry) error { - return nil -} - -// MarshalBinary interface implementation -func (m *QueryResultElementPatientListItems0) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *QueryResultElementPatientListItems0) UnmarshalBinary(b []byte) error { - var res QueryResultElementPatientListItems0 - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/swagger/restapi/embedded_spec.go b/swagger/restapi/embedded_spec.go index a46e574d..57542cb0 100644 --- a/swagger/restapi/embedded_spec.go +++ b/swagger/restapi/embedded_spec.go @@ -385,19 +385,14 @@ func init() { "encryptedCount": { "type": "string" }, - "encryptionKey": { - "type": "string" - }, - "patientList": { + "encryptedPatientList": { "type": "array", "items": { - "type": "object", - "properties": { - "id": { - "type": "string" - } - } + "type": "string" } + }, + "encryptionKey": { + "type": "string" } } }, @@ -1121,19 +1116,14 @@ func init() { "encryptedCount": { "type": "string" }, - "encryptionKey": { - "type": "string" - }, - "patientList": { + "encryptedPatientList": { "type": "array", "items": { - "type": "object", - "properties": { - "id": { - "type": "string" - } - } + "type": "string" } + }, + "encryptionKey": { + "type": "string" } } }, diff --git a/swagger/swagger.yml b/swagger/swagger.yml index 7acaea79..43216241 100644 --- a/swagger/swagger.yml +++ b/swagger/swagger.yml @@ -378,13 +378,10 @@ definitions: type: "string" encryptionKey: type: "string" - patientList: + encryptedPatientList: type: "array" items: - type: "object" - properties: - id: - type: "string" + type: "string" queryStatus: type: "object" From 087f2f2ffeaaf221fbb4e8d949cc4bcd7abc6b44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Thu, 16 May 2019 14:34:26 +0200 Subject: [PATCH 03/41] split up unlynx client into local/distributed files; add functions to access more unlynx protocols (aggregate, shuffle, key switch); add local homomorphic multiplication --- unlynx/client.go | 179 --------------- unlynx/client_distributed.go | 216 ++++++++++++++++++ ...ent_test.go => client_distributed_test.go} | 0 unlynx/client_local.go | 39 ++++ unlynx/util.go | 58 +++++ 5 files changed, 313 insertions(+), 179 deletions(-) delete mode 100644 unlynx/client.go create mode 100644 unlynx/client_distributed.go rename unlynx/{client_test.go => client_distributed_test.go} (100%) create mode 100644 unlynx/client_local.go create mode 100644 unlynx/util.go diff --git a/unlynx/client.go b/unlynx/client.go deleted file mode 100644 index 218ea0f4..00000000 --- a/unlynx/client.go +++ /dev/null @@ -1,179 +0,0 @@ -package unlynx - -import ( - "errors" - "github.com/lca1/medco-connector/util" - "github.com/lca1/medco-unlynx/services" - "github.com/lca1/unlynx/lib" - "github.com/sirupsen/logrus" - "go.dedis.ch/onet/v3" - "go.dedis.ch/onet/v3/app" - "os" - "strconv" - "time" -) - -// DDTagValues makes request through unlynx to compute distributed deterministic tags of encrypted values -func DDTagValues(queryName string, values []string) (taggedValues map[string]string, err error) { - unlynxClient, cothorityRoster := newUnlynxClient() - - // todo: get time measurements - // tr.DDTRequestTimeCommunication = totalTime - tr.DDTRequestTimeExec - // tr.DDTParsingTime = parsingTime - // tr.DDTRequestTimeExec += tr.DDTParsingTime - // totalTime = around request - - // deserialize values - desValues, err := deserializeCipherVector(values) - if err != nil { - return - } - - // execute DDT - ddtResultsChan := make(chan []libunlynx.GroupingKey) - ddtErrChan := make(chan error) - go func() { - _, ddtResults, _, ddtErr := unlynxClient.SendSurveyDDTRequestTerms( - cothorityRoster, - servicesmedco.SurveyID(queryName + "_DDT"), - desValues, - false, - false, - ) - if ddtErr != nil { - ddtErrChan <- ddtErr - } else if len(ddtResults) == 0 || len(ddtResults) != len(values) { - ddtErrChan <- errors.New("unlynx inconsistent DDT results: #results=" + strconv.Itoa(len(ddtResults)) + ", #terms=" + strconv.Itoa(len(values))) - } else { - ddtResultsChan <- ddtResults - } - }() - - select { - case ddtResults := <-ddtResultsChan: - taggedValues = make(map[string]string) - for i, result := range ddtResults { - taggedValues[values[i]] = string(result) - } - - case err = <-ddtErrChan: - logrus.Error("unlynx error executing DDT: ", err) - - case <-time.After(time.Duration(util.UnlynxTimeoutSeconds) * time.Second): - err = errors.New("unlynx timeout") - logrus.Error(err) - } - return -} - -// AggregateValues adds together several encrypted values homomorphically -func AggregateValues(values []string) (agg string, err error) { - - // deserialize values - deserialized, err := deserializeCipherVector(values) - if err != nil { - return - } - - // local aggregation - aggregate := &deserialized[0] - for i := 1; i < len(deserialized); i++ { - aggregate.Add(*aggregate, deserialized[i]) - } - - return aggregate.Serialize(), nil -} - -// KeySwitchValue makes request through unlynx to key switch encrypted values -func KeySwitchValue(queryName string, value string, targetPubKey string) (keySwitchedValue string, err error) { - unlynxClient, cothorityRoster := newUnlynxClient() - - // todo: get time measurements - // tr.AggRequestTimeCommunication = totalTime - tr.DDTRequestTimeExec - // tr.LocalAggregationTime = aggregationTime - // tr.AggParsingTime = parsingTime - // tr.AggRequestTimeExec += tr.AggParsingTime + tr.LocalAggregationTime - - // deserialize value and target public key - desValue := libunlynx.CipherText{} - err = desValue.Deserialize(value) - if err != nil { - logrus.Error("unlynx error deserializing cipher text: ", err) - return - } - - desTargetKey, err := libunlynx.DeserializePoint(targetPubKey) - if err != nil { - logrus.Error("unlynx error deserializing target public key: ", err) - return - } - - // execute key switching request - ksResultChan := make(chan libunlynx.CipherText) - ksErrChan := make(chan error) - go func() { - _, ksResult, _, ksErr := unlynxClient.SendSurveyAggRequest( - cothorityRoster, - servicesmedco.SurveyID(queryName + "_KS"), - desTargetKey, - desValue, - false, - ) - if ksErr != nil { - ksErrChan <- ksErr - } else { - ksResultChan <- ksResult - } - }() - - select { - case ksResult := <-ksResultChan: - keySwitchedValue = ksResult.Serialize() - - case err = <-ksErrChan: - logrus.Error("unlynx error executing key switching: ", err) - - case <-time.After(time.Duration(util.UnlynxTimeoutSeconds) * time.Second): - err = errors.New("unlynx timeout") - logrus.Error(err) - } - return -} - -// deserializeCipherVector deserializes string-encoded cipher texts into a vector -func deserializeCipherVector(cipherTexts []string) (cipherVector libunlynx.CipherVector, err error) { - for _, cipherText := range cipherTexts { - deserialized := libunlynx.CipherText{} - err = deserialized.Deserialize(cipherText) - if err != nil { - logrus.Error("unlynx error deserializing cipher text: ", err) - return - } - - cipherVector = append(cipherVector, deserialized) - } - return -} - -// newUnlynxClient creates a new client to communicate with unlynx -func newUnlynxClient() (unlynxClient *servicesmedco.API, cothorityRoster *onet.Roster) { - - // initialize medco client - groupFile, err := os.Open(util.UnlynxGroupFilePath) - if err != nil { - logrus.Panic("unlynx error opening group file: ", err) - } - - group, err := app.ReadGroupDescToml(groupFile) - if err != nil || len(group.Roster.List) <= 0 { - logrus.Panic("unlynx error parsing group file: ", err) - } - - cothorityRoster = group.Roster - unlynxClient = servicesmedco.NewMedCoClient( - cothorityRoster.List[util.UnlynxGroupFileIdx], - strconv.Itoa(util.UnlynxGroupFileIdx), - ) - - return -} diff --git a/unlynx/client_distributed.go b/unlynx/client_distributed.go new file mode 100644 index 00000000..00df7e0a --- /dev/null +++ b/unlynx/client_distributed.go @@ -0,0 +1,216 @@ +package unlynx + +import ( + "errors" + "github.com/lca1/medco-connector/util" + "github.com/lca1/medco-unlynx/services" + "github.com/lca1/unlynx/lib" + "github.com/sirupsen/logrus" + "strconv" + "time" +) + +// todo: get time measurements in all functions +// tr.DDTRequestTimeCommunication = totalTime - tr.DDTRequestTimeExec +// tr.DDTParsingTime = parsingTime +// tr.DDTRequestTimeExec += tr.DDTParsingTime +// totalTime = around request + +// DDTagValues makes request through unlynx to compute distributed deterministic tags of encrypted values +func DDTagValues(queryName string, values []string) (taggedValues map[string]string, err error) { + unlynxClient, cothorityRoster := newUnlynxClient() + + // deserialize values + desValues, err := deserializeCipherVector(values) + if err != nil { + return + } + + // execute DDT + ddtResultsChan := make(chan []libunlynx.GroupingKey) + ddtErrChan := make(chan error) + go func() { + _, ddtResults, _, ddtErr := unlynxClient.SendSurveyDDTRequestTerms( + cothorityRoster, + servicesmedco.SurveyID(queryName + "_DDT"), + desValues, + false, + false, + ) + if ddtErr != nil { + ddtErrChan <- ddtErr + } else if len(ddtResults) == 0 || len(ddtResults) != len(values) { + ddtErrChan <- errors.New("unlynx inconsistent DDT results: #results=" + strconv.Itoa(len(ddtResults)) + ", #terms=" + strconv.Itoa(len(values))) + } else { + ddtResultsChan <- ddtResults + } + }() + + select { + case ddtResults := <-ddtResultsChan: + taggedValues = make(map[string]string) + for i, result := range ddtResults { + taggedValues[values[i]] = string(result) + } + + case err = <-ddtErrChan: + logrus.Error("unlynx error executing DDT: ", err) + + case <-time.After(time.Duration(util.UnlynxTimeoutSeconds) * time.Second): + err = errors.New("unlynx timeout") + logrus.Error(err) + } + return +} + +// KeySwitchValues makes request through unlynx to key switch a single encrypted value (convenience function) +func KeySwitchValue(queryName string, value string, targetPubKey string) (string, error) { + results, err := KeySwitchValues(queryName, []string{value}, targetPubKey) + return results[0], err +} + +// KeySwitchValues makes request through unlynx to key switch encrypted values +func KeySwitchValues(queryName string, values []string, targetPubKey string) (keySwitchedValues []string, err error) { + unlynxClient, cothorityRoster := newUnlynxClient() + + // deserialize values and target public key + desValues, err := deserializeCipherVector(values) + if err != nil { + return + } + + desTargetKey, err := libunlynx.DeserializePoint(targetPubKey) + if err != nil { + logrus.Error("unlynx error deserializing target public key: ", err) + return + } + + // execute key switching request + ksResultsChan := make(chan libunlynx.CipherVector) + ksErrChan := make(chan error) + go func() { + _, ksResult, _, ksErr := unlynxClient.SendSurveyKSRequest( + cothorityRoster, + servicesmedco.SurveyID(queryName + "_KS"), + desTargetKey, + desValues, + false, + ) + if ksErr != nil { + ksErrChan <- ksErr + } else { + ksResultsChan <- ksResult + } + }() + + select { + case ksResult := <-ksResultsChan: + keySwitchedValues = serializeCipherVector(ksResult) + + case err = <-ksErrChan: + logrus.Error("unlynx error executing key switching: ", err) + + case <-time.After(time.Duration(util.UnlynxTimeoutSeconds) * time.Second): + err = errors.New("unlynx timeout") + logrus.Error(err) + } + return +} + +// ShuffleAndKeySwitchValue makes request through unlynx to shuffle and key switch one value per node +func ShuffleAndKeySwitchValue(queryName string, value string, targetPubKey string) (shuffledKsValue string, err error) { + unlynxClient, cothorityRoster := newUnlynxClient() + + // deserialize value and target public key + desValue := libunlynx.CipherText{} + err = desValue.Deserialize(value) + if err != nil { + return + } + + desTargetKey, err := libunlynx.DeserializePoint(targetPubKey) + if err != nil { + logrus.Error("unlynx error deserializing target public key: ", err) + return + } + + // execute shuffle and key switching request + shuffleKsResultsChan := make(chan libunlynx.CipherText) + shuffleKsErrChan := make(chan error) + go func() { + _, shuffleKsResult, _, shuffleKsErr := unlynxClient.SendSurveyShuffleRequest( + cothorityRoster, + servicesmedco.SurveyID(queryName + "_SHUFFLE"), + desTargetKey, + desValue, + false, + ) + if shuffleKsErr != nil { + shuffleKsErrChan <- shuffleKsErr + } else { + shuffleKsResultsChan <- shuffleKsResult + } + }() + + select { + case shuffleKsResult := <-shuffleKsResultsChan: + shuffledKsValue = shuffleKsResult.Serialize() + + case err = <-shuffleKsErrChan: + logrus.Error("unlynx error executing shuffle and key switching: ", err) + + case <-time.After(time.Duration(util.UnlynxTimeoutSeconds) * time.Second): + err = errors.New("unlynx timeout") + logrus.Error(err) + } + return +} + +// AggregateAndKeySwitchValue makes request through unlynx to aggregate and key switch one value per node +func AggregateAndKeySwitchValue(queryName string, value string, targetPubKey string) (aggValue string, err error) { + unlynxClient, cothorityRoster := newUnlynxClient() + + // deserialize value and target public key + desValue := libunlynx.CipherText{} + err = desValue.Deserialize(value) + if err != nil { + return + } + + desTargetKey, err := libunlynx.DeserializePoint(targetPubKey) + if err != nil { + logrus.Error("unlynx error deserializing target public key: ", err) + return + } + + // execute shuffle and key switching request + aggKsResultsChan := make(chan libunlynx.CipherText) + aggKsErrChan := make(chan error) + go func() { + _, aggKsResult, _, aggKsErr := unlynxClient.SendSurveyAggRequest( + cothorityRoster, + servicesmedco.SurveyID(queryName + "_AGG"), + desTargetKey, + desValue, + false, + ) + if aggKsErr != nil { + aggKsErrChan <- aggKsErr + } else { + aggKsResultsChan <- aggKsResult + } + }() + + select { + case aggKsResult := <-aggKsResultsChan: + aggValue = aggKsResult.Serialize() + + case err = <-aggKsErrChan: + logrus.Error("unlynx error executing aggregate and key switching: ", err) + + case <-time.After(time.Duration(util.UnlynxTimeoutSeconds) * time.Second): + err = errors.New("unlynx timeout") + logrus.Error(err) + } + return +} diff --git a/unlynx/client_test.go b/unlynx/client_distributed_test.go similarity index 100% rename from unlynx/client_test.go rename to unlynx/client_distributed_test.go diff --git a/unlynx/client_local.go b/unlynx/client_local.go new file mode 100644 index 00000000..5a21b8dd --- /dev/null +++ b/unlynx/client_local.go @@ -0,0 +1,39 @@ +package unlynx + +import ( + libunlynx "github.com/lca1/unlynx/lib" + "github.com/sirupsen/logrus" +) + +// LocallyAggregateValues adds together several encrypted values homomorphically +func LocallyAggregateValues(values []string) (agg string, err error) { + + // deserialize values + deserialized, err := deserializeCipherVector(values) + if err != nil { + return + } + + // local aggregation + aggregate := &deserialized[0] + for i := 1; i < len(deserialized); i++ { + aggregate.Add(*aggregate, deserialized[i]) + } + + return aggregate.Serialize(), nil +} + +// LocallyMultiplyScalar multiply homomorphically an encrypted value with a clear-text scalar +func LocallyMultiplyScalar(encValue string, scalar int64) (res string, err error) { + + deserialized := libunlynx.CipherText{} + err = deserialized.Deserialize(encValue) + if err != nil { + logrus.Error("unlynx error deserializing cipher text: ", err) + return + } + + result := libunlynx.CipherText{} + result.MulCipherTextbyScalar(deserialized, libunlynx.SuiTe.Scalar().SetInt64(scalar)) + return result.Serialize(), nil +} diff --git a/unlynx/util.go b/unlynx/util.go new file mode 100644 index 00000000..af15d77c --- /dev/null +++ b/unlynx/util.go @@ -0,0 +1,58 @@ +package unlynx + +import ( + "github.com/lca1/medco-connector/util" + servicesmedco "github.com/lca1/medco-unlynx/services" + libunlynx "github.com/lca1/unlynx/lib" + "github.com/sirupsen/logrus" + "go.dedis.ch/onet/v3" + "go.dedis.ch/onet/v3/app" + "os" + "strconv" +) + +// serializeCipherVector serializes a vector of cipher texts into a string-encoded slice +func serializeCipherVector(cipherVector libunlynx.CipherVector) (serializedVector []string) { + for _, cipherText := range cipherVector { + serializedVector = append(serializedVector, cipherText.Serialize()) + } + return +} + +// deserializeCipherVector deserializes string-encoded cipher texts into a vector +func deserializeCipherVector(cipherTexts []string) (cipherVector libunlynx.CipherVector, err error) { + for _, cipherText := range cipherTexts { + deserialized := libunlynx.CipherText{} + err = deserialized.Deserialize(cipherText) + if err != nil { + logrus.Error("unlynx error deserializing cipher text: ", err) + return + } + + cipherVector = append(cipherVector, deserialized) + } + return +} + +// newUnlynxClient creates a new client to communicate with unlynx +func newUnlynxClient() (unlynxClient *servicesmedco.API, cothorityRoster *onet.Roster) { + + // initialize medco client + groupFile, err := os.Open(util.UnlynxGroupFilePath) + if err != nil { + logrus.Panic("unlynx error opening group file: ", err) + } + + group, err := app.ReadGroupDescToml(groupFile) + if err != nil || len(group.Roster.List) <= 0 { + logrus.Panic("unlynx error parsing group file: ", err) + } + + cothorityRoster = group.Roster + unlynxClient = servicesmedco.NewMedCoClient( + cothorityRoster.List[util.UnlynxGroupFileIdx], + strconv.Itoa(util.UnlynxGroupFileIdx), + ) + + return +} From 6bb62eb3eb729dae462309dae098666d0f51b013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Thu, 16 May 2019 14:36:03 +0200 Subject: [PATCH 04/41] split up implementation; add query type for authorizations and different types of queries; add support for query types patient list, shuffle, global aggregate --- medco/i2b2_medco_query.go | 100 ----------------- medco/picsure2_api_handlers.go | 24 ++++- medco/query_logic.go | 190 +++++++++++++++++++++++++++++++++ medco/query_type.go | 43 ++++++++ 4 files changed, 253 insertions(+), 104 deletions(-) delete mode 100644 medco/i2b2_medco_query.go create mode 100644 medco/query_logic.go create mode 100644 medco/query_type.go diff --git a/medco/i2b2_medco_query.go b/medco/i2b2_medco_query.go deleted file mode 100644 index 757e98e8..00000000 --- a/medco/i2b2_medco_query.go +++ /dev/null @@ -1,100 +0,0 @@ -package medco - -import ( - "errors" - "github.com/lca1/medco-connector/i2b2" - "github.com/lca1/medco-connector/swagger/models" - "github.com/lca1/medco-connector/unlynx" - "github.com/sirupsen/logrus" -) - -// I2b2MedCoQuery executes an i2b2-medco query -func I2b2MedCoQuery(queryName string, query *models.QueryI2b2Medco) (result *models.QueryResultElement, err error) { - // todo: timers - // todo: log query (with associated status) - // todo: query types (agregated per site, obfuscated per site, aggregated total) - // todo: query type: patient list - // todo: put user + query type + unique ID in query name - - // tag query terms - taggedQueryTerms, err := unlynx.DDTagValues(queryName, extractEncryptedQueryTerms(query.Panels)) - if err != nil { - return - } - logrus.Info(queryName, ": tagged ", len(taggedQueryTerms), " elements with unlynx") - - // i2b2 PSM query with tagged items - panelsItemKeys, panelsIsNot, err := prepareI2b2PsmQuery(query.Panels, taggedQueryTerms) - if err != nil { - return - } - - patientCount, patientSetID, err := i2b2.ExecutePsmQuery(queryName, panelsItemKeys, panelsIsNot) - if err != nil { - return - } - logrus.Info(queryName, ": got ", patientCount, " in patient set ", patientSetID, " with i2b2") - - // i2b2 PDO query to get the dummy flags - patientIDs, patientDummyFlags, err := i2b2.GetPatientSet(patientSetID) - if err != nil { - return - } - logrus.Info(queryName, ": got ", len(patientIDs), " patient IDs and ", len(patientDummyFlags), " dummy flags with i2b2") - - // aggregate patient dummy flags - aggPatientFlags, err := unlynx.AggregateValues(patientDummyFlags) - if err != nil { - return - } - - // key switch aggregated flags - encCount, err := unlynx.KeySwitchValue(queryName, aggPatientFlags, query.UserPublicKey) - if err != nil { - return - } - - result = &models.QueryResultElement{ - EncryptedCount: encCount, - EncryptionKey: query.UserPublicKey, - PatientList: nil, // todo: when implementing query type - } - return -} - -func extractEncryptedQueryTerms(panels []*models.QueryI2b2MedcoPanelsItems0) (encQueryTerms []string) { - for _, panel := range panels { - for _, item := range panel.Items { - if *item.Encrypted { - encQueryTerms = append(encQueryTerms, item.QueryTerm) - } - } - } - return -} - -func prepareI2b2PsmQuery(panels []*models.QueryI2b2MedcoPanelsItems0, taggedQueryTerms map[string]string) (panelsItemKeys [][]string, panelsIsNot []bool, err error) { - for panelIdx, panel := range panels { - panelsIsNot = append(panelsIsNot, *panel.Not) - - panelsItemKeys = append(panelsItemKeys, []string{}) - for _, item := range panel.Items { - var itemKey string - if *item.Encrypted { - - if tag, ok := taggedQueryTerms[item.QueryTerm]; ok { - itemKey = `\\SENSITIVE_TAGGED\medco\tagged\` + tag + `\` - } else { - err = errors.New("query error: encrypted term does not have corresponding tag") - logrus.Error(err) - return - } - - } else { - itemKey = item.QueryTerm - } - panelsItemKeys[panelIdx] = append(panelsItemKeys[panelIdx], itemKey) - } - } - return -} \ No newline at end of file diff --git a/medco/picsure2_api_handlers.go b/medco/picsure2_api_handlers.go index 3eca545b..787cf485 100644 --- a/medco/picsure2_api_handlers.go +++ b/medco/picsure2_api_handlers.go @@ -1,4 +1,5 @@ package medco + import( "github.com/go-openapi/runtime/middleware" "github.com/lca1/medco-connector/i2b2" @@ -57,6 +58,7 @@ func SearchHandlerFunc(params picsure2.SearchParams, principal *models.User) mid // QuerySyncHandlerFunc handles /query/sync API endpoint func QuerySyncHandlerFunc(params picsure2.QuerySyncParams, principal *models.User) middleware.Responder { + // authentication / authorization err := util.Authorize(params.Body.ResourceCredentials, principal) if err != nil { return picsure2.NewQuerySyncDefault(401).WithPayload(&picsure2.QuerySyncDefaultBody{ @@ -64,12 +66,26 @@ func QuerySyncHandlerFunc(params picsure2.QuerySyncParams, principal *models.Use }) } - queryResult, err := I2b2MedCoQuery(params.Body.Query.Name, params.Body.Query.I2b2Medco) + // resolve authorizations + queryType := resolveQueryType(params.Body.Query.I2b2Medco, principal) + + // execute query + query, err := NewI2b2MedCoQuery(params.Body.Query.Name, params.Body.Query.I2b2Medco) + if err != nil { + return picsure2.NewQuerySyncDefault(400).WithPayload(&picsure2.QuerySyncDefaultBody{ + Message: "Bad query: " + err.Error(), + }) + } + err = query.Execute(queryType) if err != nil { return picsure2.NewQuerySyncDefault(500).WithPayload(&picsure2.QuerySyncDefaultBody{ - Message: err.Error(), + Message: "Query execution error: " + err.Error(), }) } - return picsure2.NewQuerySyncOK().WithPayload(queryResult) -} \ No newline at end of file + return picsure2.NewQuerySyncOK().WithPayload(&models.QueryResultElement{ + EncryptedCount: query.queryResult.encCount, + EncryptionKey: query.query.UserPublicKey, + EncryptedPatientList: query.queryResult.encPatientList, + }) +} diff --git a/medco/query_logic.go b/medco/query_logic.go new file mode 100644 index 00000000..c7246d3e --- /dev/null +++ b/medco/query_logic.go @@ -0,0 +1,190 @@ +package medco + +import ( + "github.com/lca1/medco-connector/i2b2" + "github.com/lca1/medco-connector/swagger/models" + "github.com/lca1/medco-connector/unlynx" + "github.com/pkg/errors" + "github.com/sirupsen/logrus" + "strconv" +) + +// todo: timers +// todo: log query (with associated status) +// todo: query type obfuscated (DP) +// todo: put user + query type + unique ID in query name + +// I2b2MedCoQuery represents an i2b2-MedCo query to be executed +type I2b2MedCoQuery struct { + name string + query *models.QueryI2b2Medco + queryResult struct { + encCount string + encPatientList []string + } +} + +// NewI2b2MedCoQuery creates a new query object and checks its validity +func NewI2b2MedCoQuery(queryName string, query *models.QueryI2b2Medco) (new I2b2MedCoQuery, err error) { + new = I2b2MedCoQuery{ + name: queryName, + query: query, + } + return new, new.isValid() +} + +// todo: breakdown in i2b2 / count / patient list +// Execute implements the I2b2 MedCo query logic +func (q *I2b2MedCoQuery) Execute(queryType I2b2MedCoQueryType) (err error) { + + err = q.isValid() + if err != nil { + return + } + + // tag query terms + taggedQueryTerms, err := unlynx.DDTagValues(q.name, q.getEncQueryTerms()) + if err != nil { + return + } + logrus.Info(q.name, ": tagged ", len(taggedQueryTerms), " elements with unlynx") + + // i2b2 PSM query with tagged items + panelsItemKeys, panelsIsNot, err := q.getI2b2PsmQueryTerms(taggedQueryTerms) + if err != nil { + return + } + + patientCount, patientSetID, err := i2b2.ExecutePsmQuery(q.name, panelsItemKeys, panelsIsNot) + if err != nil { + return + } + logrus.Info(q.name, ": got ", patientCount, " in patient set ", patientSetID, " with i2b2") + + // i2b2 PDO query to get the dummy flags + patientIDs, patientDummyFlags, err := i2b2.GetPatientSet(patientSetID) + if err != nil { + return + } + logrus.Info(q.name, ": got ", len(patientIDs), " patient IDs and ", len(patientDummyFlags), " dummy flags with i2b2") + + // aggregate patient dummy flags + aggPatientFlags, err := unlynx.LocallyAggregateValues(patientDummyFlags) + if err != nil { + return + } + + // compute and key switch count (returns optionally global aggregate or shuffled results) + var encCount string + if !queryType.CountPerSite { + logrus.Info(q.name, ": global aggregate requested") + encCount, err = unlynx.AggregateAndKeySwitchValue(q.name, aggPatientFlags, q.query.UserPublicKey) + } else if queryType.Shuffled { + logrus.Info(q.name, ": count per site requested, shuffle enabled") + encCount, err = unlynx.ShuffleAndKeySwitchValue(q.name, aggPatientFlags, q.query.UserPublicKey) + } else { + logrus.Info(q.name, ": count per site requested, shuffle disabled") + encCount, err = unlynx.KeySwitchValue(q.name, aggPatientFlags, q.query.UserPublicKey) + } + if err != nil { + return + } + q.queryResult.encCount = encCount + logrus.Info(q.name, ": key switched count") + + // optionally prepare the patient list + if queryType.PatientList { + logrus.Info(q.name, ": patient list requested") + + // mask patient IDs + maskedPatientIDs, err := q.maskPatientIDs(patientIDs, patientDummyFlags) + if err != nil { + return + } + logrus.Info(q.name, ": masked ", len(maskedPatientIDs), " patient IDs") + + // key switch the masked patient IDs + ksMaskedPatientIDs, err := unlynx.KeySwitchValues(q.name, maskedPatientIDs, q.query.UserPublicKey) + if err != nil { + return + } + q.queryResult.encPatientList = ksMaskedPatientIDs + logrus.Info(q.name, ": key switched patient IDs") + } + + return +} + +// maskPatientIDs multiplies homomorphically patient IDs with their dummy flags to mask the dummy patients +func (q *I2b2MedCoQuery) maskPatientIDs(patientIDs []string, patientDummyFlags []string) (maskedPatientIDs []string, err error) { + + if len(patientIDs) != len(patientDummyFlags) { + err = errors.New("patient IDs and dummy flags do not have matching lengths") + logrus.Error(err) + return + } + + for idx, patientID := range patientIDs { + + patientIDInt, err := strconv.ParseInt(patientID, 10, 64) + if err != nil { + logrus.Error("error parsing patient ID " + patientID + " as an integer") + return + } + + maskedPatientID, err := unlynx.LocallyMultiplyScalar(patientDummyFlags[idx], patientIDInt) + if err != nil { + return + } + + maskedPatientIDs = append(maskedPatientIDs, maskedPatientID) + } + + return +} + +func (q *I2b2MedCoQuery) getEncQueryTerms() (encQueryTerms []string) { + for _, panel := range q.query.Panels { + for _, item := range panel.Items { + if *item.Encrypted { + encQueryTerms = append(encQueryTerms, item.QueryTerm) + } + } + } + return +} + +func (q *I2b2MedCoQuery) getI2b2PsmQueryTerms(taggedQueryTerms map[string]string) (panelsItemKeys [][]string, panelsIsNot []bool, err error) { + for panelIdx, panel := range q.query.Panels { + panelsIsNot = append(panelsIsNot, *panel.Not) + + panelsItemKeys = append(panelsItemKeys, []string{}) + for _, item := range panel.Items { + var itemKey string + if *item.Encrypted { + + if tag, ok := taggedQueryTerms[item.QueryTerm]; ok { + itemKey = `\\SENSITIVE_TAGGED\medco\tagged\` + tag + `\` + } else { + err = errors.New("query error: encrypted term does not have corresponding tag") + logrus.Error(err) + return + } + + } else { + itemKey = item.QueryTerm + } + panelsItemKeys[panelIdx] = append(panelsItemKeys[panelIdx], itemKey) + } + } + return +} + +// isValid checks the validity of the query +func (q *I2b2MedCoQuery) isValid() (err error) { + if len(q.name) == 0 || q.query == nil || len(q.query.UserPublicKey) == 0 { + err = errors.New("Query " + q.name + " is invalid") + logrus.Error(err) + } + return +} diff --git a/medco/query_type.go b/medco/query_type.go new file mode 100644 index 00000000..8dd8177e --- /dev/null +++ b/medco/query_type.go @@ -0,0 +1,43 @@ +package medco + +import "github.com/lca1/medco-connector/swagger/models" + +// I2b2MedCoQueryType encodes the requested results from the query +type I2b2MedCoQueryType struct { + + // PatientList encodes if the (encrypted) patient list is retrieved, otherwise only a count + PatientList bool + + // CountPerSite encodes if the retrieved count is per site, or aggregated over all nodes + CountPerSite bool + + // Shuffled encodes if the count per site if shuffled across all nodes for unlinkability + Shuffled bool + + // Obfuscated encodes if the count (per site or aggregated) should be obfuscated + Obfuscated bool + + // todo: include differential privacy requested +} + + +// resolveQueryType resolves the query type based on the user's authorizations and its request +func resolveQueryType(query *models.QueryI2b2Medco, userPrincipal *models.User) (queryType I2b2MedCoQueryType) { + // todo: authorizations param model to create + // todo: other authorizations + + queryType = I2b2MedCoQueryType{ + PatientList: false, + CountPerSite: true, // todo: from principal + Shuffled: true, // todo: from principal + Obfuscated: false, // todo: with DP implementation + } + + for _, selectedResult := range query.Select { + if selectedResult == "patient_list" { + queryType.PatientList = true + } + } + + return +} From 1fd8a7afeed21a7ba4e0f53bbb89a3f3a2b2d45e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Mon, 20 May 2019 18:01:35 +0200 Subject: [PATCH 05/41] swagger add support for query types and authorizations --- swagger/models/query.go | 89 ++++++++++++++++++++---------- swagger/models/query_type.go | 78 +++++++++++++++++++++++++++ swagger/models/user.go | 93 ++++++++++++++++++++++++++++++++ swagger/restapi/embedded_spec.go | 86 ++++++++++++++++++++++------- swagger/swagger.yml | 35 +++++++++--- 5 files changed, 328 insertions(+), 53 deletions(-) create mode 100644 swagger/models/query_type.go diff --git a/swagger/models/query.go b/swagger/models/query.go index ed5d7b9f..89c3c8d5 100644 --- a/swagger/models/query.go +++ b/swagger/models/query.go @@ -84,11 +84,14 @@ func (m *Query) UnmarshalBinary(b []byte) error { // swagger:model QueryI2b2Medco type QueryI2b2Medco struct { + // differential privacy + DifferentialPrivacy *QueryI2b2MedcoDifferentialPrivacy `json:"differentialPrivacy,omitempty"` + // i2b2 panels (linked by an AND) Panels []*QueryI2b2MedcoPanelsItems0 `json:"panels"` - // select - Select []string `json:"select"` + // query type + QueryType QueryType `json:"queryType,omitempty"` // user public key UserPublicKey string `json:"userPublicKey,omitempty"` @@ -98,11 +101,15 @@ type QueryI2b2Medco struct { func (m *QueryI2b2Medco) Validate(formats strfmt.Registry) error { var res []error + if err := m.validateDifferentialPrivacy(formats); err != nil { + res = append(res, err) + } + if err := m.validatePanels(formats); err != nil { res = append(res, err) } - if err := m.validateSelect(formats); err != nil { + if err := m.validateQueryType(formats); err != nil { res = append(res, err) } @@ -112,6 +119,24 @@ func (m *QueryI2b2Medco) Validate(formats strfmt.Registry) error { return nil } +func (m *QueryI2b2Medco) validateDifferentialPrivacy(formats strfmt.Registry) error { + + if swag.IsZero(m.DifferentialPrivacy) { // not required + return nil + } + + if m.DifferentialPrivacy != nil { + if err := m.DifferentialPrivacy.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("i2b2-medco" + "." + "differentialPrivacy") + } + return err + } + } + + return nil +} + func (m *QueryI2b2Medco) validatePanels(formats strfmt.Registry) error { if swag.IsZero(m.Panels) { // not required @@ -137,45 +162,55 @@ func (m *QueryI2b2Medco) validatePanels(formats strfmt.Registry) error { return nil } -var queryI2b2MedcoSelectItemsEnum []interface{} +func (m *QueryI2b2Medco) validateQueryType(formats strfmt.Registry) error { -func init() { - var res []string - if err := json.Unmarshal([]byte(`["count","patient_list"]`), &res); err != nil { - panic(err) - } - for _, v := range res { - queryI2b2MedcoSelectItemsEnum = append(queryI2b2MedcoSelectItemsEnum, v) + if swag.IsZero(m.QueryType) { // not required + return nil } -} -func (m *QueryI2b2Medco) validateSelectItemsEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, queryI2b2MedcoSelectItemsEnum); err != nil { + if err := m.QueryType.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("i2b2-medco" + "." + "queryType") + } return err } + return nil } -func (m *QueryI2b2Medco) validateSelect(formats strfmt.Registry) error { - - if swag.IsZero(m.Select) { // not required - return nil +// MarshalBinary interface implementation +func (m *QueryI2b2Medco) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil } + return swag.WriteJSON(m) +} - for i := 0; i < len(m.Select); i++ { +// UnmarshalBinary interface implementation +func (m *QueryI2b2Medco) UnmarshalBinary(b []byte) error { + var res QueryI2b2Medco + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} - // value enum - if err := m.validateSelectItemsEnum("i2b2-medco"+"."+"select"+"."+strconv.Itoa(i), "body", m.Select[i]); err != nil { - return err - } +// QueryI2b2MedcoDifferentialPrivacy differential privacy query parameters (todo) +// swagger:model QueryI2b2MedcoDifferentialPrivacy +type QueryI2b2MedcoDifferentialPrivacy struct { - } + // query budget + QueryBudget float64 `json:"queryBudget,omitempty"` +} +// Validate validates this query i2b2 medco differential privacy +func (m *QueryI2b2MedcoDifferentialPrivacy) Validate(formats strfmt.Registry) error { return nil } // MarshalBinary interface implementation -func (m *QueryI2b2Medco) MarshalBinary() ([]byte, error) { +func (m *QueryI2b2MedcoDifferentialPrivacy) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } @@ -183,8 +218,8 @@ func (m *QueryI2b2Medco) MarshalBinary() ([]byte, error) { } // UnmarshalBinary interface implementation -func (m *QueryI2b2Medco) UnmarshalBinary(b []byte) error { - var res QueryI2b2Medco +func (m *QueryI2b2MedcoDifferentialPrivacy) UnmarshalBinary(b []byte) error { + var res QueryI2b2MedcoDifferentialPrivacy if err := swag.ReadJSON(b, &res); err != nil { return err } diff --git a/swagger/models/query_type.go b/swagger/models/query_type.go new file mode 100644 index 00000000..91766b0b --- /dev/null +++ b/swagger/models/query_type.go @@ -0,0 +1,78 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "encoding/json" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/validate" +) + +// QueryType query type +// swagger:model queryType +type QueryType string + +const ( + + // QueryTypePatientList captures enum value "patient_list" + QueryTypePatientList QueryType = "patient_list" + + // QueryTypeCountPerSite captures enum value "count_per_site" + QueryTypeCountPerSite QueryType = "count_per_site" + + // QueryTypeCountPerSiteObfuscated captures enum value "count_per_site_obfuscated" + QueryTypeCountPerSiteObfuscated QueryType = "count_per_site_obfuscated" + + // QueryTypeCountPerSiteShuffled captures enum value "count_per_site_shuffled" + QueryTypeCountPerSiteShuffled QueryType = "count_per_site_shuffled" + + // QueryTypeCountPerSiteShuffledObfuscated captures enum value "count_per_site_shuffled_obfuscated" + QueryTypeCountPerSiteShuffledObfuscated QueryType = "count_per_site_shuffled_obfuscated" + + // QueryTypeCountGlobal captures enum value "count_global" + QueryTypeCountGlobal QueryType = "count_global" + + // QueryTypeCountGlobalObfuscated captures enum value "count_global_obfuscated" + QueryTypeCountGlobalObfuscated QueryType = "count_global_obfuscated" +) + +// for schema +var queryTypeEnum []interface{} + +func init() { + var res []QueryType + if err := json.Unmarshal([]byte(`["patient_list","count_per_site","count_per_site_obfuscated","count_per_site_shuffled","count_per_site_shuffled_obfuscated","count_global","count_global_obfuscated"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + queryTypeEnum = append(queryTypeEnum, v) + } +} + +func (m QueryType) validateQueryTypeEnum(path, location string, value QueryType) error { + if err := validate.Enum(path, location, value, queryTypeEnum); err != nil { + return err + } + return nil +} + +// Validate validates this query type +func (m QueryType) Validate(formats strfmt.Registry) error { + var res []error + + // value enum + if err := m.validateQueryTypeEnum("", "body", m); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/swagger/models/user.go b/swagger/models/user.go index 3bf94672..b9fc3a41 100644 --- a/swagger/models/user.go +++ b/swagger/models/user.go @@ -6,8 +6,11 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "strconv" + strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/errors" "github.com/go-openapi/swag" ) @@ -15,6 +18,9 @@ import ( // swagger:model user type User struct { + // authorizations + Authorizations *UserAuthorizations `json:"authorizations,omitempty"` + // id ID string `json:"id,omitempty"` @@ -24,6 +30,33 @@ type User struct { // Validate validates this user func (m *User) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAuthorizations(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *User) validateAuthorizations(formats strfmt.Registry) error { + + if swag.IsZero(m.Authorizations) { // not required + return nil + } + + if m.Authorizations != nil { + if err := m.Authorizations.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("authorizations") + } + return err + } + } + return nil } @@ -44,3 +77,63 @@ func (m *User) UnmarshalBinary(b []byte) error { *m = res return nil } + +// UserAuthorizations user authorizations +// swagger:model UserAuthorizations +type UserAuthorizations struct { + + // query type + QueryType []QueryType `json:"queryType"` +} + +// Validate validates this user authorizations +func (m *UserAuthorizations) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateQueryType(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *UserAuthorizations) validateQueryType(formats strfmt.Registry) error { + + if swag.IsZero(m.QueryType) { // not required + return nil + } + + for i := 0; i < len(m.QueryType); i++ { + + if err := m.QueryType[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("authorizations" + "." + "queryType" + "." + strconv.Itoa(i)) + } + return err + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *UserAuthorizations) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *UserAuthorizations) UnmarshalBinary(b []byte) error { + var res UserAuthorizations + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/swagger/restapi/embedded_spec.go b/swagger/restapi/embedded_spec.go index 57542cb0..c793c716 100644 --- a/swagger/restapi/embedded_spec.go +++ b/swagger/restapi/embedded_spec.go @@ -315,6 +315,15 @@ func init() { "description": "i2b2-medco query", "type": "object", "properties": { + "differentialPrivacy": { + "description": "differential privacy query parameters (todo)", + "type": "object", + "properties": { + "queryBudget": { + "type": "number" + } + } + }, "panels": { "description": "i2b2 panels (linked by an AND)", "type": "array", @@ -359,15 +368,8 @@ func init() { } } }, - "select": { - "type": "array", - "items": { - "type": "string", - "enum": [ - "count", - "patient_list" - ] - } + "queryType": { + "$ref": "#/definitions/queryType" }, "userPublicKey": { "type": "string" @@ -442,6 +444,18 @@ func init() { } } }, + "queryType": { + "type": "string", + "enum": [ + "patient_list", + "count_per_site", + "count_per_site_obfuscated", + "count_per_site_shuffled", + "count_per_site_shuffled_obfuscated", + "count_global", + "count_global_obfuscated" + ] + }, "resourceCredentials": { "type": "object", "properties": { @@ -528,6 +542,17 @@ func init() { "user": { "type": "object", "properties": { + "authorizations": { + "type": "object", + "properties": { + "queryType": { + "type": "array", + "items": { + "$ref": "#/definitions/queryType" + } + } + } + }, "id": { "type": "string" }, @@ -1046,6 +1071,15 @@ func init() { "description": "i2b2-medco query", "type": "object", "properties": { + "differentialPrivacy": { + "description": "differential privacy query parameters (todo)", + "type": "object", + "properties": { + "queryBudget": { + "type": "number" + } + } + }, "panels": { "description": "i2b2 panels (linked by an AND)", "type": "array", @@ -1090,15 +1124,8 @@ func init() { } } }, - "select": { - "type": "array", - "items": { - "type": "string", - "enum": [ - "count", - "patient_list" - ] - } + "queryType": { + "$ref": "#/definitions/queryType" }, "userPublicKey": { "type": "string" @@ -1173,6 +1200,18 @@ func init() { } } }, + "queryType": { + "type": "string", + "enum": [ + "patient_list", + "count_per_site", + "count_per_site_obfuscated", + "count_per_site_shuffled", + "count_per_site_shuffled_obfuscated", + "count_global", + "count_global_obfuscated" + ] + }, "resourceCredentials": { "type": "object", "properties": { @@ -1259,6 +1298,17 @@ func init() { "user": { "type": "object", "properties": { + "authorizations": { + "type": "object", + "properties": { + "queryType": { + "type": "array", + "items": { + "$ref": "#/definitions/queryType" + } + } + } + }, "id": { "type": "string" }, diff --git a/swagger/swagger.yml b/swagger/swagger.yml index 43216241..a3ee56a2 100644 --- a/swagger/swagger.yml +++ b/swagger/swagger.yml @@ -330,13 +330,14 @@ definitions: type: "object" description: "i2b2-medco query" properties: - select: - type: "array" - items: - type: "string" - enum: - - count - - patient_list + queryType: + $ref: "#/definitions/queryType" + differentialPrivacy: + type: "object" + description: "differential privacy query parameters (todo)" + properties: + queryBudget: + type: "number" panels: type: "array" description: "i2b2 panels (linked by an AND)" @@ -371,6 +372,17 @@ definitions: type: "object" description: "genomic annotations query (todo)" + queryType: + type: "string" + enum: + - patient_list + - count_per_site + - count_per_site_obfuscated + - count_per_site_shuffled + - count_per_site_shuffled_obfuscated + - count_global + - count_global_obfuscated + queryResultElement: type: "object" properties: @@ -423,4 +435,11 @@ definitions: id: type: "string" token: - type: "string" \ No newline at end of file + type: "string" + authorizations: + type: "object" + properties: + queryType: + type: "array" + items: + $ref: "#/definitions/queryType" From 2edd5337574f1f3547dec95bfb6ad18aec1cd0ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Mon, 20 May 2019 18:02:10 +0200 Subject: [PATCH 06/41] docker update to go 1.12; update dependencies (medco-unlynx) --- deployment/Dockerfile | 4 +- go.mod | 49 ++++++++++++---------- go.sum | 96 +++++++++++++++++++++++++++++-------------- 3 files changed, 94 insertions(+), 55 deletions(-) diff --git a/deployment/Dockerfile b/deployment/Dockerfile index d9125aa3..5cbbefc7 100644 --- a/deployment/Dockerfile +++ b/deployment/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.11 as build +FROM golang:1.12 as build COPY ./ /src @@ -8,7 +8,7 @@ RUN CGO_ENABLED=0 go build -v ./... && \ CGO_ENABLED=0 go install -v ./... # ------------------------------------------- -FROM golang:1.11-alpine as release +FROM golang:1.12-alpine as release COPY deployment/docker-entrypoint.sh /usr/local/bin/ RUN apk update && apk add bash && rm -rf /var/cache/apk/* && \ diff --git a/go.mod b/go.mod index f6df1217..e9fbdcb5 100644 --- a/go.mod +++ b/go.mod @@ -1,27 +1,32 @@ module github.com/lca1/medco-connector require ( - github.com/PuerkitoBio/purell v1.1.1 // indirect - github.com/go-openapi/analysis v0.18.0 // indirect - github.com/go-openapi/errors v0.18.0 - github.com/go-openapi/jsonpointer v0.18.0 // indirect - github.com/go-openapi/jsonreference v0.18.0 // indirect - github.com/go-openapi/loads v0.18.0 - github.com/go-openapi/runtime v0.18.0 - github.com/go-openapi/spec v0.18.0 - github.com/go-openapi/strfmt v0.18.0 - github.com/go-openapi/swag v0.18.0 - github.com/go-openapi/validate v0.18.0 - github.com/google/uuid v1.1.1 // indirect + github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a // indirect + github.com/docker/go-units v0.4.0 // indirect + github.com/go-openapi/analysis v0.19.0 // indirect + github.com/go-openapi/errors v0.19.0 + github.com/go-openapi/jsonpointer v0.19.0 // indirect + github.com/go-openapi/jsonreference v0.19.0 // indirect + github.com/go-openapi/loads v0.19.0 + github.com/go-openapi/runtime v0.19.0 + github.com/go-openapi/spec v0.19.0 + github.com/go-openapi/strfmt v0.19.0 + github.com/go-openapi/swag v0.19.0 + github.com/go-openapi/validate v0.19.0 + github.com/gopherjs/gopherjs v0.0.0-20190430165422-3e4dfb77656c // indirect github.com/jessevdk/go-flags v1.4.0 - github.com/lca1/medco-unlynx v0.0.0-20190326092154-e12359adb567 - github.com/lca1/unlynx v0.0.0-20190312131415-2e3533f65afe - github.com/lestrrat-go/jwx v0.0.0-20190415045601-bee008e7f2ee - github.com/lestrrat-go/pdebug v0.0.0-20180220043849-39f9a71bcabe // indirect - github.com/mailru/easyjson v0.0.0-20190221075403-6243d8e04c3f // indirect - github.com/pkg/errors v0.8.1 // indirect - github.com/sirupsen/logrus v1.4.0 - github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a // indirect - go.dedis.ch/onet/v3 v3.0.0 - golang.org/x/net v0.0.0-20190311183353-d8887717615a + github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect + github.com/lca1/medco-unlynx v0.0.0-20190520135023-7273e0cd4409 + github.com/lca1/unlynx v1.3.1 + github.com/lestrrat-go/jwx v0.0.0-20190520025545-5d60d87d07dd + github.com/mailru/easyjson v0.0.0-20190403194419-1ea4449da983 // indirect + github.com/pkg/errors v0.8.1 + github.com/sirupsen/logrus v1.4.2 + github.com/smartystreets/assertions v0.0.0-20190401211740-f487f9de1cd3 // indirect + go.dedis.ch/kyber/v3 v3.0.3 // indirect + go.dedis.ch/onet/v3 v3.0.12 + golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f // indirect + golang.org/x/net v0.0.0-20190514140710-3ec191127204 + golang.org/x/sys v0.0.0-20190516110030-61b9204099cb // indirect + golang.org/x/text v0.3.2 // indirect ) diff --git a/go.sum b/go.sum index 69cc00d1..43c90ae6 100644 --- a/go.sum +++ b/go.sum @@ -8,6 +8,8 @@ github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf h1:eg0MeVzsP1G42dRafH3vf+al2vQIJU0YHX+1Tw87oco= github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= +github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a h1:idn718Q4B6AGu/h5Sxe66HYVdqdGu2l9Iebqhi/AEoA= +github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= github.com/boltdb/bolt v1.3.1 h1:JQmyP4ZBrce+ZQu0dY660FMfatumYDLun9hBCUVIkF4= github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps= github.com/btcsuite/goleveldb v1.0.0 h1:Tvd0BfvqX9o823q1j2UZ/epQo09eJh6dTcRp79ilIN4= @@ -20,6 +22,8 @@ github.com/daviddengcn/go-colortext v0.0.0-20180409174941-186a3d44e920 h1:d/cVoZ github.com/daviddengcn/go-colortext v0.0.0-20180409174941-186a3d44e920/go.mod h1:dv4zxwHi5C/8AeI+4gX4dCWOIvNi7I6JCSX0HvlKPgE= github.com/docker/go-units v0.3.3 h1:Xk8S3Xj5sLGlG5g67hJmYMmUgXv5N4PhkjJHHqrwnTk= github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= +github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw= +github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/fanliao/go-concurrentMap v0.0.0-20141114143905-7d2d7a5ea67b h1:aHrWACMJZJ160Pl0qlH6s0/+5Kb1KYG/kEUTaZCW7QY= github.com/fanliao/go-concurrentMap v0.0.0-20141114143905-7d2d7a5ea67b/go.mod h1:DRc7ieGsJItxOsZ2lnqemj92zsSsBjBepuritZaumSE= github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= @@ -27,43 +31,52 @@ github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8 h1:DujepqpGd1hyOd7a github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= github.com/go-openapi/analysis v0.0.0-20180825180245-b006789cd277/go.mod h1:k70tL6pCuVxPJOHXQ+wIac1FUrvNkHolPie/cLEU6hI= github.com/go-openapi/analysis v0.17.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik= -github.com/go-openapi/analysis v0.17.2/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik= github.com/go-openapi/analysis v0.18.0 h1:hRMEymXOgwo7KLPqqFmw6t3jLO2/zxUe/TXjAHPq9Gc= github.com/go-openapi/analysis v0.18.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik= +github.com/go-openapi/analysis v0.19.0 h1:sYEyyO7OKQvJX0z4OyHWoGt0uLuALxB/ZJ4Jb3I6KNU= +github.com/go-openapi/analysis v0.19.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik= github.com/go-openapi/errors v0.17.0/go.mod h1:LcZQpmvG4wyF5j4IhA73wkLFQg+QJXOQHVjmcZxhka0= -github.com/go-openapi/errors v0.17.2/go.mod h1:LcZQpmvG4wyF5j4IhA73wkLFQg+QJXOQHVjmcZxhka0= github.com/go-openapi/errors v0.18.0 h1:+RnmJ5MQccF7jwWAoMzwOpzJEspZ18ZIWfg9Z2eiXq8= github.com/go-openapi/errors v0.18.0/go.mod h1:LcZQpmvG4wyF5j4IhA73wkLFQg+QJXOQHVjmcZxhka0= +github.com/go-openapi/errors v0.19.0 h1:guf3T2lnCBKlODmERt4T9GtMWRpJOikgKGyIvi0xcb8= +github.com/go-openapi/errors v0.19.0/go.mod h1:LcZQpmvG4wyF5j4IhA73wkLFQg+QJXOQHVjmcZxhka0= github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= -github.com/go-openapi/jsonpointer v0.17.2/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= github.com/go-openapi/jsonpointer v0.18.0 h1:KVRzjXpMzgdM4GEMDmDTnGcY5yBwGWreJwmmk4k35yU= github.com/go-openapi/jsonpointer v0.18.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= +github.com/go-openapi/jsonpointer v0.19.0 h1:FTUMcX77w5rQkClIzDtTxvn6Bsa894CcrzNj2MMfeg8= +github.com/go-openapi/jsonpointer v0.19.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= github.com/go-openapi/jsonreference v0.17.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= -github.com/go-openapi/jsonreference v0.17.2/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= github.com/go-openapi/jsonreference v0.18.0 h1:oP2OUNdG1l2r5kYhrfVMXO54gWmzcfAwP/GFuHpNTkE= github.com/go-openapi/jsonreference v0.18.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= +github.com/go-openapi/jsonreference v0.19.0 h1:BqWKpV1dFd+AuiKlgtddwVIFQsuMpxfBDBHGfM2yNpk= +github.com/go-openapi/jsonreference v0.19.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= github.com/go-openapi/loads v0.17.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= -github.com/go-openapi/loads v0.17.2/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= github.com/go-openapi/loads v0.18.0 h1:2A3goxrC4KuN8ZrMKHCqAAugtq6A6WfXVfOIKUbZ4n0= github.com/go-openapi/loads v0.18.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= +github.com/go-openapi/loads v0.19.0 h1:wCOBNscACI8L93tt5tvB2zOMkJ098XCw3fP0BY2ybDA= +github.com/go-openapi/loads v0.19.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= github.com/go-openapi/runtime v0.0.0-20180920151709-4f900dc2ade9/go.mod h1:6v9a6LTXWQCdL8k1AO3cvqx5OtZY/Y9wKTgaoP6YRfA= -github.com/go-openapi/runtime v0.18.0 h1:ddoL4Uo/729XbNAS9UIsG7Oqa8R8l2edBe6Pq/i8AHM= -github.com/go-openapi/runtime v0.18.0/go.mod h1:uI6pHuxWYTy94zZxgcwJkUWa9wbIlhteGfloI10GD4U= +github.com/go-openapi/runtime v0.19.0 h1:sU6pp4dSV2sGlNKKyHxZzi1m1kG4WnYtWcJ+HYbygjE= +github.com/go-openapi/runtime v0.19.0/go.mod h1:OwNfisksmmaZse4+gpV3Ne9AyMOlP1lt4sK4FXt0O64= github.com/go-openapi/spec v0.17.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= -github.com/go-openapi/spec v0.17.2/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= github.com/go-openapi/spec v0.18.0 h1:aIjeyG5mo5/FrvDkpKKEGZPmF9MPHahS72mzfVqeQXQ= github.com/go-openapi/spec v0.18.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= +github.com/go-openapi/spec v0.19.0 h1:A4SZ6IWh3lnjH0rG0Z5lkxazMGBECtrZcbyYQi+64k4= +github.com/go-openapi/spec v0.19.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= github.com/go-openapi/strfmt v0.17.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU= -github.com/go-openapi/strfmt v0.17.2/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU= github.com/go-openapi/strfmt v0.18.0 h1:FqqmmVCKn3di+ilU/+1m957T1CnMz3IteVUcV3aGXWA= github.com/go-openapi/strfmt v0.18.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU= +github.com/go-openapi/strfmt v0.19.0 h1:0Dn9qy1G9+UJfRU7TR8bmdGxb4uifB7HNrJjOnV0yPk= +github.com/go-openapi/strfmt v0.19.0/go.mod h1:+uW+93UVvGGq2qGaZxdDeJqSAqBqBdl+ZPMF/cC8nDY= github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= -github.com/go-openapi/swag v0.17.2/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= github.com/go-openapi/swag v0.18.0 h1:1DU8Km1MRGv9Pj7BNLmkA+umwTStwDHttXvx3NhJA70= github.com/go-openapi/swag v0.18.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= -github.com/go-openapi/validate v0.17.2/go.mod h1:Uh4HdOzKt19xGIGm1qHf/ofbX1YQ4Y+MYsct2VUrAJ4= +github.com/go-openapi/swag v0.19.0 h1:Kg7Wl7LkTPlmc393QZQ/5rQadPhi7pBVEMZxyTi0Ii8= +github.com/go-openapi/swag v0.19.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= github.com/go-openapi/validate v0.18.0 h1:PVXYcP1GkTl+XIAJnyJxOmK6CSG5Q1UcvoCvNO++5Kg= github.com/go-openapi/validate v0.18.0/go.mod h1:Uh4HdOzKt19xGIGm1qHf/ofbX1YQ4Y+MYsct2VUrAJ4= +github.com/go-openapi/validate v0.19.0 h1:SF5vyj6PBFM6D1cw2NJIFrlS8Su2YKk6ADPPjAH70Bw= +github.com/go-openapi/validate v0.19.0/go.mod h1:Uh4HdOzKt19xGIGm1qHf/ofbX1YQ4Y+MYsct2VUrAJ4= github.com/golangplus/bytes v0.0.0-20160111154220-45c989fe5450 h1:7xqw01UYS+KCI25bMrPxwNYkSns2Db1ziQPpVq99FpE= github.com/golangplus/bytes v0.0.0-20160111154220-45c989fe5450/go.mod h1:Bk6SMAONeMXrxql8uvOKuAZSu8aM5RUGv+1C6IJaEho= github.com/golangplus/fmt v0.0.0-20150411045040-2a5d6d7d2995 h1:f5gsjBiF9tRRVomCvrkGMMWI8W1f2OBFar2c5oakAP0= @@ -71,11 +84,12 @@ github.com/golangplus/fmt v0.0.0-20150411045040-2a5d6d7d2995/go.mod h1:lJgMEyOkY github.com/golangplus/testing v0.0.0-20180327235837-af21d9c3145e h1:KhcknUwkWHKZPbFy2P7jH5LKJ3La+0ZeknkkmrSgqb0= github.com/golangplus/testing v0.0.0-20180327235837-af21d9c3145e/go.mod h1:0AA//k/eakGydO4jKRoRL2j92ZKSzTgj9tclaCrvXHk= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.1.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gopherjs/gopherjs v0.0.0-20190430165422-3e4dfb77656c h1:7lF+Vz0LqiRidnzC1Oq86fpX1q/iEv2KJdrCtttYjT4= +github.com/gopherjs/gopherjs v0.0.0-20190430165422-3e4dfb77656c/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA= @@ -84,23 +98,24 @@ github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7 github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s= +github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/lca1/medco-unlynx v0.0.0-20190326092154-e12359adb567 h1:f8mduTZYHphUUdp7hL5B+ZlYna4j/4BDzo5dx4c4rak= -github.com/lca1/medco-unlynx v0.0.0-20190326092154-e12359adb567/go.mod h1:1684yL2mbYGMM5KG+ANuDQXq58tYq5kVJde9RI0iisY= -github.com/lca1/unlynx v0.0.0-20190312131415-2e3533f65afe h1:WHc+KZi5aiGJJyNcADipOkaB+d1TWE7nVEwzDzFfi8A= -github.com/lca1/unlynx v0.0.0-20190312131415-2e3533f65afe/go.mod h1:iVlai2WR/UbMOeozxL2uOuLK2AQ+pcEl0Hkepk1ub3g= -github.com/lestrrat-go/jwx v0.0.0-20190415045601-bee008e7f2ee h1:VOIDjd8ZXCGDfeWERYG8QHmKdL0ldnkTIdKAhnZhm/M= -github.com/lestrrat-go/jwx v0.0.0-20190415045601-bee008e7f2ee/go.mod h1:iEoxlYfZjvoGpuWwxUz+eR5e6KTJGsaRcy/YNA/UnBk= -github.com/lestrrat-go/pdebug v0.0.0-20180220043849-39f9a71bcabe h1:S7XSBlgc/eI2v47LkPPVa+infH3FuTS4tPJbqCtJovo= -github.com/lestrrat-go/pdebug v0.0.0-20180220043849-39f9a71bcabe/go.mod h1:zvUY6gZZVL2nu7NM+/3b51Z/hxyFZCZxV0hvfZ3NJlg= -github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lca1/medco-unlynx v0.0.0-20190520135023-7273e0cd4409 h1:JMzXDulliMydz3vckJePLq7bApeQ5ZopsoEE2Og6Z9I= +github.com/lca1/medco-unlynx v0.0.0-20190520135023-7273e0cd4409/go.mod h1:ye1nTpn1fuEoRC5V+cM0ykbjEwvcgN6eXsM2rIN89T0= +github.com/lca1/unlynx v1.3.1 h1:l/sLi4DGL9Rlvk6ySzR13VYjgbubY1tMHPyXGvd2zZU= +github.com/lca1/unlynx v1.3.1/go.mod h1:HOR8K2JLrylJjIDdMdFev5rE5q6XGifs0OnH7rvreqY= +github.com/lestrrat-go/jwx v0.0.0-20190520025545-5d60d87d07dd h1:LlBVT5LW5RiBhlLGhvAJwPSQrQe4cF/lJfciixiUauw= +github.com/lestrrat-go/jwx v0.0.0-20190520025545-5d60d87d07dd/go.mod h1:iEoxlYfZjvoGpuWwxUz+eR5e6KTJGsaRcy/YNA/UnBk= +github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mailru/easyjson v0.0.0-20190221075403-6243d8e04c3f h1:B6PQkurxGG1rqEX96oE14gbj8bqvYC5dtks9r5uGmlE= -github.com/mailru/easyjson v0.0.0-20190221075403-6243d8e04c3f/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.0.0-20190403194419-1ea4449da983 h1:wL11wNW7dhKIcRCHSm4sHKPWz0tt4mwBsVodG7+Xyqg= +github.com/mailru/easyjson v0.0.0-20190403194419-1ea4449da983/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/montanaflynn/stats v0.5.0 h1:2EkzeTSqBB4V4bJwWrt5gIIrZmpJBcoIRGS2kWLgzmk= @@ -116,10 +131,12 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/r0fls/gostats v0.0.0-20180711082619-e793b1fda35c/go.mod h1:2mJY7Hx2k1GaMAmiAoyy090oY3RTSk3kkaaTieLq7wc= github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= -github.com/sirupsen/logrus v1.4.0 h1:yKenngtzGh+cUSSh6GWbxW2abRqhYUSR/t/6+2QqNvE= -github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/assertions v0.0.0-20190401211740-f487f9de1cd3 h1:hBSHahWMEgzwRyS6dRpxY0XyjZsHyQ61s084wo5PJe0= +github.com/smartystreets/assertions v0.0.0-20190401211740-f487f9de1cd3/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a h1:pa8hGb/2YqsZKovtsgrwcDH1RZhVbTKCjLp47XpqCDs= github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -132,32 +149,49 @@ go.dedis.ch/fixbuf v1.0.3/go.mod h1:yzJMt34Wa5xD37V5RTdmp38cz3QhMagdGoem9anUalw= go.dedis.ch/kyber/v3 v3.0.0-pre2/go.mod h1:OzvaEnPvKlyrWyp3kGXlFdp7ap1VC6RkZDTaPikqhsQ= go.dedis.ch/kyber/v3 v3.0.0 h1:XuefPFGJKPyfPBD6kXctbLb4smT9Il5HmUn303JRr08= go.dedis.ch/kyber/v3 v3.0.0/go.mod h1:OzvaEnPvKlyrWyp3kGXlFdp7ap1VC6RkZDTaPikqhsQ= +go.dedis.ch/kyber/v3 v3.0.2/go.mod h1:OzvaEnPvKlyrWyp3kGXlFdp7ap1VC6RkZDTaPikqhsQ= +go.dedis.ch/kyber/v3 v3.0.3 h1:XdqCfDQSuSJli/KhO5jnUFfcr8GWfMimwnwScOH5Lg8= +go.dedis.ch/kyber/v3 v3.0.3/go.mod h1:OzvaEnPvKlyrWyp3kGXlFdp7ap1VC6RkZDTaPikqhsQ= go.dedis.ch/onet/v3 v3.0.0 h1:haBqkwkNNu/jHz7+PoZJS+xbtA5JheQvt0SSIjGyk5I= go.dedis.ch/onet/v3 v3.0.0/go.mod h1:xqmP2+NvxeNzgmNj/4hf56EZm3KT0Qksz98miZw5G3A= +go.dedis.ch/onet/v3 v3.0.6/go.mod h1:0wrof0zfyD+Qfw9Pfhu9jW+bTbwwWBzC1hMuV/c8v2w= +go.dedis.ch/onet/v3 v3.0.12 h1:hqo54/Noh9J4EsFz2KEYb/r7bFhiI5hSClGGVUJDcDk= +go.dedis.ch/onet/v3 v3.0.12/go.mod h1:8zNbWaMMpTiBfa8gftpoe726sivOF1ymxqkiPuvpdFA= go.dedis.ch/protobuf v1.0.5/go.mod h1:eIV4wicvi6JK0q/QnfIEGeSFNG0ZeB24kzut5+HaRLo= go.dedis.ch/protobuf v1.0.6 h1:E61p2XjYbYrTf3WeXE8M8Ui5WA3hX/NgbHHi5D0FLxI= go.dedis.ch/protobuf v1.0.6/go.mod h1:YHYXW6dQ9p2iJ3f+2fxKnOpjGx0MvL4cwpg1RVNXaV8= go.etcd.io/bbolt v1.3.0 h1:oY10fI923Q5pVCVt1GBTZMn8LHo5M+RCInFpeMnV4QI= go.etcd.io/bbolt v1.3.0/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= -golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +go.etcd.io/bbolt v1.3.2 h1:Z/90sZLPOeCy2PwprqkFa25PdkusRzaj9P8zm/KNyvk= +go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= golang.org/x/crypto v0.0.0-20190123085648-057139ce5d2b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f h1:hX65Cu3JDlGH3uEdK7I99Ii+9kjD6mvnnpfLdEAH0x4= -golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/crypto v0.0.0-20190320223903-b7391e95e576/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f h1:R423Cnkcp5JABoeemiGEPlt9tHXFfw5kvc0yqlxRPWo= +golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/net v0.0.0-20190320064053-1272bf9dcd53/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190514140710-3ec191127204 h1:4yG6GqBtw9C+UrLp6s2wtSniayy/Vd/3F7ffLE427XI= +golang.org/x/net v0.0.0-20190514140710-3ec191127204/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sys v0.0.0-20190124100055-b90733256f2e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190321052220-f7bb7a8bee54/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190516110030-61b9204099cb h1:k07iPOt0d6nEnwXF+kHB+iEg+WSuKe/SOQuFM2QoD+E= +golang.org/x/sys v0.0.0-20190516110030-61b9204099cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/tools v0.0.0-20190311215038-5c2858a9cfe5/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384 h1:TFlARGu6Czu1z7q93HTxcP1P+/ZFC/IKythI5RzrnRg= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From e6ee284054b92fcaa0f942b555210392aa304765 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Mon, 20 May 2019 18:03:11 +0200 Subject: [PATCH 07/41] modifications to be combatible with updated medco-unlynx --- unlynx/client_distributed.go | 23 ++++++++++++++++------- unlynx/client_local.go | 13 +++++++++++-- unlynx/util.go | 11 +++++++++-- 3 files changed, 36 insertions(+), 11 deletions(-) diff --git a/unlynx/client_distributed.go b/unlynx/client_distributed.go index 00df7e0a..5279329f 100644 --- a/unlynx/client_distributed.go +++ b/unlynx/client_distributed.go @@ -30,7 +30,7 @@ func DDTagValues(queryName string, values []string) (taggedValues map[string]str ddtResultsChan := make(chan []libunlynx.GroupingKey) ddtErrChan := make(chan error) go func() { - _, ddtResults, _, ddtErr := unlynxClient.SendSurveyDDTRequestTerms( + _, ddtResults, ddtErr := unlynxClient.SendSurveyDDTRequestTerms( cothorityRoster, servicesmedco.SurveyID(queryName + "_DDT"), desValues, @@ -89,7 +89,7 @@ func KeySwitchValues(queryName string, values []string, targetPubKey string) (ke ksResultsChan := make(chan libunlynx.CipherVector) ksErrChan := make(chan error) go func() { - _, ksResult, _, ksErr := unlynxClient.SendSurveyKSRequest( + _, ksResult, ksErr := unlynxClient.SendSurveyKSRequest( cothorityRoster, servicesmedco.SurveyID(queryName + "_KS"), desTargetKey, @@ -105,7 +105,10 @@ func KeySwitchValues(queryName string, values []string, targetPubKey string) (ke select { case ksResult := <-ksResultsChan: - keySwitchedValues = serializeCipherVector(ksResult) + keySwitchedValues, err = serializeCipherVector(ksResult) + if err != nil { + logrus.Error("unlynx error serializing: ", err) + } case err = <-ksErrChan: logrus.Error("unlynx error executing key switching: ", err) @@ -138,7 +141,7 @@ func ShuffleAndKeySwitchValue(queryName string, value string, targetPubKey strin shuffleKsResultsChan := make(chan libunlynx.CipherText) shuffleKsErrChan := make(chan error) go func() { - _, shuffleKsResult, _, shuffleKsErr := unlynxClient.SendSurveyShuffleRequest( + _, shuffleKsResult, shuffleKsErr := unlynxClient.SendSurveyShuffleRequest( cothorityRoster, servicesmedco.SurveyID(queryName + "_SHUFFLE"), desTargetKey, @@ -154,7 +157,10 @@ func ShuffleAndKeySwitchValue(queryName string, value string, targetPubKey strin select { case shuffleKsResult := <-shuffleKsResultsChan: - shuffledKsValue = shuffleKsResult.Serialize() + shuffledKsValue, err = shuffleKsResult.Serialize() + if err != nil { + logrus.Error("unlynx error serializing: ", err) + } case err = <-shuffleKsErrChan: logrus.Error("unlynx error executing shuffle and key switching: ", err) @@ -187,7 +193,7 @@ func AggregateAndKeySwitchValue(queryName string, value string, targetPubKey str aggKsResultsChan := make(chan libunlynx.CipherText) aggKsErrChan := make(chan error) go func() { - _, aggKsResult, _, aggKsErr := unlynxClient.SendSurveyAggRequest( + _, aggKsResult, aggKsErr := unlynxClient.SendSurveyAggRequest( cothorityRoster, servicesmedco.SurveyID(queryName + "_AGG"), desTargetKey, @@ -203,7 +209,10 @@ func AggregateAndKeySwitchValue(queryName string, value string, targetPubKey str select { case aggKsResult := <-aggKsResultsChan: - aggValue = aggKsResult.Serialize() + aggValue, err = aggKsResult.Serialize() + if err != nil { + logrus.Error("unlynx error serializing: ", err) + } case err = <-aggKsErrChan: logrus.Error("unlynx error executing aggregate and key switching: ", err) diff --git a/unlynx/client_local.go b/unlynx/client_local.go index 5a21b8dd..20302cf2 100644 --- a/unlynx/client_local.go +++ b/unlynx/client_local.go @@ -20,7 +20,11 @@ func LocallyAggregateValues(values []string) (agg string, err error) { aggregate.Add(*aggregate, deserialized[i]) } - return aggregate.Serialize(), nil + agg, err = aggregate.Serialize() + if err != nil { + logrus.Error("unlynx error serializing: ", err) + } + return } // LocallyMultiplyScalar multiply homomorphically an encrypted value with a clear-text scalar @@ -35,5 +39,10 @@ func LocallyMultiplyScalar(encValue string, scalar int64) (res string, err error result := libunlynx.CipherText{} result.MulCipherTextbyScalar(deserialized, libunlynx.SuiTe.Scalar().SetInt64(scalar)) - return result.Serialize(), nil + + res, err = result.Serialize() + if err != nil { + logrus.Error("unlynx error serializing: ", err) + } + return } diff --git a/unlynx/util.go b/unlynx/util.go index af15d77c..1ab08155 100644 --- a/unlynx/util.go +++ b/unlynx/util.go @@ -12,9 +12,16 @@ import ( ) // serializeCipherVector serializes a vector of cipher texts into a string-encoded slice -func serializeCipherVector(cipherVector libunlynx.CipherVector) (serializedVector []string) { +func serializeCipherVector(cipherVector libunlynx.CipherVector) (serializedVector []string, err error) { for _, cipherText := range cipherVector { - serializedVector = append(serializedVector, cipherText.Serialize()) + + serialized, err := cipherText.Serialize() + if err != nil { + logrus.Error("unlynx error serializing: ", err) + return nil, err + } + + serializedVector = append(serializedVector, serialized) } return } From bcb2e0c01a3f46ce2aa04f3deca0425485583eff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Mon, 20 May 2019 18:03:31 +0200 Subject: [PATCH 08/41] fix shadowed variables --- medco/query_logic.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/medco/query_logic.go b/medco/query_logic.go index c7246d3e..1c981d3c 100644 --- a/medco/query_logic.go +++ b/medco/query_logic.go @@ -99,14 +99,14 @@ func (q *I2b2MedCoQuery) Execute(queryType I2b2MedCoQueryType) (err error) { // mask patient IDs maskedPatientIDs, err := q.maskPatientIDs(patientIDs, patientDummyFlags) if err != nil { - return + return err } logrus.Info(q.name, ": masked ", len(maskedPatientIDs), " patient IDs") // key switch the masked patient IDs ksMaskedPatientIDs, err := unlynx.KeySwitchValues(q.name, maskedPatientIDs, q.query.UserPublicKey) if err != nil { - return + return err } q.queryResult.encPatientList = ksMaskedPatientIDs logrus.Info(q.name, ": key switched patient IDs") @@ -129,12 +129,12 @@ func (q *I2b2MedCoQuery) maskPatientIDs(patientIDs []string, patientDummyFlags [ patientIDInt, err := strconv.ParseInt(patientID, 10, 64) if err != nil { logrus.Error("error parsing patient ID " + patientID + " as an integer") - return + return nil, err } maskedPatientID, err := unlynx.LocallyMultiplyScalar(patientDummyFlags[idx], patientIDInt) if err != nil { - return + return nil, err } maskedPatientIDs = append(maskedPatientIDs, maskedPatientID) From f370fb11839850f7c681c98b51b98a7d32a97cc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Tue, 21 May 2019 14:15:05 +0200 Subject: [PATCH 09/41] bug fix: zero results crash --- unlynx/client_local.go | 5 +++++ unlynx/util.go | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/unlynx/client_local.go b/unlynx/client_local.go index 20302cf2..91bd4948 100644 --- a/unlynx/client_local.go +++ b/unlynx/client_local.go @@ -6,8 +6,13 @@ import ( ) // LocallyAggregateValues adds together several encrypted values homomorphically +// if there are no values, the value zero encrypted is returned func LocallyAggregateValues(values []string) (agg string, err error) { + if len(values) == 0 { + return getEncryptedZero() + } + // deserialize values deserialized, err := deserializeCipherVector(values) if err != nil { diff --git a/unlynx/util.go b/unlynx/util.go index 1ab08155..cf61b5a7 100644 --- a/unlynx/util.go +++ b/unlynx/util.go @@ -63,3 +63,14 @@ func newUnlynxClient() (unlynxClient *servicesmedco.API, cothorityRoster *onet.R return } + +// getEncryptedZero returns an encrypted zero +func getEncryptedZero() (serializedZero string, err error) { + _, cothorityRoster := newUnlynxClient() + encZero := libunlynx.EncryptInt(cothorityRoster.Aggregate, 0) + serializedZero, err = encZero.Serialize() + if err != nil { + logrus.Error("unlynx failed serializing zero: ", err) + } + return +} \ No newline at end of file From 7db17d40c9e5070f1a349ca397c9cf45d1a7da50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Tue, 21 May 2019 14:36:02 +0200 Subject: [PATCH 10/41] return query type in answer --- medco/picsure2_api_handlers.go | 1 + swagger/models/query_result_element.go | 29 ++++++++++++++++++++++++++ swagger/restapi/embedded_spec.go | 6 ++++++ swagger/swagger.yml | 2 ++ 4 files changed, 38 insertions(+) diff --git a/medco/picsure2_api_handlers.go b/medco/picsure2_api_handlers.go index 787cf485..e7f6fc21 100644 --- a/medco/picsure2_api_handlers.go +++ b/medco/picsure2_api_handlers.go @@ -84,6 +84,7 @@ func QuerySyncHandlerFunc(params picsure2.QuerySyncParams, principal *models.Use } return picsure2.NewQuerySyncOK().WithPayload(&models.QueryResultElement{ + QueryType: query.query.QueryType, EncryptedCount: query.queryResult.encCount, EncryptionKey: query.query.UserPublicKey, EncryptedPatientList: query.queryResult.encPatientList, diff --git a/swagger/models/query_result_element.go b/swagger/models/query_result_element.go index 6760c0f8..a547b3ca 100644 --- a/swagger/models/query_result_element.go +++ b/swagger/models/query_result_element.go @@ -8,6 +8,7 @@ package models import ( strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/errors" "github.com/go-openapi/swag" ) @@ -23,10 +24,38 @@ type QueryResultElement struct { // encryption key EncryptionKey string `json:"encryptionKey,omitempty"` + + // query type + QueryType QueryType `json:"queryType,omitempty"` } // Validate validates this query result element func (m *QueryResultElement) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateQueryType(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *QueryResultElement) validateQueryType(formats strfmt.Registry) error { + + if swag.IsZero(m.QueryType) { // not required + return nil + } + + if err := m.QueryType.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("queryType") + } + return err + } + return nil } diff --git a/swagger/restapi/embedded_spec.go b/swagger/restapi/embedded_spec.go index c793c716..2b18f584 100644 --- a/swagger/restapi/embedded_spec.go +++ b/swagger/restapi/embedded_spec.go @@ -395,6 +395,9 @@ func init() { }, "encryptionKey": { "type": "string" + }, + "queryType": { + "$ref": "#/definitions/queryType" } } }, @@ -1151,6 +1154,9 @@ func init() { }, "encryptionKey": { "type": "string" + }, + "queryType": { + "$ref": "#/definitions/queryType" } } }, diff --git a/swagger/swagger.yml b/swagger/swagger.yml index a3ee56a2..9001de5f 100644 --- a/swagger/swagger.yml +++ b/swagger/swagger.yml @@ -386,6 +386,8 @@ definitions: queryResultElement: type: "object" properties: + queryType: + $ref: "#/definitions/queryType" encryptedCount: type: "string" encryptionKey: From 2510f09da38cc61ec2dedfed25515126240c4479 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Tue, 21 May 2019 18:37:53 +0200 Subject: [PATCH 11/41] finalized implement of different query types; implement part of authorizations --- medco/picsure2_api_handlers.go | 31 ++++++++---- medco/query_logic.go | 3 +- medco/query_type.go | 87 +++++++++++++++++++++++++++------- util/security.go | 34 +++++++++++-- 4 files changed, 126 insertions(+), 29 deletions(-) diff --git a/medco/picsure2_api_handlers.go b/medco/picsure2_api_handlers.go index e7f6fc21..8e97520f 100644 --- a/medco/picsure2_api_handlers.go +++ b/medco/picsure2_api_handlers.go @@ -11,7 +11,7 @@ import( // GetInfoHandlerFunc handles /info API endpoint func GetInfoHandlerFunc(params picsure2.GetInfoParams, principal *models.User) middleware.Responder { - err := util.Authorize(params.Body.ResourceCredentials, principal) + err := util.AuthorizeUser(*params.Body.ResourceCredentials, principal) if err != nil { return picsure2.NewGetInfoDefault(401).WithPayload(&picsure2.GetInfoDefaultBody{ Message: "Authorization failed: " + err.Error(), @@ -35,7 +35,7 @@ func GetInfoHandlerFunc(params picsure2.GetInfoParams, principal *models.User) m // SearchHandlerFunc handles /search API endpoint func SearchHandlerFunc(params picsure2.SearchParams, principal *models.User) middleware.Responder { - err := util.Authorize(params.Body.ResourceCredentials, principal) + err := util.AuthorizeUser(*params.Body.ResourceCredentials, principal) if err != nil { return picsure2.NewSearchDefault(401).WithPayload(&picsure2.SearchDefaultBody{ Message: "Authorization failed: " + err.Error(), @@ -58,24 +58,39 @@ func SearchHandlerFunc(params picsure2.SearchParams, principal *models.User) mid // QuerySyncHandlerFunc handles /query/sync API endpoint func QuerySyncHandlerFunc(params picsure2.QuerySyncParams, principal *models.User) middleware.Responder { - // authentication / authorization - err := util.Authorize(params.Body.ResourceCredentials, principal) + // authentication / authorization of user + err := util.AuthorizeUser(*params.Body.ResourceCredentials, principal) if err != nil { return picsure2.NewQuerySyncDefault(401).WithPayload(&picsure2.QuerySyncDefaultBody{ - Message: "Authorization failed: " + err.Error(), + Message: "Authorization of user failed: " + err.Error(), }) } - // resolve authorizations - queryType := resolveQueryType(params.Body.Query.I2b2Medco, principal) + // authorizations of query + err = util.AuthorizeQueryType(*principal, params.Body.Query.I2b2Medco.QueryType) + if err != nil { + return picsure2.NewQuerySyncDefault(401).WithPayload(&picsure2.QuerySyncDefaultBody{ + Message: "Authorization of query failed: " + err.Error(), + }) + } - // execute query + // create query query, err := NewI2b2MedCoQuery(params.Body.Query.Name, params.Body.Query.I2b2Medco) if err != nil { return picsure2.NewQuerySyncDefault(400).WithPayload(&picsure2.QuerySyncDefaultBody{ Message: "Bad query: " + err.Error(), }) } + + // parse query type + queryType, err := NewI2b2MedCoQueryType(params.Body.Query.I2b2Medco.QueryType) + if err != nil { + return picsure2.NewQuerySyncDefault(400).WithPayload(&picsure2.QuerySyncDefaultBody{ + Message: "Bad query type: " + err.Error(), + }) + } + + // execute query err = query.Execute(queryType) if err != nil { return picsure2.NewQuerySyncDefault(500).WithPayload(&picsure2.QuerySyncDefaultBody{ diff --git a/medco/query_logic.go b/medco/query_logic.go index 1c981d3c..884672ee 100644 --- a/medco/query_logic.go +++ b/medco/query_logic.go @@ -34,6 +34,7 @@ func NewI2b2MedCoQuery(queryName string, query *models.QueryI2b2Medco) (new I2b2 } // todo: breakdown in i2b2 / count / patient list +// todo: implement obfuscation // Execute implements the I2b2 MedCo query logic func (q *I2b2MedCoQuery) Execute(queryType I2b2MedCoQueryType) (err error) { @@ -76,7 +77,7 @@ func (q *I2b2MedCoQuery) Execute(queryType I2b2MedCoQueryType) (err error) { // compute and key switch count (returns optionally global aggregate or shuffled results) var encCount string - if !queryType.CountPerSite { + if queryType.CountType == Global { logrus.Info(q.name, ": global aggregate requested") encCount, err = unlynx.AggregateAndKeySwitchValue(q.name, aggPatientFlags, q.query.UserPublicKey) } else if queryType.Shuffled { diff --git a/medco/query_type.go b/medco/query_type.go index 8dd8177e..a2edc0ad 100644 --- a/medco/query_type.go +++ b/medco/query_type.go @@ -1,6 +1,9 @@ package medco -import "github.com/lca1/medco-connector/swagger/models" +import ( + "errors" + "github.com/lca1/medco-connector/swagger/models" +) // I2b2MedCoQueryType encodes the requested results from the query type I2b2MedCoQueryType struct { @@ -8,8 +11,8 @@ type I2b2MedCoQueryType struct { // PatientList encodes if the (encrypted) patient list is retrieved, otherwise only a count PatientList bool - // CountPerSite encodes if the retrieved count is per site, or aggregated over all nodes - CountPerSite bool + // CountType encodes the type of count, either global or per site + CountType CountType // Shuffled encodes if the count per site if shuffled across all nodes for unlinkability Shuffled bool @@ -20,23 +23,75 @@ type I2b2MedCoQueryType struct { // todo: include differential privacy requested } +type CountType int +const ( + PerSite = iota + Global +) -// resolveQueryType resolves the query type based on the user's authorizations and its request -func resolveQueryType(query *models.QueryI2b2Medco, userPrincipal *models.User) (queryType I2b2MedCoQueryType) { - // todo: authorizations param model to create - // todo: other authorizations - queryType = I2b2MedCoQueryType{ - PatientList: false, - CountPerSite: true, // todo: from principal - Shuffled: true, // todo: from principal - Obfuscated: false, // todo: with DP implementation - } +// NewI2b2MedCoQueryType creates a query type based on the requested query type +func NewI2b2MedCoQueryType(requestedQueryType models.QueryType) (queryType I2b2MedCoQueryType, err error) { + + switch requestedQueryType { + case models.QueryTypePatientList: + queryType = I2b2MedCoQueryType{ + PatientList: true, + CountType: PerSite, + Shuffled: false, + Obfuscated: false, + } + + case models.QueryTypeCountPerSite: + queryType = I2b2MedCoQueryType{ + PatientList: false, + CountType: PerSite, + Shuffled: false, + Obfuscated: false, + } + + case models.QueryTypeCountPerSiteObfuscated: + queryType = I2b2MedCoQueryType{ + PatientList: false, + CountType: PerSite, + Shuffled: false, + Obfuscated: true, + } - for _, selectedResult := range query.Select { - if selectedResult == "patient_list" { - queryType.PatientList = true + case models.QueryTypeCountPerSiteShuffled: + queryType = I2b2MedCoQueryType{ + PatientList: false, + CountType: PerSite, + Shuffled: true, + Obfuscated: false, } + + case models.QueryTypeCountPerSiteShuffledObfuscated: + queryType = I2b2MedCoQueryType{ + PatientList: false, + CountType: PerSite, + Shuffled: true, + Obfuscated: true, + } + + case models.QueryTypeCountGlobal: + queryType = I2b2MedCoQueryType{ + PatientList: false, + CountType: Global, + Shuffled: false, + Obfuscated: false, + } + + case models.QueryTypeCountGlobalObfuscated: + queryType = I2b2MedCoQueryType{ + PatientList: false, + CountType: Global, + Shuffled: false, + Obfuscated: true, + } + + default: + err = errors.New("unrecognized query type: " + string(requestedQueryType)) } return diff --git a/util/security.go b/util/security.go index ea0b53b2..5901ac9c 100644 --- a/util/security.go +++ b/util/security.go @@ -16,11 +16,9 @@ var cachedKeySet struct { expirationTime time.Time } -// --- JWT-based MedCo user authentication - -// Authorize authorizes user and populate principal with user information +// AuthorizeUser authorizes user and populate principal with user information, including its authorizations // returns error if user is not authorized -func Authorize(credentials *models.ResourceCredentials, user *models.User) (err error) { +func AuthorizeUser(credentials models.ResourceCredentials, user *models.User) (err error) { // get JWT signing keys keySet, err := retrieveJWKSet() @@ -62,6 +60,34 @@ func Authorize(credentials *models.ResourceCredentials, user *models.User) (err err = errors.New("authentication failed (user ID claim not present)") logrus.Warn(err) } + + // extract user authorizations + // todo: implement the extraction + user.Authorizations = &models.UserAuthorizations{ + QueryType: []models.QueryType{ + models.QueryTypePatientList, + models.QueryTypeCountPerSite, + models.QueryTypeCountPerSiteObfuscated, + models.QueryTypeCountPerSiteShuffled, + models.QueryTypeCountPerSiteShuffledObfuscated, + models.QueryTypeCountGlobal, + models.QueryTypeCountGlobalObfuscated, + }, + } + return +} + +// AuthorizeQueryType authorizes the query type requested by the user +func AuthorizeQueryType(user models.User, requestedQueryType models.QueryType) (err error) { + for _, userQueryType := range user.Authorizations.QueryType { + if userQueryType == requestedQueryType { + logrus.Info("user is authorized to execute the query type " + string(requestedQueryType)) + return nil + } + } + + err = errors.New("user is not authorized to execute the query type " + string(requestedQueryType)) + logrus.Warn(err) return } From 0570a4b694074930eb28239c996ebd559e797d7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Thu, 23 May 2019 15:42:27 +0200 Subject: [PATCH 12/41] go-swagger upgrade; revert temporary hack for boolean values --- i2b2/ontology_query.go | 14 +++---- medco/query_logic.go | 6 +-- swagger/models/query.go | 32 +--------------- swagger/models/search_result_element.go | 37 +------------------ swagger/restapi/embedded_spec.go | 24 ------------ .../restapi/operations/medco_connector_api.go | 6 +-- swagger/restapi/server.go | 2 +- swagger/swagger.yml | 4 -- 8 files changed, 17 insertions(+), 108 deletions(-) diff --git a/i2b2/ontology_query.go b/i2b2/ontology_query.go index 08d29278..a405d372 100644 --- a/i2b2/ontology_query.go +++ b/i2b2/ontology_query.go @@ -62,14 +62,12 @@ func parseI2b2Concept(concept Concept) (result *models.SearchResultElement) { // - CONCEPT_PARENT_NODE // - CONCEPT_INTERNAL_NODE // - CONCEPT_LEAF - true := true - false := false result = &models.SearchResultElement{ Name: concept.Name, DisplayName: concept.Name, Code: concept.Basecode, MedcoEncryption: &models.SearchResultElementMedcoEncryption{ - Encrypted: &false, + Encrypted: false, ID: -1, ChildrenIds: []int64{}, }, @@ -82,19 +80,19 @@ func parseI2b2Concept(concept Concept) (result *models.SearchResultElement) { switch concept.Visualattributes[0] { // i2b2 leaf case 'L': - result.Leaf = &true + result.Leaf = true result.Type = models.SearchResultElementTypeConcept // i2b2 container case 'C': - result.Leaf = &false + result.Leaf = false result.Type = models.SearchResultElementTypeContainer // i2b2 folder (& default) default: fallthrough case 'F': - result.Leaf = &false + result.Leaf = false result.Type = models.SearchResultElementTypeConcept } @@ -103,12 +101,12 @@ func parseI2b2Concept(concept Concept) (result *models.SearchResultElement) { // if clinical concept from data loader v0 (from concept code) if splitCode[0] == "ENC_ID" { - result.MedcoEncryption.Encrypted = &true + result.MedcoEncryption.Encrypted = true result.MedcoEncryption.ID, _ = strconv.ParseInt(splitCode[1], 10, 64) // if concept from loader v1 encrypted (from metadata xml) } else if concept.Metadataxml.ValueMetadata.EncryptedType != "" { - result.MedcoEncryption.Encrypted = &true + result.MedcoEncryption.Encrypted = true result.MedcoEncryption.ID, _ = strconv.ParseInt(concept.Metadataxml.ValueMetadata.NodeEncryptID, 10, 64) for _, childEncryptIDString := range strings.Split(concept.Metadataxml.ValueMetadata.ChildrenEncryptIDs, ",") { diff --git a/medco/query_logic.go b/medco/query_logic.go index 884672ee..766d1204 100644 --- a/medco/query_logic.go +++ b/medco/query_logic.go @@ -147,7 +147,7 @@ func (q *I2b2MedCoQuery) maskPatientIDs(patientIDs []string, patientDummyFlags [ func (q *I2b2MedCoQuery) getEncQueryTerms() (encQueryTerms []string) { for _, panel := range q.query.Panels { for _, item := range panel.Items { - if *item.Encrypted { + if item.Encrypted { encQueryTerms = append(encQueryTerms, item.QueryTerm) } } @@ -157,12 +157,12 @@ func (q *I2b2MedCoQuery) getEncQueryTerms() (encQueryTerms []string) { func (q *I2b2MedCoQuery) getI2b2PsmQueryTerms(taggedQueryTerms map[string]string) (panelsItemKeys [][]string, panelsIsNot []bool, err error) { for panelIdx, panel := range q.query.Panels { - panelsIsNot = append(panelsIsNot, *panel.Not) + panelsIsNot = append(panelsIsNot, panel.Not) panelsItemKeys = append(panelsItemKeys, []string{}) for _, item := range panel.Items { var itemKey string - if *item.Encrypted { + if item.Encrypted { if tag, ok := taggedQueryTerms[item.QueryTerm]; ok { itemKey = `\\SENSITIVE_TAGGED\medco\tagged\` + tag + `\` diff --git a/swagger/models/query.go b/swagger/models/query.go index 89c3c8d5..78abff03 100644 --- a/swagger/models/query.go +++ b/swagger/models/query.go @@ -235,8 +235,7 @@ type QueryI2b2MedcoPanelsItems0 struct { Items []*QueryI2b2MedcoPanelsItems0ItemsItems0 `json:"items"` // exclude the i2b2 panel - // Required: true - Not *bool `json:"not"` + Not bool `json:"not,omitempty"` } // Validate validates this query i2b2 medco panels items0 @@ -247,10 +246,6 @@ func (m *QueryI2b2MedcoPanelsItems0) Validate(formats strfmt.Registry) error { res = append(res, err) } - if err := m.validateNot(formats); err != nil { - res = append(res, err) - } - if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -282,15 +277,6 @@ func (m *QueryI2b2MedcoPanelsItems0) validateItems(formats strfmt.Registry) erro return nil } -func (m *QueryI2b2MedcoPanelsItems0) validateNot(formats strfmt.Registry) error { - - if err := validate.Required("not", "body", m.Not); err != nil { - return err - } - - return nil -} - // MarshalBinary interface implementation func (m *QueryI2b2MedcoPanelsItems0) MarshalBinary() ([]byte, error) { if m == nil { @@ -314,8 +300,7 @@ func (m *QueryI2b2MedcoPanelsItems0) UnmarshalBinary(b []byte) error { type QueryI2b2MedcoPanelsItems0ItemsItems0 struct { // encrypted - // Required: true - Encrypted *bool `json:"encrypted"` + Encrypted bool `json:"encrypted,omitempty"` // operator // Enum: [exists equals] @@ -332,10 +317,6 @@ type QueryI2b2MedcoPanelsItems0ItemsItems0 struct { func (m *QueryI2b2MedcoPanelsItems0ItemsItems0) Validate(formats strfmt.Registry) error { var res []error - if err := m.validateEncrypted(formats); err != nil { - res = append(res, err) - } - if err := m.validateOperator(formats); err != nil { res = append(res, err) } @@ -346,15 +327,6 @@ func (m *QueryI2b2MedcoPanelsItems0ItemsItems0) Validate(formats strfmt.Registry return nil } -func (m *QueryI2b2MedcoPanelsItems0ItemsItems0) validateEncrypted(formats strfmt.Registry) error { - - if err := validate.Required("encrypted", "body", m.Encrypted); err != nil { - return err - } - - return nil -} - var queryI2b2MedcoPanelsItems0ItemsItems0TypeOperatorPropEnum []interface{} func init() { diff --git a/swagger/models/search_result_element.go b/swagger/models/search_result_element.go index 6d2b4d63..6a1a3dd8 100644 --- a/swagger/models/search_result_element.go +++ b/swagger/models/search_result_element.go @@ -26,8 +26,7 @@ type SearchResultElement struct { DisplayName string `json:"displayName,omitempty"` // leaf - // Required: true - Leaf *bool `json:"leaf"` + Leaf bool `json:"leaf,omitempty"` // medco encryption MedcoEncryption *SearchResultElementMedcoEncryption `json:"medcoEncryption,omitempty"` @@ -50,10 +49,6 @@ type SearchResultElement struct { func (m *SearchResultElement) Validate(formats strfmt.Registry) error { var res []error - if err := m.validateLeaf(formats); err != nil { - res = append(res, err) - } - if err := m.validateMedcoEncryption(formats); err != nil { res = append(res, err) } @@ -68,15 +63,6 @@ func (m *SearchResultElement) Validate(formats strfmt.Registry) error { return nil } -func (m *SearchResultElement) validateLeaf(formats strfmt.Registry) error { - - if err := validate.Required("leaf", "body", m.Leaf); err != nil { - return err - } - - return nil -} - func (m *SearchResultElement) validateMedcoEncryption(formats strfmt.Registry) error { if swag.IsZero(m.MedcoEncryption) { // not required @@ -176,8 +162,7 @@ type SearchResultElementMedcoEncryption struct { ChildrenIds []int64 `json:"childrenIds"` // encrypted - // Required: true - Encrypted *bool `json:"encrypted"` + Encrypted bool `json:"encrypted,omitempty"` // id ID int64 `json:"id,omitempty"` @@ -185,24 +170,6 @@ type SearchResultElementMedcoEncryption struct { // Validate validates this search result element medco encryption func (m *SearchResultElementMedcoEncryption) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateEncrypted(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *SearchResultElementMedcoEncryption) validateEncrypted(formats strfmt.Registry) error { - - if err := validate.Required("medcoEncryption"+"."+"encrypted", "body", m.Encrypted); err != nil { - return err - } - return nil } diff --git a/swagger/restapi/embedded_spec.go b/swagger/restapi/embedded_spec.go index 2b18f584..fcf3f4e0 100644 --- a/swagger/restapi/embedded_spec.go +++ b/swagger/restapi/embedded_spec.go @@ -329,18 +329,12 @@ func init() { "type": "array", "items": { "type": "object", - "required": [ - "not" - ], "properties": { "items": { "description": "i2b2 items (linked by an OR)", "type": "array", "items": { "type": "object", - "required": [ - "encrypted" - ], "properties": { "encrypted": { "type": "boolean" @@ -485,9 +479,6 @@ func init() { }, "searchResultElement": { "type": "object", - "required": [ - "leaf" - ], "properties": { "code": { "type": "string" @@ -500,9 +491,6 @@ func init() { }, "medcoEncryption": { "type": "object", - "required": [ - "encrypted" - ], "properties": { "childrenIds": { "type": "array", @@ -1088,18 +1076,12 @@ func init() { "type": "array", "items": { "type": "object", - "required": [ - "not" - ], "properties": { "items": { "description": "i2b2 items (linked by an OR)", "type": "array", "items": { "type": "object", - "required": [ - "encrypted" - ], "properties": { "encrypted": { "type": "boolean" @@ -1244,9 +1226,6 @@ func init() { }, "searchResultElement": { "type": "object", - "required": [ - "leaf" - ], "properties": { "code": { "type": "string" @@ -1259,9 +1238,6 @@ func init() { }, "medcoEncryption": { "type": "object", - "required": [ - "encrypted" - ], "properties": { "childrenIds": { "type": "array", diff --git a/swagger/restapi/operations/medco_connector_api.go b/swagger/restapi/operations/medco_connector_api.go index a86723a4..87276998 100644 --- a/swagger/restapi/operations/medco_connector_api.go +++ b/swagger/restapi/operations/medco_connector_api.go @@ -82,13 +82,13 @@ type MedcoConnectorAPI struct { Middleware func(middleware.Builder) http.Handler // BasicAuthenticator generates a runtime.Authenticator from the supplied basic auth function. - // It has a default implemention in the security package, however you can replace it for your particular usage. + // It has a default implementation in the security package, however you can replace it for your particular usage. BasicAuthenticator func(security.UserPassAuthentication) runtime.Authenticator // APIKeyAuthenticator generates a runtime.Authenticator from the supplied token auth function. - // It has a default implemention in the security package, however you can replace it for your particular usage. + // It has a default implementation in the security package, however you can replace it for your particular usage. APIKeyAuthenticator func(string, string, security.TokenAuthentication) runtime.Authenticator // BearerAuthenticator generates a runtime.Authenticator from the supplied bearer token auth function. - // It has a default implemention in the security package, however you can replace it for your particular usage. + // It has a default implementation in the security package, however you can replace it for your particular usage. BearerAuthenticator func(string, security.ScopedTokenAuthentication) runtime.Authenticator // JSONConsumer registers a consumer for a "application/json" mime type diff --git a/swagger/restapi/server.go b/swagger/restapi/server.go index 6880e4a8..7c5f0551 100644 --- a/swagger/restapi/server.go +++ b/swagger/restapi/server.go @@ -87,7 +87,7 @@ type Server struct { TLSHost string `long:"tls-host" description:"the IP to listen on for tls, when not specified it's the same as --host" env:"TLS_HOST"` TLSPort int `long:"tls-port" description:"the port to listen on for secure connections, defaults to a random value" env:"TLS_PORT"` TLSCertificate flags.Filename `long:"tls-certificate" description:"the certificate to use for secure connections" env:"TLS_CERTIFICATE"` - TLSCertificateKey flags.Filename `long:"tls-key" description:"the private key to use for secure conections" env:"TLS_PRIVATE_KEY"` + TLSCertificateKey flags.Filename `long:"tls-key" description:"the private key to use for secure connections" env:"TLS_PRIVATE_KEY"` TLSCACertificate flags.Filename `long:"tls-ca" description:"the certificate authority file to be used with mutual tls auth" env:"TLS_CA_CERTIFICATE"` TLSListenLimit int `long:"tls-listen-limit" description:"limit the number of outstanding requests"` TLSKeepAlive time.Duration `long:"tls-keep-alive" description:"sets the TCP keep-alive timeouts on accepted connections. It prunes dead TCP connections ( e.g. closing laptop mid-download)"` diff --git a/swagger/swagger.yml b/swagger/swagger.yml index 9001de5f..496ebbf8 100644 --- a/swagger/swagger.yml +++ b/swagger/swagger.yml @@ -283,7 +283,6 @@ definitions: searchResultElement: type: "object" - required: [leaf] properties: path: type: "string" @@ -306,7 +305,6 @@ definitions: type: "boolean" medcoEncryption: type: "object" - required: [encrypted] properties: encrypted: type: "boolean" @@ -343,7 +341,6 @@ definitions: description: "i2b2 panels (linked by an AND)" items: type: "object" - required: [not] properties: not: type: "boolean" @@ -353,7 +350,6 @@ definitions: description: "i2b2 items (linked by an OR)" items: type: "object" - required: [encrypted] properties: queryTerm: type: "string" From 7ce17583576b2ac4bc65ae65244da5c3e8d68067 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Thu, 23 May 2019 15:43:26 +0200 Subject: [PATCH 13/41] go-swagger client library; go modules update --- Makefile | 7 + go.mod | 8 +- go.sum | 16 +- swagger/client/medco_cli_client_client.go | 117 +++++++ .../client/picsure2/get_info_parameters.go | 135 ++++++++ swagger/client/picsure2/get_info_responses.go | 319 ++++++++++++++++++ swagger/client/picsure2/picsure2_client.go | 204 +++++++++++ swagger/client/picsure2/query_parameters.go | 135 ++++++++ swagger/client/picsure2/query_responses.go | 233 +++++++++++++ .../picsure2/query_result_parameters.go | 156 +++++++++ .../client/picsure2/query_result_responses.go | 205 +++++++++++ .../picsure2/query_status_parameters.go | 156 +++++++++ .../client/picsure2/query_status_responses.go | 205 +++++++++++ .../client/picsure2/query_sync_parameters.go | 135 ++++++++ .../client/picsure2/query_sync_responses.go | 233 +++++++++++++ swagger/client/picsure2/search_parameters.go | 135 ++++++++ swagger/client/picsure2/search_responses.go | 303 +++++++++++++++++ 17 files changed, 2690 insertions(+), 12 deletions(-) create mode 100644 swagger/client/medco_cli_client_client.go create mode 100644 swagger/client/picsure2/get_info_parameters.go create mode 100644 swagger/client/picsure2/get_info_responses.go create mode 100644 swagger/client/picsure2/picsure2_client.go create mode 100644 swagger/client/picsure2/query_parameters.go create mode 100644 swagger/client/picsure2/query_responses.go create mode 100644 swagger/client/picsure2/query_result_parameters.go create mode 100644 swagger/client/picsure2/query_result_responses.go create mode 100644 swagger/client/picsure2/query_status_parameters.go create mode 100644 swagger/client/picsure2/query_status_responses.go create mode 100644 swagger/client/picsure2/query_sync_parameters.go create mode 100644 swagger/client/picsure2/query_sync_responses.go create mode 100644 swagger/client/picsure2/search_parameters.go create mode 100644 swagger/client/picsure2/search_responses.go diff --git a/Makefile b/Makefile index d5703fd0..aac436c8 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,13 @@ swagger-gen: --target=./swagger/ \ --spec=./swagger/swagger.yml \ --name=medco-connector + swagger generate client \ + --principal=models.User \ + --target=./swagger/ \ + --spec=./swagger/swagger.yml \ + --name=medco-cli-client \ + --existing-models=github.com/lca1/medco-connector/swagger/models \ + --default-scheme=https test_lint: @echo Checking linting of files diff --git a/go.mod b/go.mod index e9fbdcb5..a97ab1de 100644 --- a/go.mod +++ b/go.mod @@ -18,15 +18,15 @@ require ( github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect github.com/lca1/medco-unlynx v0.0.0-20190520135023-7273e0cd4409 github.com/lca1/unlynx v1.3.1 - github.com/lestrrat-go/jwx v0.0.0-20190520025545-5d60d87d07dd + github.com/lestrrat-go/jwx v0.9.0 github.com/mailru/easyjson v0.0.0-20190403194419-1ea4449da983 // indirect github.com/pkg/errors v0.8.1 github.com/sirupsen/logrus v1.4.2 github.com/smartystreets/assertions v0.0.0-20190401211740-f487f9de1cd3 // indirect go.dedis.ch/kyber/v3 v3.0.3 // indirect - go.dedis.ch/onet/v3 v3.0.12 + go.dedis.ch/onet/v3 v3.0.13 golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f // indirect - golang.org/x/net v0.0.0-20190514140710-3ec191127204 - golang.org/x/sys v0.0.0-20190516110030-61b9204099cb // indirect + golang.org/x/net v0.0.0-20190522155817-f3200d17e092 + golang.org/x/sys v0.0.0-20190522044717-8097e1b27ff5 // indirect golang.org/x/text v0.3.2 // indirect ) diff --git a/go.sum b/go.sum index 43c90ae6..59f5cb12 100644 --- a/go.sum +++ b/go.sum @@ -109,8 +109,8 @@ github.com/lca1/medco-unlynx v0.0.0-20190520135023-7273e0cd4409 h1:JMzXDulliMydz github.com/lca1/medco-unlynx v0.0.0-20190520135023-7273e0cd4409/go.mod h1:ye1nTpn1fuEoRC5V+cM0ykbjEwvcgN6eXsM2rIN89T0= github.com/lca1/unlynx v1.3.1 h1:l/sLi4DGL9Rlvk6ySzR13VYjgbubY1tMHPyXGvd2zZU= github.com/lca1/unlynx v1.3.1/go.mod h1:HOR8K2JLrylJjIDdMdFev5rE5q6XGifs0OnH7rvreqY= -github.com/lestrrat-go/jwx v0.0.0-20190520025545-5d60d87d07dd h1:LlBVT5LW5RiBhlLGhvAJwPSQrQe4cF/lJfciixiUauw= -github.com/lestrrat-go/jwx v0.0.0-20190520025545-5d60d87d07dd/go.mod h1:iEoxlYfZjvoGpuWwxUz+eR5e6KTJGsaRcy/YNA/UnBk= +github.com/lestrrat-go/jwx v0.9.0 h1:Fnd0EWzTm0kFrBPzE/PEPp9nzllES5buMkksPMjEKpM= +github.com/lestrrat-go/jwx v0.9.0/go.mod h1:iEoxlYfZjvoGpuWwxUz+eR5e6KTJGsaRcy/YNA/UnBk= github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= @@ -155,8 +155,8 @@ go.dedis.ch/kyber/v3 v3.0.3/go.mod h1:OzvaEnPvKlyrWyp3kGXlFdp7ap1VC6RkZDTaPikqhs go.dedis.ch/onet/v3 v3.0.0 h1:haBqkwkNNu/jHz7+PoZJS+xbtA5JheQvt0SSIjGyk5I= go.dedis.ch/onet/v3 v3.0.0/go.mod h1:xqmP2+NvxeNzgmNj/4hf56EZm3KT0Qksz98miZw5G3A= go.dedis.ch/onet/v3 v3.0.6/go.mod h1:0wrof0zfyD+Qfw9Pfhu9jW+bTbwwWBzC1hMuV/c8v2w= -go.dedis.ch/onet/v3 v3.0.12 h1:hqo54/Noh9J4EsFz2KEYb/r7bFhiI5hSClGGVUJDcDk= -go.dedis.ch/onet/v3 v3.0.12/go.mod h1:8zNbWaMMpTiBfa8gftpoe726sivOF1ymxqkiPuvpdFA= +go.dedis.ch/onet/v3 v3.0.13 h1:3qF14IUvSqwq8z3ivGuXrB8T0S0wZSbku0d0quJIPQ8= +go.dedis.ch/onet/v3 v3.0.13/go.mod h1:8zNbWaMMpTiBfa8gftpoe726sivOF1ymxqkiPuvpdFA= go.dedis.ch/protobuf v1.0.5/go.mod h1:eIV4wicvi6JK0q/QnfIEGeSFNG0ZeB24kzut5+HaRLo= go.dedis.ch/protobuf v1.0.6 h1:E61p2XjYbYrTf3WeXE8M8Ui5WA3hX/NgbHHi5D0FLxI= go.dedis.ch/protobuf v1.0.6/go.mod h1:YHYXW6dQ9p2iJ3f+2fxKnOpjGx0MvL4cwpg1RVNXaV8= @@ -177,16 +177,16 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJV golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190320064053-1272bf9dcd53/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190514140710-3ec191127204 h1:4yG6GqBtw9C+UrLp6s2wtSniayy/Vd/3F7ffLE427XI= -golang.org/x/net v0.0.0-20190514140710-3ec191127204/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190522155817-f3200d17e092 h1:4QSRKanuywn15aTZvI/mIDEgPQpswuFndXpOj3rKEco= +golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/sys v0.0.0-20190124100055-b90733256f2e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190321052220-f7bb7a8bee54/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190516110030-61b9204099cb h1:k07iPOt0d6nEnwXF+kHB+iEg+WSuKe/SOQuFM2QoD+E= -golang.org/x/sys v0.0.0-20190516110030-61b9204099cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190522044717-8097e1b27ff5 h1:f005F/Jl5JLP036x7QIvUVhNTqxvSYwFIiyOh2q12iU= +golang.org/x/sys v0.0.0-20190522044717-8097e1b27ff5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= diff --git a/swagger/client/medco_cli_client_client.go b/swagger/client/medco_cli_client_client.go new file mode 100644 index 00000000..b7ca21af --- /dev/null +++ b/swagger/client/medco_cli_client_client.go @@ -0,0 +1,117 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package client + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/runtime" + httptransport "github.com/go-openapi/runtime/client" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/lca1/medco-connector/swagger/client/picsure2" +) + +// Default medco cli client HTTP client. +var Default = NewHTTPClient(nil) + +const ( + // DefaultHost is the default Host + // found in Meta (info) section of spec file + DefaultHost string = "localhost" + // DefaultBasePath is the default BasePath + // found in Meta (info) section of spec file + DefaultBasePath string = "/medco-connector" +) + +// DefaultSchemes are the default schemes found in Meta (info) section of spec file +var DefaultSchemes = []string{"http"} + +// NewHTTPClient creates a new medco cli client HTTP client. +func NewHTTPClient(formats strfmt.Registry) *MedcoCliClient { + return NewHTTPClientWithConfig(formats, nil) +} + +// NewHTTPClientWithConfig creates a new medco cli client HTTP client, +// using a customizable transport config. +func NewHTTPClientWithConfig(formats strfmt.Registry, cfg *TransportConfig) *MedcoCliClient { + // ensure nullable parameters have default + if cfg == nil { + cfg = DefaultTransportConfig() + } + + // create transport and client + transport := httptransport.New(cfg.Host, cfg.BasePath, cfg.Schemes) + return New(transport, formats) +} + +// New creates a new medco cli client client +func New(transport runtime.ClientTransport, formats strfmt.Registry) *MedcoCliClient { + // ensure nullable parameters have default + if formats == nil { + formats = strfmt.Default + } + + cli := new(MedcoCliClient) + cli.Transport = transport + + cli.Picsure2 = picsure2.New(transport, formats) + + return cli +} + +// DefaultTransportConfig creates a TransportConfig with the +// default settings taken from the meta section of the spec file. +func DefaultTransportConfig() *TransportConfig { + return &TransportConfig{ + Host: DefaultHost, + BasePath: DefaultBasePath, + Schemes: DefaultSchemes, + } +} + +// TransportConfig contains the transport related info, +// found in the meta section of the spec file. +type TransportConfig struct { + Host string + BasePath string + Schemes []string +} + +// WithHost overrides the default host, +// provided by the meta section of the spec file. +func (cfg *TransportConfig) WithHost(host string) *TransportConfig { + cfg.Host = host + return cfg +} + +// WithBasePath overrides the default basePath, +// provided by the meta section of the spec file. +func (cfg *TransportConfig) WithBasePath(basePath string) *TransportConfig { + cfg.BasePath = basePath + return cfg +} + +// WithSchemes overrides the default schemes, +// provided by the meta section of the spec file. +func (cfg *TransportConfig) WithSchemes(schemes []string) *TransportConfig { + cfg.Schemes = schemes + return cfg +} + +// MedcoCliClient is a client for medco cli client +type MedcoCliClient struct { + Picsure2 *picsure2.Client + + Transport runtime.ClientTransport +} + +// SetTransport changes the transport on the client and all its subresources +func (c *MedcoCliClient) SetTransport(transport runtime.ClientTransport) { + c.Transport = transport + + c.Picsure2.SetTransport(transport) + +} diff --git a/swagger/client/picsure2/get_info_parameters.go b/swagger/client/picsure2/get_info_parameters.go new file mode 100644 index 00000000..f21cd4ac --- /dev/null +++ b/swagger/client/picsure2/get_info_parameters.go @@ -0,0 +1,135 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package picsure2 + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + + strfmt "github.com/go-openapi/strfmt" +) + +// NewGetInfoParams creates a new GetInfoParams object +// with the default values initialized. +func NewGetInfoParams() *GetInfoParams { + var () + return &GetInfoParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewGetInfoParamsWithTimeout creates a new GetInfoParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewGetInfoParamsWithTimeout(timeout time.Duration) *GetInfoParams { + var () + return &GetInfoParams{ + + timeout: timeout, + } +} + +// NewGetInfoParamsWithContext creates a new GetInfoParams object +// with the default values initialized, and the ability to set a context for a request +func NewGetInfoParamsWithContext(ctx context.Context) *GetInfoParams { + var () + return &GetInfoParams{ + + Context: ctx, + } +} + +// NewGetInfoParamsWithHTTPClient creates a new GetInfoParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewGetInfoParamsWithHTTPClient(client *http.Client) *GetInfoParams { + var () + return &GetInfoParams{ + HTTPClient: client, + } +} + +/*GetInfoParams contains all the parameters to send to the API endpoint +for the get info operation typically these are written to a http.Request +*/ +type GetInfoParams struct { + + /*Body + Credentials to be used. + + */ + Body GetInfoBody + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the get info params +func (o *GetInfoParams) WithTimeout(timeout time.Duration) *GetInfoParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the get info params +func (o *GetInfoParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the get info params +func (o *GetInfoParams) WithContext(ctx context.Context) *GetInfoParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the get info params +func (o *GetInfoParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the get info params +func (o *GetInfoParams) WithHTTPClient(client *http.Client) *GetInfoParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the get info params +func (o *GetInfoParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the get info params +func (o *GetInfoParams) WithBody(body GetInfoBody) *GetInfoParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the get info params +func (o *GetInfoParams) SetBody(body GetInfoBody) { + o.Body = body +} + +// WriteToRequest writes these params to a swagger request +func (o *GetInfoParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/swagger/client/picsure2/get_info_responses.go b/swagger/client/picsure2/get_info_responses.go new file mode 100644 index 00000000..68b00292 --- /dev/null +++ b/swagger/client/picsure2/get_info_responses.go @@ -0,0 +1,319 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package picsure2 + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/lca1/medco-connector/swagger/models" +) + +// GetInfoReader is a Reader for the GetInfo structure. +type GetInfoReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *GetInfoReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + + case 200: + result := NewGetInfoOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + + default: + result := NewGetInfoDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result + } +} + +// NewGetInfoOK creates a GetInfoOK with default headers values +func NewGetInfoOK() *GetInfoOK { + return &GetInfoOK{} +} + +/*GetInfoOK handles this case with default header values. + +PIC-SURE 2 resource information. +*/ +type GetInfoOK struct { + Payload *GetInfoOKBody +} + +func (o *GetInfoOK) Error() string { + return fmt.Sprintf("[POST /picsure2/info][%d] getInfoOK %+v", 200, o.Payload) +} + +func (o *GetInfoOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(GetInfoOKBody) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetInfoDefault creates a GetInfoDefault with default headers values +func NewGetInfoDefault(code int) *GetInfoDefault { + return &GetInfoDefault{ + _statusCode: code, + } +} + +/*GetInfoDefault handles this case with default header values. + +Error response +*/ +type GetInfoDefault struct { + _statusCode int + + Payload *GetInfoDefaultBody +} + +// Code gets the status code for the get info default response +func (o *GetInfoDefault) Code() int { + return o._statusCode +} + +func (o *GetInfoDefault) Error() string { + return fmt.Sprintf("[POST /picsure2/info][%d] getInfo default %+v", o._statusCode, o.Payload) +} + +func (o *GetInfoDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(GetInfoDefaultBody) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +/*GetInfoBody get info body +swagger:model GetInfoBody +*/ +type GetInfoBody struct { + + // resource credentials + ResourceCredentials *models.ResourceCredentials `json:"resourceCredentials,omitempty"` +} + +// Validate validates this get info body +func (o *GetInfoBody) Validate(formats strfmt.Registry) error { + var res []error + + if err := o.validateResourceCredentials(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetInfoBody) validateResourceCredentials(formats strfmt.Registry) error { + + if swag.IsZero(o.ResourceCredentials) { // not required + return nil + } + + if o.ResourceCredentials != nil { + if err := o.ResourceCredentials.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("body" + "." + "resourceCredentials") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (o *GetInfoBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *GetInfoBody) UnmarshalBinary(b []byte) error { + var res GetInfoBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} + +/*GetInfoDefaultBody get info default body +swagger:model GetInfoDefaultBody +*/ +type GetInfoDefaultBody struct { + + // message + Message string `json:"message,omitempty"` +} + +// Validate validates this get info default body +func (o *GetInfoDefaultBody) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *GetInfoDefaultBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *GetInfoDefaultBody) UnmarshalBinary(b []byte) error { + var res GetInfoDefaultBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} + +/*GetInfoOKBody get info o k body +swagger:model GetInfoOKBody +*/ +type GetInfoOKBody struct { + + // id + ID string `json:"id,omitempty"` + + // name + Name string `json:"name,omitempty"` + + // query formats + QueryFormats []*QueryFormatsItems0 `json:"queryFormats"` +} + +// Validate validates this get info o k body +func (o *GetInfoOKBody) Validate(formats strfmt.Registry) error { + var res []error + + if err := o.validateQueryFormats(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetInfoOKBody) validateQueryFormats(formats strfmt.Registry) error { + + if swag.IsZero(o.QueryFormats) { // not required + return nil + } + + for i := 0; i < len(o.QueryFormats); i++ { + if swag.IsZero(o.QueryFormats[i]) { // not required + continue + } + + if o.QueryFormats[i] != nil { + if err := o.QueryFormats[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getInfoOK" + "." + "queryFormats" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (o *GetInfoOKBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *GetInfoOKBody) UnmarshalBinary(b []byte) error { + var res GetInfoOKBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} + +/*QueryFormatsItems0 query formats items0 +swagger:model QueryFormatsItems0 +*/ +type QueryFormatsItems0 struct { + + // description + Description string `json:"description,omitempty"` + + // examples + Examples []interface{} `json:"examples"` + + // name + Name string `json:"name,omitempty"` + + // specifications + Specifications interface{} `json:"specifications,omitempty"` +} + +// Validate validates this query formats items0 +func (o *QueryFormatsItems0) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *QueryFormatsItems0) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *QueryFormatsItems0) UnmarshalBinary(b []byte) error { + var res QueryFormatsItems0 + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} diff --git a/swagger/client/picsure2/picsure2_client.go b/swagger/client/picsure2/picsure2_client.go new file mode 100644 index 00000000..31c5a96a --- /dev/null +++ b/swagger/client/picsure2/picsure2_client.go @@ -0,0 +1,204 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package picsure2 + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/runtime" + + strfmt "github.com/go-openapi/strfmt" +) + +// New creates a new picsure2 API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) *Client { + return &Client{transport: transport, formats: formats} +} + +/* +Client for picsure2 API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +/* +GetInfo returns information on how to interact with this p i c s u r e endpoint +*/ +func (a *Client) GetInfo(params *GetInfoParams, authInfo runtime.ClientAuthInfoWriter) (*GetInfoOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewGetInfoParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "getInfo", + Method: "POST", + PathPattern: "/picsure2/info", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &GetInfoReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + return result.(*GetInfoOK), nil + +} + +/* +Query queries med co node +*/ +func (a *Client) Query(params *QueryParams, authInfo runtime.ClientAuthInfoWriter) (*QueryOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewQueryParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "query", + Method: "POST", + PathPattern: "/picsure2/query", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &QueryReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + return result.(*QueryOK), nil + +} + +/* +QueryResult gets result of query +*/ +func (a *Client) QueryResult(params *QueryResultParams, authInfo runtime.ClientAuthInfoWriter) (*QueryResultOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewQueryResultParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "queryResult", + Method: "POST", + PathPattern: "/picsure2/{queryId}/result", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &QueryResultReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + return result.(*QueryResultOK), nil + +} + +/* +QueryStatus gets status of query +*/ +func (a *Client) QueryStatus(params *QueryStatusParams, authInfo runtime.ClientAuthInfoWriter) (*QueryStatusOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewQueryStatusParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "queryStatus", + Method: "POST", + PathPattern: "/picsure2/{queryId}/status", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &QueryStatusReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + return result.(*QueryStatusOK), nil + +} + +/* +QuerySync queries med co node synchronously +*/ +func (a *Client) QuerySync(params *QuerySyncParams, authInfo runtime.ClientAuthInfoWriter) (*QuerySyncOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewQuerySyncParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "querySync", + Method: "POST", + PathPattern: "/picsure2/query/sync", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &QuerySyncReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + return result.(*QuerySyncOK), nil + +} + +/* +Search searches through the ontology +*/ +func (a *Client) Search(params *SearchParams, authInfo runtime.ClientAuthInfoWriter) (*SearchOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewSearchParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "search", + Method: "POST", + PathPattern: "/picsure2/search", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &SearchReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + return result.(*SearchOK), nil + +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/swagger/client/picsure2/query_parameters.go b/swagger/client/picsure2/query_parameters.go new file mode 100644 index 00000000..bc88b8c4 --- /dev/null +++ b/swagger/client/picsure2/query_parameters.go @@ -0,0 +1,135 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package picsure2 + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + + strfmt "github.com/go-openapi/strfmt" +) + +// NewQueryParams creates a new QueryParams object +// with the default values initialized. +func NewQueryParams() *QueryParams { + var () + return &QueryParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewQueryParamsWithTimeout creates a new QueryParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewQueryParamsWithTimeout(timeout time.Duration) *QueryParams { + var () + return &QueryParams{ + + timeout: timeout, + } +} + +// NewQueryParamsWithContext creates a new QueryParams object +// with the default values initialized, and the ability to set a context for a request +func NewQueryParamsWithContext(ctx context.Context) *QueryParams { + var () + return &QueryParams{ + + Context: ctx, + } +} + +// NewQueryParamsWithHTTPClient creates a new QueryParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewQueryParamsWithHTTPClient(client *http.Client) *QueryParams { + var () + return &QueryParams{ + HTTPClient: client, + } +} + +/*QueryParams contains all the parameters to send to the API endpoint +for the query operation typically these are written to a http.Request +*/ +type QueryParams struct { + + /*Body + Query request. + + */ + Body QueryBody + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the query params +func (o *QueryParams) WithTimeout(timeout time.Duration) *QueryParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the query params +func (o *QueryParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the query params +func (o *QueryParams) WithContext(ctx context.Context) *QueryParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the query params +func (o *QueryParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the query params +func (o *QueryParams) WithHTTPClient(client *http.Client) *QueryParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the query params +func (o *QueryParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the query params +func (o *QueryParams) WithBody(body QueryBody) *QueryParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the query params +func (o *QueryParams) SetBody(body QueryBody) { + o.Body = body +} + +// WriteToRequest writes these params to a swagger request +func (o *QueryParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/swagger/client/picsure2/query_responses.go b/swagger/client/picsure2/query_responses.go new file mode 100644 index 00000000..c956794d --- /dev/null +++ b/swagger/client/picsure2/query_responses.go @@ -0,0 +1,233 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package picsure2 + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/lca1/medco-connector/swagger/models" +) + +// QueryReader is a Reader for the Query structure. +type QueryReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *QueryReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + + case 200: + result := NewQueryOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + + default: + result := NewQueryDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result + } +} + +// NewQueryOK creates a QueryOK with default headers values +func NewQueryOK() *QueryOK { + return &QueryOK{} +} + +/*QueryOK handles this case with default header values. + +Query status. +*/ +type QueryOK struct { + Payload *models.QueryStatus +} + +func (o *QueryOK) Error() string { + return fmt.Sprintf("[POST /picsure2/query][%d] queryOK %+v", 200, o.Payload) +} + +func (o *QueryOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.QueryStatus) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewQueryDefault creates a QueryDefault with default headers values +func NewQueryDefault(code int) *QueryDefault { + return &QueryDefault{ + _statusCode: code, + } +} + +/*QueryDefault handles this case with default header values. + +Error response +*/ +type QueryDefault struct { + _statusCode int + + Payload *QueryDefaultBody +} + +// Code gets the status code for the query default response +func (o *QueryDefault) Code() int { + return o._statusCode +} + +func (o *QueryDefault) Error() string { + return fmt.Sprintf("[POST /picsure2/query][%d] query default %+v", o._statusCode, o.Payload) +} + +func (o *QueryDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(QueryDefaultBody) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +/*QueryBody query body +swagger:model QueryBody +*/ +type QueryBody struct { + + // query + Query *models.Query `json:"query,omitempty"` + + // resource credentials + ResourceCredentials *models.ResourceCredentials `json:"resourceCredentials,omitempty"` + + // resource UUID + ResourceUUID string `json:"resourceUUID,omitempty"` +} + +// Validate validates this query body +func (o *QueryBody) Validate(formats strfmt.Registry) error { + var res []error + + if err := o.validateQuery(formats); err != nil { + res = append(res, err) + } + + if err := o.validateResourceCredentials(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *QueryBody) validateQuery(formats strfmt.Registry) error { + + if swag.IsZero(o.Query) { // not required + return nil + } + + if o.Query != nil { + if err := o.Query.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("body" + "." + "query") + } + return err + } + } + + return nil +} + +func (o *QueryBody) validateResourceCredentials(formats strfmt.Registry) error { + + if swag.IsZero(o.ResourceCredentials) { // not required + return nil + } + + if o.ResourceCredentials != nil { + if err := o.ResourceCredentials.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("body" + "." + "resourceCredentials") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (o *QueryBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *QueryBody) UnmarshalBinary(b []byte) error { + var res QueryBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} + +/*QueryDefaultBody query default body +swagger:model QueryDefaultBody +*/ +type QueryDefaultBody struct { + + // message + Message string `json:"message,omitempty"` +} + +// Validate validates this query default body +func (o *QueryDefaultBody) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *QueryDefaultBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *QueryDefaultBody) UnmarshalBinary(b []byte) error { + var res QueryDefaultBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} diff --git a/swagger/client/picsure2/query_result_parameters.go b/swagger/client/picsure2/query_result_parameters.go new file mode 100644 index 00000000..287bde86 --- /dev/null +++ b/swagger/client/picsure2/query_result_parameters.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package picsure2 + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + + strfmt "github.com/go-openapi/strfmt" +) + +// NewQueryResultParams creates a new QueryResultParams object +// with the default values initialized. +func NewQueryResultParams() *QueryResultParams { + var () + return &QueryResultParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewQueryResultParamsWithTimeout creates a new QueryResultParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewQueryResultParamsWithTimeout(timeout time.Duration) *QueryResultParams { + var () + return &QueryResultParams{ + + timeout: timeout, + } +} + +// NewQueryResultParamsWithContext creates a new QueryResultParams object +// with the default values initialized, and the ability to set a context for a request +func NewQueryResultParamsWithContext(ctx context.Context) *QueryResultParams { + var () + return &QueryResultParams{ + + Context: ctx, + } +} + +// NewQueryResultParamsWithHTTPClient creates a new QueryResultParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewQueryResultParamsWithHTTPClient(client *http.Client) *QueryResultParams { + var () + return &QueryResultParams{ + HTTPClient: client, + } +} + +/*QueryResultParams contains all the parameters to send to the API endpoint +for the query result operation typically these are written to a http.Request +*/ +type QueryResultParams struct { + + /*Body + Credentials to be used. + + */ + Body QueryResultBody + /*QueryID + Query ID + + */ + QueryID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the query result params +func (o *QueryResultParams) WithTimeout(timeout time.Duration) *QueryResultParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the query result params +func (o *QueryResultParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the query result params +func (o *QueryResultParams) WithContext(ctx context.Context) *QueryResultParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the query result params +func (o *QueryResultParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the query result params +func (o *QueryResultParams) WithHTTPClient(client *http.Client) *QueryResultParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the query result params +func (o *QueryResultParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the query result params +func (o *QueryResultParams) WithBody(body QueryResultBody) *QueryResultParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the query result params +func (o *QueryResultParams) SetBody(body QueryResultBody) { + o.Body = body +} + +// WithQueryID adds the queryID to the query result params +func (o *QueryResultParams) WithQueryID(queryID string) *QueryResultParams { + o.SetQueryID(queryID) + return o +} + +// SetQueryID adds the queryId to the query result params +func (o *QueryResultParams) SetQueryID(queryID string) { + o.QueryID = queryID +} + +// WriteToRequest writes these params to a swagger request +func (o *QueryResultParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + + // path param queryId + if err := r.SetPathParam("queryId", o.QueryID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/swagger/client/picsure2/query_result_responses.go b/swagger/client/picsure2/query_result_responses.go new file mode 100644 index 00000000..74b7b454 --- /dev/null +++ b/swagger/client/picsure2/query_result_responses.go @@ -0,0 +1,205 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package picsure2 + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/lca1/medco-connector/swagger/models" +) + +// QueryResultReader is a Reader for the QueryResult structure. +type QueryResultReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *QueryResultReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + + case 200: + result := NewQueryResultOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + + default: + result := NewQueryResultDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result + } +} + +// NewQueryResultOK creates a QueryResultOK with default headers values +func NewQueryResultOK() *QueryResultOK { + return &QueryResultOK{} +} + +/*QueryResultOK handles this case with default header values. + +Query result. +*/ +type QueryResultOK struct { + Payload *models.QueryResultElement +} + +func (o *QueryResultOK) Error() string { + return fmt.Sprintf("[POST /picsure2/{queryId}/result][%d] queryResultOK %+v", 200, o.Payload) +} + +func (o *QueryResultOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.QueryResultElement) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewQueryResultDefault creates a QueryResultDefault with default headers values +func NewQueryResultDefault(code int) *QueryResultDefault { + return &QueryResultDefault{ + _statusCode: code, + } +} + +/*QueryResultDefault handles this case with default header values. + +Error response +*/ +type QueryResultDefault struct { + _statusCode int + + Payload *QueryResultDefaultBody +} + +// Code gets the status code for the query result default response +func (o *QueryResultDefault) Code() int { + return o._statusCode +} + +func (o *QueryResultDefault) Error() string { + return fmt.Sprintf("[POST /picsure2/{queryId}/result][%d] queryResult default %+v", o._statusCode, o.Payload) +} + +func (o *QueryResultDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(QueryResultDefaultBody) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +/*QueryResultBody query result body +swagger:model QueryResultBody +*/ +type QueryResultBody struct { + + // resource credentials + ResourceCredentials *models.ResourceCredentials `json:"resourceCredentials,omitempty"` +} + +// Validate validates this query result body +func (o *QueryResultBody) Validate(formats strfmt.Registry) error { + var res []error + + if err := o.validateResourceCredentials(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *QueryResultBody) validateResourceCredentials(formats strfmt.Registry) error { + + if swag.IsZero(o.ResourceCredentials) { // not required + return nil + } + + if o.ResourceCredentials != nil { + if err := o.ResourceCredentials.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("body" + "." + "resourceCredentials") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (o *QueryResultBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *QueryResultBody) UnmarshalBinary(b []byte) error { + var res QueryResultBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} + +/*QueryResultDefaultBody query result default body +swagger:model QueryResultDefaultBody +*/ +type QueryResultDefaultBody struct { + + // message + Message string `json:"message,omitempty"` +} + +// Validate validates this query result default body +func (o *QueryResultDefaultBody) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *QueryResultDefaultBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *QueryResultDefaultBody) UnmarshalBinary(b []byte) error { + var res QueryResultDefaultBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} diff --git a/swagger/client/picsure2/query_status_parameters.go b/swagger/client/picsure2/query_status_parameters.go new file mode 100644 index 00000000..13fccdb8 --- /dev/null +++ b/swagger/client/picsure2/query_status_parameters.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package picsure2 + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + + strfmt "github.com/go-openapi/strfmt" +) + +// NewQueryStatusParams creates a new QueryStatusParams object +// with the default values initialized. +func NewQueryStatusParams() *QueryStatusParams { + var () + return &QueryStatusParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewQueryStatusParamsWithTimeout creates a new QueryStatusParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewQueryStatusParamsWithTimeout(timeout time.Duration) *QueryStatusParams { + var () + return &QueryStatusParams{ + + timeout: timeout, + } +} + +// NewQueryStatusParamsWithContext creates a new QueryStatusParams object +// with the default values initialized, and the ability to set a context for a request +func NewQueryStatusParamsWithContext(ctx context.Context) *QueryStatusParams { + var () + return &QueryStatusParams{ + + Context: ctx, + } +} + +// NewQueryStatusParamsWithHTTPClient creates a new QueryStatusParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewQueryStatusParamsWithHTTPClient(client *http.Client) *QueryStatusParams { + var () + return &QueryStatusParams{ + HTTPClient: client, + } +} + +/*QueryStatusParams contains all the parameters to send to the API endpoint +for the query status operation typically these are written to a http.Request +*/ +type QueryStatusParams struct { + + /*Body + Credentials to be used. + + */ + Body QueryStatusBody + /*QueryID + Query ID + + */ + QueryID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the query status params +func (o *QueryStatusParams) WithTimeout(timeout time.Duration) *QueryStatusParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the query status params +func (o *QueryStatusParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the query status params +func (o *QueryStatusParams) WithContext(ctx context.Context) *QueryStatusParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the query status params +func (o *QueryStatusParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the query status params +func (o *QueryStatusParams) WithHTTPClient(client *http.Client) *QueryStatusParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the query status params +func (o *QueryStatusParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the query status params +func (o *QueryStatusParams) WithBody(body QueryStatusBody) *QueryStatusParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the query status params +func (o *QueryStatusParams) SetBody(body QueryStatusBody) { + o.Body = body +} + +// WithQueryID adds the queryID to the query status params +func (o *QueryStatusParams) WithQueryID(queryID string) *QueryStatusParams { + o.SetQueryID(queryID) + return o +} + +// SetQueryID adds the queryId to the query status params +func (o *QueryStatusParams) SetQueryID(queryID string) { + o.QueryID = queryID +} + +// WriteToRequest writes these params to a swagger request +func (o *QueryStatusParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + + // path param queryId + if err := r.SetPathParam("queryId", o.QueryID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/swagger/client/picsure2/query_status_responses.go b/swagger/client/picsure2/query_status_responses.go new file mode 100644 index 00000000..146c2785 --- /dev/null +++ b/swagger/client/picsure2/query_status_responses.go @@ -0,0 +1,205 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package picsure2 + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/lca1/medco-connector/swagger/models" +) + +// QueryStatusReader is a Reader for the QueryStatus structure. +type QueryStatusReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *QueryStatusReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + + case 200: + result := NewQueryStatusOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + + default: + result := NewQueryStatusDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result + } +} + +// NewQueryStatusOK creates a QueryStatusOK with default headers values +func NewQueryStatusOK() *QueryStatusOK { + return &QueryStatusOK{} +} + +/*QueryStatusOK handles this case with default header values. + +Query status. +*/ +type QueryStatusOK struct { + Payload *models.QueryStatus +} + +func (o *QueryStatusOK) Error() string { + return fmt.Sprintf("[POST /picsure2/{queryId}/status][%d] queryStatusOK %+v", 200, o.Payload) +} + +func (o *QueryStatusOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.QueryStatus) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewQueryStatusDefault creates a QueryStatusDefault with default headers values +func NewQueryStatusDefault(code int) *QueryStatusDefault { + return &QueryStatusDefault{ + _statusCode: code, + } +} + +/*QueryStatusDefault handles this case with default header values. + +Error response +*/ +type QueryStatusDefault struct { + _statusCode int + + Payload *QueryStatusDefaultBody +} + +// Code gets the status code for the query status default response +func (o *QueryStatusDefault) Code() int { + return o._statusCode +} + +func (o *QueryStatusDefault) Error() string { + return fmt.Sprintf("[POST /picsure2/{queryId}/status][%d] queryStatus default %+v", o._statusCode, o.Payload) +} + +func (o *QueryStatusDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(QueryStatusDefaultBody) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +/*QueryStatusBody query status body +swagger:model QueryStatusBody +*/ +type QueryStatusBody struct { + + // resource credentials + ResourceCredentials *models.ResourceCredentials `json:"resourceCredentials,omitempty"` +} + +// Validate validates this query status body +func (o *QueryStatusBody) Validate(formats strfmt.Registry) error { + var res []error + + if err := o.validateResourceCredentials(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *QueryStatusBody) validateResourceCredentials(formats strfmt.Registry) error { + + if swag.IsZero(o.ResourceCredentials) { // not required + return nil + } + + if o.ResourceCredentials != nil { + if err := o.ResourceCredentials.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("body" + "." + "resourceCredentials") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (o *QueryStatusBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *QueryStatusBody) UnmarshalBinary(b []byte) error { + var res QueryStatusBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} + +/*QueryStatusDefaultBody query status default body +swagger:model QueryStatusDefaultBody +*/ +type QueryStatusDefaultBody struct { + + // message + Message string `json:"message,omitempty"` +} + +// Validate validates this query status default body +func (o *QueryStatusDefaultBody) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *QueryStatusDefaultBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *QueryStatusDefaultBody) UnmarshalBinary(b []byte) error { + var res QueryStatusDefaultBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} diff --git a/swagger/client/picsure2/query_sync_parameters.go b/swagger/client/picsure2/query_sync_parameters.go new file mode 100644 index 00000000..882f4430 --- /dev/null +++ b/swagger/client/picsure2/query_sync_parameters.go @@ -0,0 +1,135 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package picsure2 + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + + strfmt "github.com/go-openapi/strfmt" +) + +// NewQuerySyncParams creates a new QuerySyncParams object +// with the default values initialized. +func NewQuerySyncParams() *QuerySyncParams { + var () + return &QuerySyncParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewQuerySyncParamsWithTimeout creates a new QuerySyncParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewQuerySyncParamsWithTimeout(timeout time.Duration) *QuerySyncParams { + var () + return &QuerySyncParams{ + + timeout: timeout, + } +} + +// NewQuerySyncParamsWithContext creates a new QuerySyncParams object +// with the default values initialized, and the ability to set a context for a request +func NewQuerySyncParamsWithContext(ctx context.Context) *QuerySyncParams { + var () + return &QuerySyncParams{ + + Context: ctx, + } +} + +// NewQuerySyncParamsWithHTTPClient creates a new QuerySyncParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewQuerySyncParamsWithHTTPClient(client *http.Client) *QuerySyncParams { + var () + return &QuerySyncParams{ + HTTPClient: client, + } +} + +/*QuerySyncParams contains all the parameters to send to the API endpoint +for the query sync operation typically these are written to a http.Request +*/ +type QuerySyncParams struct { + + /*Body + Query request. + + */ + Body QuerySyncBody + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the query sync params +func (o *QuerySyncParams) WithTimeout(timeout time.Duration) *QuerySyncParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the query sync params +func (o *QuerySyncParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the query sync params +func (o *QuerySyncParams) WithContext(ctx context.Context) *QuerySyncParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the query sync params +func (o *QuerySyncParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the query sync params +func (o *QuerySyncParams) WithHTTPClient(client *http.Client) *QuerySyncParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the query sync params +func (o *QuerySyncParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the query sync params +func (o *QuerySyncParams) WithBody(body QuerySyncBody) *QuerySyncParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the query sync params +func (o *QuerySyncParams) SetBody(body QuerySyncBody) { + o.Body = body +} + +// WriteToRequest writes these params to a swagger request +func (o *QuerySyncParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/swagger/client/picsure2/query_sync_responses.go b/swagger/client/picsure2/query_sync_responses.go new file mode 100644 index 00000000..47ba44c1 --- /dev/null +++ b/swagger/client/picsure2/query_sync_responses.go @@ -0,0 +1,233 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package picsure2 + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/lca1/medco-connector/swagger/models" +) + +// QuerySyncReader is a Reader for the QuerySync structure. +type QuerySyncReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *QuerySyncReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + + case 200: + result := NewQuerySyncOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + + default: + result := NewQuerySyncDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result + } +} + +// NewQuerySyncOK creates a QuerySyncOK with default headers values +func NewQuerySyncOK() *QuerySyncOK { + return &QuerySyncOK{} +} + +/*QuerySyncOK handles this case with default header values. + +Query result. +*/ +type QuerySyncOK struct { + Payload *models.QueryResultElement +} + +func (o *QuerySyncOK) Error() string { + return fmt.Sprintf("[POST /picsure2/query/sync][%d] querySyncOK %+v", 200, o.Payload) +} + +func (o *QuerySyncOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.QueryResultElement) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewQuerySyncDefault creates a QuerySyncDefault with default headers values +func NewQuerySyncDefault(code int) *QuerySyncDefault { + return &QuerySyncDefault{ + _statusCode: code, + } +} + +/*QuerySyncDefault handles this case with default header values. + +Error response +*/ +type QuerySyncDefault struct { + _statusCode int + + Payload *QuerySyncDefaultBody +} + +// Code gets the status code for the query sync default response +func (o *QuerySyncDefault) Code() int { + return o._statusCode +} + +func (o *QuerySyncDefault) Error() string { + return fmt.Sprintf("[POST /picsure2/query/sync][%d] querySync default %+v", o._statusCode, o.Payload) +} + +func (o *QuerySyncDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(QuerySyncDefaultBody) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +/*QuerySyncBody query sync body +swagger:model QuerySyncBody +*/ +type QuerySyncBody struct { + + // query + Query *models.Query `json:"query,omitempty"` + + // resource credentials + ResourceCredentials *models.ResourceCredentials `json:"resourceCredentials,omitempty"` + + // resource UUID + ResourceUUID string `json:"resourceUUID,omitempty"` +} + +// Validate validates this query sync body +func (o *QuerySyncBody) Validate(formats strfmt.Registry) error { + var res []error + + if err := o.validateQuery(formats); err != nil { + res = append(res, err) + } + + if err := o.validateResourceCredentials(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *QuerySyncBody) validateQuery(formats strfmt.Registry) error { + + if swag.IsZero(o.Query) { // not required + return nil + } + + if o.Query != nil { + if err := o.Query.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("body" + "." + "query") + } + return err + } + } + + return nil +} + +func (o *QuerySyncBody) validateResourceCredentials(formats strfmt.Registry) error { + + if swag.IsZero(o.ResourceCredentials) { // not required + return nil + } + + if o.ResourceCredentials != nil { + if err := o.ResourceCredentials.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("body" + "." + "resourceCredentials") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (o *QuerySyncBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *QuerySyncBody) UnmarshalBinary(b []byte) error { + var res QuerySyncBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} + +/*QuerySyncDefaultBody query sync default body +swagger:model QuerySyncDefaultBody +*/ +type QuerySyncDefaultBody struct { + + // message + Message string `json:"message,omitempty"` +} + +// Validate validates this query sync default body +func (o *QuerySyncDefaultBody) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *QuerySyncDefaultBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *QuerySyncDefaultBody) UnmarshalBinary(b []byte) error { + var res QuerySyncDefaultBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} diff --git a/swagger/client/picsure2/search_parameters.go b/swagger/client/picsure2/search_parameters.go new file mode 100644 index 00000000..50e9d51a --- /dev/null +++ b/swagger/client/picsure2/search_parameters.go @@ -0,0 +1,135 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package picsure2 + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + + strfmt "github.com/go-openapi/strfmt" +) + +// NewSearchParams creates a new SearchParams object +// with the default values initialized. +func NewSearchParams() *SearchParams { + var () + return &SearchParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewSearchParamsWithTimeout creates a new SearchParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewSearchParamsWithTimeout(timeout time.Duration) *SearchParams { + var () + return &SearchParams{ + + timeout: timeout, + } +} + +// NewSearchParamsWithContext creates a new SearchParams object +// with the default values initialized, and the ability to set a context for a request +func NewSearchParamsWithContext(ctx context.Context) *SearchParams { + var () + return &SearchParams{ + + Context: ctx, + } +} + +// NewSearchParamsWithHTTPClient creates a new SearchParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewSearchParamsWithHTTPClient(client *http.Client) *SearchParams { + var () + return &SearchParams{ + HTTPClient: client, + } +} + +/*SearchParams contains all the parameters to send to the API endpoint +for the search operation typically these are written to a http.Request +*/ +type SearchParams struct { + + /*Body + Search request. + + */ + Body SearchBody + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the search params +func (o *SearchParams) WithTimeout(timeout time.Duration) *SearchParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the search params +func (o *SearchParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the search params +func (o *SearchParams) WithContext(ctx context.Context) *SearchParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the search params +func (o *SearchParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the search params +func (o *SearchParams) WithHTTPClient(client *http.Client) *SearchParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the search params +func (o *SearchParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the search params +func (o *SearchParams) WithBody(body SearchBody) *SearchParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the search params +func (o *SearchParams) SetBody(body SearchBody) { + o.Body = body +} + +// WriteToRequest writes these params to a swagger request +func (o *SearchParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/swagger/client/picsure2/search_responses.go b/swagger/client/picsure2/search_responses.go new file mode 100644 index 00000000..d94f068b --- /dev/null +++ b/swagger/client/picsure2/search_responses.go @@ -0,0 +1,303 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package picsure2 + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/lca1/medco-connector/swagger/models" +) + +// SearchReader is a Reader for the Search structure. +type SearchReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *SearchReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + + case 200: + result := NewSearchOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + + default: + result := NewSearchDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result + } +} + +// NewSearchOK creates a SearchOK with default headers values +func NewSearchOK() *SearchOK { + return &SearchOK{} +} + +/*SearchOK handles this case with default header values. + +Search results. +*/ +type SearchOK struct { + Payload *SearchOKBody +} + +func (o *SearchOK) Error() string { + return fmt.Sprintf("[POST /picsure2/search][%d] searchOK %+v", 200, o.Payload) +} + +func (o *SearchOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(SearchOKBody) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewSearchDefault creates a SearchDefault with default headers values +func NewSearchDefault(code int) *SearchDefault { + return &SearchDefault{ + _statusCode: code, + } +} + +/*SearchDefault handles this case with default header values. + +Error response +*/ +type SearchDefault struct { + _statusCode int + + Payload *SearchDefaultBody +} + +// Code gets the status code for the search default response +func (o *SearchDefault) Code() int { + return o._statusCode +} + +func (o *SearchDefault) Error() string { + return fmt.Sprintf("[POST /picsure2/search][%d] search default %+v", o._statusCode, o.Payload) +} + +func (o *SearchDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(SearchDefaultBody) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +/*SearchBody search body +swagger:model SearchBody +*/ +type SearchBody struct { + + // query + Query *models.SearchQuery `json:"query,omitempty"` + + // resource credentials + ResourceCredentials *models.ResourceCredentials `json:"resourceCredentials,omitempty"` + + // resource UUID + ResourceUUID string `json:"resourceUUID,omitempty"` +} + +// Validate validates this search body +func (o *SearchBody) Validate(formats strfmt.Registry) error { + var res []error + + if err := o.validateQuery(formats); err != nil { + res = append(res, err) + } + + if err := o.validateResourceCredentials(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *SearchBody) validateQuery(formats strfmt.Registry) error { + + if swag.IsZero(o.Query) { // not required + return nil + } + + if o.Query != nil { + if err := o.Query.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("body" + "." + "query") + } + return err + } + } + + return nil +} + +func (o *SearchBody) validateResourceCredentials(formats strfmt.Registry) error { + + if swag.IsZero(o.ResourceCredentials) { // not required + return nil + } + + if o.ResourceCredentials != nil { + if err := o.ResourceCredentials.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("body" + "." + "resourceCredentials") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (o *SearchBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *SearchBody) UnmarshalBinary(b []byte) error { + var res SearchBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} + +/*SearchDefaultBody search default body +swagger:model SearchDefaultBody +*/ +type SearchDefaultBody struct { + + // message + Message string `json:"message,omitempty"` +} + +// Validate validates this search default body +func (o *SearchDefaultBody) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *SearchDefaultBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *SearchDefaultBody) UnmarshalBinary(b []byte) error { + var res SearchDefaultBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} + +/*SearchOKBody search o k body +swagger:model SearchOKBody +*/ +type SearchOKBody struct { + + // results + Results []*models.SearchResultElement `json:"results"` + + // search query + SearchQuery string `json:"searchQuery,omitempty"` +} + +// Validate validates this search o k body +func (o *SearchOKBody) Validate(formats strfmt.Registry) error { + var res []error + + if err := o.validateResults(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *SearchOKBody) validateResults(formats strfmt.Registry) error { + + if swag.IsZero(o.Results) { // not required + return nil + } + + for i := 0; i < len(o.Results); i++ { + if swag.IsZero(o.Results[i]) { // not required + continue + } + + if o.Results[i] != nil { + if err := o.Results[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("searchOK" + "." + "results" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (o *SearchOKBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *SearchOKBody) UnmarshalBinary(b []byte) error { + var res SearchOKBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} From 364f30706208f7fbd29b0d2031f7b10db862336c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Thu, 23 May 2019 16:03:00 +0200 Subject: [PATCH 14/41] linting --- Makefile | 2 +- medco/query_logic.go | 4 ++-- medco/query_type.go | 4 ++++ unlynx/client_distributed.go | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index aac436c8..60e80b59 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ swagger-gen: test_lint: @echo Checking linting of files @{ \ - go install golang.org/x/lint/golint; \ + GO111MODULE=off go get -u golang.org/x/lint/golint; \ el=$(EXCLUDE_LINT); \ lintfiles=$$( golint ./... | egrep -v "$$el" ); \ if [ -n "$$lintfiles" ]; then \ diff --git a/medco/query_logic.go b/medco/query_logic.go index 766d1204..478f6584 100644 --- a/medco/query_logic.go +++ b/medco/query_logic.go @@ -33,10 +33,10 @@ func NewI2b2MedCoQuery(queryName string, query *models.QueryI2b2Medco) (new I2b2 return new, new.isValid() } -// todo: breakdown in i2b2 / count / patient list -// todo: implement obfuscation // Execute implements the I2b2 MedCo query logic func (q *I2b2MedCoQuery) Execute(queryType I2b2MedCoQueryType) (err error) { + // todo: breakdown in i2b2 / count / patient list + // todo: implement obfuscation err = q.isValid() if err != nil { diff --git a/medco/query_type.go b/medco/query_type.go index a2edc0ad..5c3ef632 100644 --- a/medco/query_type.go +++ b/medco/query_type.go @@ -23,9 +23,13 @@ type I2b2MedCoQueryType struct { // todo: include differential privacy requested } +// CountType encodes the type of count, either global or per site type CountType int const ( + // PerSite represents the count broken down per site PerSite = iota + + // Global represents the count globally aggregated over all sites Global ) diff --git a/unlynx/client_distributed.go b/unlynx/client_distributed.go index 5279329f..22c6200e 100644 --- a/unlynx/client_distributed.go +++ b/unlynx/client_distributed.go @@ -63,7 +63,7 @@ func DDTagValues(queryName string, values []string) (taggedValues map[string]str return } -// KeySwitchValues makes request through unlynx to key switch a single encrypted value (convenience function) +// KeySwitchValue makes request through unlynx to key switch a single encrypted value (convenience function) func KeySwitchValue(queryName string, value string, targetPubKey string) (string, error) { results, err := KeySwitchValues(queryName, []string{value}, targetPubKey) return results[0], err From e39374b75dbc73aa04457618cce9b1fde2b2a7f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Tue, 28 May 2019 14:56:09 +0200 Subject: [PATCH 15/41] move up swagger folder --- Makefile | 12 ++++++------ .../medco_cli_client_client.go | 2 +- .../picsure2/get_info_parameters.go | 0 .../picsure2/get_info_responses.go | 2 +- .../picsure2/picsure2_client.go | 0 .../picsure2/query_parameters.go | 0 .../picsure2/query_responses.go | 2 +- .../picsure2/query_result_parameters.go | 0 .../picsure2/query_result_responses.go | 2 +- .../picsure2/query_status_parameters.go | 0 .../picsure2/query_status_responses.go | 2 +- .../picsure2/query_sync_parameters.go | 0 .../picsure2/query_sync_responses.go | 2 +- .../picsure2/search_parameters.go | 0 .../picsure2/search_responses.go | 2 +- .../medco-connector-server/main.go | 4 ++-- i2b2/ontology_query.go | 2 +- medco/picsure2_api_handlers.go | 4 ++-- medco/query_logic.go | 2 +- medco/query_type.go | 2 +- {swagger/models => models}/query.go | 0 .../models => models}/query_result_element.go | 0 {swagger/models => models}/query_status.go | 0 {swagger/models => models}/query_type.go | 0 .../models => models}/resource_credentials.go | 0 {swagger/models => models}/search_query.go | 0 .../search_result_element.go | 0 {swagger/models => models}/user.go | 0 .../configure_medco_connector.go | 19 +++++++++---------- {swagger/restapi => restapi}/doc.go | 0 {swagger/restapi => restapi}/embedded_spec.go | 0 .../operations/medco_connector_api.go | 4 ++-- .../operations/picsure2/get_info.go | 2 +- .../picsure2/get_info_parameters.go | 0 .../operations/picsure2/get_info_responses.go | 0 .../picsure2/get_info_urlbuilder.go | 0 .../operations/picsure2/query.go | 2 +- .../operations/picsure2/query_parameters.go | 0 .../operations/picsure2/query_responses.go | 2 +- .../operations/picsure2/query_result.go | 2 +- .../picsure2/query_result_parameters.go | 0 .../picsure2/query_result_responses.go | 2 +- .../picsure2/query_result_urlbuilder.go | 0 .../operations/picsure2/query_status.go | 2 +- .../picsure2/query_status_parameters.go | 0 .../picsure2/query_status_responses.go | 2 +- .../picsure2/query_status_urlbuilder.go | 0 .../operations/picsure2/query_sync.go | 2 +- .../picsure2/query_sync_parameters.go | 0 .../picsure2/query_sync_responses.go | 2 +- .../picsure2/query_sync_urlbuilder.go | 0 .../operations/picsure2/query_urlbuilder.go | 0 .../operations/picsure2/search.go | 2 +- .../operations/picsure2/search_parameters.go | 0 .../operations/picsure2/search_responses.go | 0 .../operations/picsure2/search_urlbuilder.go | 0 {swagger/restapi => restapi}/server.go | 2 +- swagger/swagger.yml => swagger.yml | 0 util/security.go | 2 +- 59 files changed, 43 insertions(+), 44 deletions(-) rename {swagger/client => client}/medco_cli_client_client.go (98%) rename {swagger/client => client}/picsure2/get_info_parameters.go (100%) rename {swagger/client => client}/picsure2/get_info_responses.go (99%) rename {swagger/client => client}/picsure2/picsure2_client.go (100%) rename {swagger/client => client}/picsure2/query_parameters.go (100%) rename {swagger/client => client}/picsure2/query_responses.go (99%) rename {swagger/client => client}/picsure2/query_result_parameters.go (100%) rename {swagger/client => client}/picsure2/query_result_responses.go (98%) rename {swagger/client => client}/picsure2/query_status_parameters.go (100%) rename {swagger/client => client}/picsure2/query_status_responses.go (98%) rename {swagger/client => client}/picsure2/query_sync_parameters.go (100%) rename {swagger/client => client}/picsure2/query_sync_responses.go (99%) rename {swagger/client => client}/picsure2/search_parameters.go (100%) rename {swagger/client => client}/picsure2/search_responses.go (99%) rename {swagger/cmd => cmd}/medco-connector-server/main.go (91%) rename {swagger/models => models}/query.go (100%) rename {swagger/models => models}/query_result_element.go (100%) rename {swagger/models => models}/query_status.go (100%) rename {swagger/models => models}/query_type.go (100%) rename {swagger/models => models}/resource_credentials.go (100%) rename {swagger/models => models}/search_query.go (100%) rename {swagger/models => models}/search_result_element.go (100%) rename {swagger/models => models}/user.go (100%) rename {swagger/restapi => restapi}/configure_medco_connector.go (77%) rename {swagger/restapi => restapi}/doc.go (100%) rename {swagger/restapi => restapi}/embedded_spec.go (100%) rename {swagger/restapi => restapi}/operations/medco_connector_api.go (99%) rename {swagger/restapi => restapi}/operations/picsure2/get_info.go (99%) rename {swagger/restapi => restapi}/operations/picsure2/get_info_parameters.go (100%) rename {swagger/restapi => restapi}/operations/picsure2/get_info_responses.go (100%) rename {swagger/restapi => restapi}/operations/picsure2/get_info_urlbuilder.go (100%) rename {swagger/restapi => restapi}/operations/picsure2/query.go (98%) rename {swagger/restapi => restapi}/operations/picsure2/query_parameters.go (100%) rename {swagger/restapi => restapi}/operations/picsure2/query_responses.go (97%) rename {swagger/restapi => restapi}/operations/picsure2/query_result.go (98%) rename {swagger/restapi => restapi}/operations/picsure2/query_result_parameters.go (100%) rename {swagger/restapi => restapi}/operations/picsure2/query_result_responses.go (98%) rename {swagger/restapi => restapi}/operations/picsure2/query_result_urlbuilder.go (100%) rename {swagger/restapi => restapi}/operations/picsure2/query_status.go (98%) rename {swagger/restapi => restapi}/operations/picsure2/query_status_parameters.go (100%) rename {swagger/restapi => restapi}/operations/picsure2/query_status_responses.go (97%) rename {swagger/restapi => restapi}/operations/picsure2/query_status_urlbuilder.go (100%) rename {swagger/restapi => restapi}/operations/picsure2/query_sync.go (98%) rename {swagger/restapi => restapi}/operations/picsure2/query_sync_parameters.go (100%) rename {swagger/restapi => restapi}/operations/picsure2/query_sync_responses.go (97%) rename {swagger/restapi => restapi}/operations/picsure2/query_sync_urlbuilder.go (100%) rename {swagger/restapi => restapi}/operations/picsure2/query_urlbuilder.go (100%) rename {swagger/restapi => restapi}/operations/picsure2/search.go (99%) rename {swagger/restapi => restapi}/operations/picsure2/search_parameters.go (100%) rename {swagger/restapi => restapi}/operations/picsure2/search_responses.go (100%) rename {swagger/restapi => restapi}/operations/picsure2/search_urlbuilder.go (100%) rename {swagger/restapi => restapi}/server.go (99%) rename swagger/swagger.yml => swagger.yml (100%) diff --git a/Makefile b/Makefile index 60e80b59..17aa0153 100644 --- a/Makefile +++ b/Makefile @@ -2,18 +2,18 @@ EXCLUDE_LINT = "_test.go" # generate/update go server based on swagger specifications swagger-gen: - swagger validate ./swagger/swagger.yml + swagger validate ./swagger.yml swagger generate server \ --principal=models.User \ - --target=./swagger/ \ - --spec=./swagger/swagger.yml \ + --target=./ \ + --spec=./swagger.yml \ --name=medco-connector swagger generate client \ --principal=models.User \ - --target=./swagger/ \ - --spec=./swagger/swagger.yml \ + --target=./ \ + --spec=./swagger.yml \ --name=medco-cli-client \ - --existing-models=github.com/lca1/medco-connector/swagger/models \ + --existing-models=github.com/lca1/medco-connector/models \ --default-scheme=https test_lint: diff --git a/swagger/client/medco_cli_client_client.go b/client/medco_cli_client_client.go similarity index 98% rename from swagger/client/medco_cli_client_client.go rename to client/medco_cli_client_client.go index b7ca21af..ce0cfa0f 100644 --- a/swagger/client/medco_cli_client_client.go +++ b/client/medco_cli_client_client.go @@ -11,7 +11,7 @@ import ( strfmt "github.com/go-openapi/strfmt" - "github.com/lca1/medco-connector/swagger/client/picsure2" + "github.com/lca1/medco-connector/client/picsure2" ) // Default medco cli client HTTP client. diff --git a/swagger/client/picsure2/get_info_parameters.go b/client/picsure2/get_info_parameters.go similarity index 100% rename from swagger/client/picsure2/get_info_parameters.go rename to client/picsure2/get_info_parameters.go diff --git a/swagger/client/picsure2/get_info_responses.go b/client/picsure2/get_info_responses.go similarity index 99% rename from swagger/client/picsure2/get_info_responses.go rename to client/picsure2/get_info_responses.go index 68b00292..932c9ab1 100644 --- a/swagger/client/picsure2/get_info_responses.go +++ b/client/picsure2/get_info_responses.go @@ -16,7 +16,7 @@ import ( strfmt "github.com/go-openapi/strfmt" - "github.com/lca1/medco-connector/swagger/models" + "github.com/lca1/medco-connector/models" ) // GetInfoReader is a Reader for the GetInfo structure. diff --git a/swagger/client/picsure2/picsure2_client.go b/client/picsure2/picsure2_client.go similarity index 100% rename from swagger/client/picsure2/picsure2_client.go rename to client/picsure2/picsure2_client.go diff --git a/swagger/client/picsure2/query_parameters.go b/client/picsure2/query_parameters.go similarity index 100% rename from swagger/client/picsure2/query_parameters.go rename to client/picsure2/query_parameters.go diff --git a/swagger/client/picsure2/query_responses.go b/client/picsure2/query_responses.go similarity index 99% rename from swagger/client/picsure2/query_responses.go rename to client/picsure2/query_responses.go index c956794d..d3ff6bc0 100644 --- a/swagger/client/picsure2/query_responses.go +++ b/client/picsure2/query_responses.go @@ -15,7 +15,7 @@ import ( strfmt "github.com/go-openapi/strfmt" - "github.com/lca1/medco-connector/swagger/models" + "github.com/lca1/medco-connector/models" ) // QueryReader is a Reader for the Query structure. diff --git a/swagger/client/picsure2/query_result_parameters.go b/client/picsure2/query_result_parameters.go similarity index 100% rename from swagger/client/picsure2/query_result_parameters.go rename to client/picsure2/query_result_parameters.go diff --git a/swagger/client/picsure2/query_result_responses.go b/client/picsure2/query_result_responses.go similarity index 98% rename from swagger/client/picsure2/query_result_responses.go rename to client/picsure2/query_result_responses.go index 74b7b454..8e8677c6 100644 --- a/swagger/client/picsure2/query_result_responses.go +++ b/client/picsure2/query_result_responses.go @@ -15,7 +15,7 @@ import ( strfmt "github.com/go-openapi/strfmt" - "github.com/lca1/medco-connector/swagger/models" + "github.com/lca1/medco-connector/models" ) // QueryResultReader is a Reader for the QueryResult structure. diff --git a/swagger/client/picsure2/query_status_parameters.go b/client/picsure2/query_status_parameters.go similarity index 100% rename from swagger/client/picsure2/query_status_parameters.go rename to client/picsure2/query_status_parameters.go diff --git a/swagger/client/picsure2/query_status_responses.go b/client/picsure2/query_status_responses.go similarity index 98% rename from swagger/client/picsure2/query_status_responses.go rename to client/picsure2/query_status_responses.go index 146c2785..0355e68b 100644 --- a/swagger/client/picsure2/query_status_responses.go +++ b/client/picsure2/query_status_responses.go @@ -15,7 +15,7 @@ import ( strfmt "github.com/go-openapi/strfmt" - "github.com/lca1/medco-connector/swagger/models" + "github.com/lca1/medco-connector/models" ) // QueryStatusReader is a Reader for the QueryStatus structure. diff --git a/swagger/client/picsure2/query_sync_parameters.go b/client/picsure2/query_sync_parameters.go similarity index 100% rename from swagger/client/picsure2/query_sync_parameters.go rename to client/picsure2/query_sync_parameters.go diff --git a/swagger/client/picsure2/query_sync_responses.go b/client/picsure2/query_sync_responses.go similarity index 99% rename from swagger/client/picsure2/query_sync_responses.go rename to client/picsure2/query_sync_responses.go index 47ba44c1..9d6ebea7 100644 --- a/swagger/client/picsure2/query_sync_responses.go +++ b/client/picsure2/query_sync_responses.go @@ -15,7 +15,7 @@ import ( strfmt "github.com/go-openapi/strfmt" - "github.com/lca1/medco-connector/swagger/models" + "github.com/lca1/medco-connector/models" ) // QuerySyncReader is a Reader for the QuerySync structure. diff --git a/swagger/client/picsure2/search_parameters.go b/client/picsure2/search_parameters.go similarity index 100% rename from swagger/client/picsure2/search_parameters.go rename to client/picsure2/search_parameters.go diff --git a/swagger/client/picsure2/search_responses.go b/client/picsure2/search_responses.go similarity index 99% rename from swagger/client/picsure2/search_responses.go rename to client/picsure2/search_responses.go index d94f068b..537a6f5a 100644 --- a/swagger/client/picsure2/search_responses.go +++ b/client/picsure2/search_responses.go @@ -16,7 +16,7 @@ import ( strfmt "github.com/go-openapi/strfmt" - "github.com/lca1/medco-connector/swagger/models" + "github.com/lca1/medco-connector/models" ) // SearchReader is a Reader for the Search structure. diff --git a/swagger/cmd/medco-connector-server/main.go b/cmd/medco-connector-server/main.go similarity index 91% rename from swagger/cmd/medco-connector-server/main.go rename to cmd/medco-connector-server/main.go index 3a93e0cc..2600bc46 100644 --- a/swagger/cmd/medco-connector-server/main.go +++ b/cmd/medco-connector-server/main.go @@ -8,8 +8,8 @@ import ( loads "github.com/go-openapi/loads" flags "github.com/jessevdk/go-flags" - "github.com/lca1/medco-connector/swagger/restapi" - "github.com/lca1/medco-connector/swagger/restapi/operations" + "github.com/lca1/medco-connector/restapi" + "github.com/lca1/medco-connector/restapi/operations" ) // This file was generated by the swagger tool. diff --git a/i2b2/ontology_query.go b/i2b2/ontology_query.go index a405d372..31ac5464 100644 --- a/i2b2/ontology_query.go +++ b/i2b2/ontology_query.go @@ -2,7 +2,7 @@ package i2b2 import ( "errors" - "github.com/lca1/medco-connector/swagger/models" + "github.com/lca1/medco-connector/models" "github.com/lca1/medco-connector/util" "github.com/sirupsen/logrus" "strconv" diff --git a/medco/picsure2_api_handlers.go b/medco/picsure2_api_handlers.go index 8e97520f..cef54ab5 100644 --- a/medco/picsure2_api_handlers.go +++ b/medco/picsure2_api_handlers.go @@ -3,8 +3,8 @@ package medco import( "github.com/go-openapi/runtime/middleware" "github.com/lca1/medco-connector/i2b2" - "github.com/lca1/medco-connector/swagger/models" - "github.com/lca1/medco-connector/swagger/restapi/operations/picsure2" + "github.com/lca1/medco-connector/models" + "github.com/lca1/medco-connector/restapi/operations/picsure2" "github.com/lca1/medco-connector/util" ) diff --git a/medco/query_logic.go b/medco/query_logic.go index 478f6584..d77f1976 100644 --- a/medco/query_logic.go +++ b/medco/query_logic.go @@ -2,7 +2,7 @@ package medco import ( "github.com/lca1/medco-connector/i2b2" - "github.com/lca1/medco-connector/swagger/models" + "github.com/lca1/medco-connector/models" "github.com/lca1/medco-connector/unlynx" "github.com/pkg/errors" "github.com/sirupsen/logrus" diff --git a/medco/query_type.go b/medco/query_type.go index 5c3ef632..d907629c 100644 --- a/medco/query_type.go +++ b/medco/query_type.go @@ -2,7 +2,7 @@ package medco import ( "errors" - "github.com/lca1/medco-connector/swagger/models" + "github.com/lca1/medco-connector/models" ) // I2b2MedCoQueryType encodes the requested results from the query diff --git a/swagger/models/query.go b/models/query.go similarity index 100% rename from swagger/models/query.go rename to models/query.go diff --git a/swagger/models/query_result_element.go b/models/query_result_element.go similarity index 100% rename from swagger/models/query_result_element.go rename to models/query_result_element.go diff --git a/swagger/models/query_status.go b/models/query_status.go similarity index 100% rename from swagger/models/query_status.go rename to models/query_status.go diff --git a/swagger/models/query_type.go b/models/query_type.go similarity index 100% rename from swagger/models/query_type.go rename to models/query_type.go diff --git a/swagger/models/resource_credentials.go b/models/resource_credentials.go similarity index 100% rename from swagger/models/resource_credentials.go rename to models/resource_credentials.go diff --git a/swagger/models/search_query.go b/models/search_query.go similarity index 100% rename from swagger/models/search_query.go rename to models/search_query.go diff --git a/swagger/models/search_result_element.go b/models/search_result_element.go similarity index 100% rename from swagger/models/search_result_element.go rename to models/search_result_element.go diff --git a/swagger/models/user.go b/models/user.go similarity index 100% rename from swagger/models/user.go rename to models/user.go diff --git a/swagger/restapi/configure_medco_connector.go b/restapi/configure_medco_connector.go similarity index 77% rename from swagger/restapi/configure_medco_connector.go rename to restapi/configure_medco_connector.go index 7c801054..3f2f156c 100644 --- a/swagger/restapi/configure_medco_connector.go +++ b/restapi/configure_medco_connector.go @@ -9,12 +9,11 @@ import ( "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/runtime/security" "github.com/lca1/medco-connector/medco" - "github.com/lca1/medco-connector/swagger/models" + "github.com/lca1/medco-connector/models" + "github.com/lca1/medco-connector/restapi/operations" + picsure22 "github.com/lca1/medco-connector/restapi/operations/picsure2" "github.com/sirupsen/logrus" "net/http" - - "github.com/lca1/medco-connector/swagger/restapi/operations" - "github.com/lca1/medco-connector/swagger/restapi/operations/picsure2" ) //go:generate swagger generate server --target ../../swagger --name MedcoConnector --spec ../swagger.yml @@ -39,28 +38,28 @@ func configureAPI(api *operations.MedcoConnectorAPI) http.Handler { } // /medco/picsure2/info - api.Picsure2GetInfoHandler = picsure2.GetInfoHandlerFunc(medco.GetInfoHandlerFunc) + api.Picsure2GetInfoHandler = picsure22.GetInfoHandlerFunc(medco.GetInfoHandlerFunc) // /medco/picsure2/query - api.Picsure2QueryHandler = picsure2.QueryHandlerFunc(func(params picsure2.QueryParams, principal *models.User) middleware.Responder { + api.Picsure2QueryHandler = picsure22.QueryHandlerFunc(func(params picsure22.QueryParams, principal *models.User) middleware.Responder { return middleware.NotImplemented("operation picsure2.Query has not yet been implemented") }) // /medco/picsure2/query/{id}/result - api.Picsure2QueryResultHandler = picsure2.QueryResultHandlerFunc(func(params picsure2.QueryResultParams, principal *models.User) middleware.Responder { + api.Picsure2QueryResultHandler = picsure22.QueryResultHandlerFunc(func(params picsure22.QueryResultParams, principal *models.User) middleware.Responder { return middleware.NotImplemented("operation picsure2.QueryResult has not yet been implemented") }) // /medco/picsure2/query/{id}/status - api.Picsure2QueryStatusHandler = picsure2.QueryStatusHandlerFunc(func(params picsure2.QueryStatusParams, principal *models.User) middleware.Responder { + api.Picsure2QueryStatusHandler = picsure22.QueryStatusHandlerFunc(func(params picsure22.QueryStatusParams, principal *models.User) middleware.Responder { return middleware.NotImplemented("operation picsure2.QueryStatus has not yet been implemented") }) // /medco/picsure2/query/sync - api.Picsure2QuerySyncHandler = picsure2.QuerySyncHandlerFunc(medco.QuerySyncHandlerFunc) + api.Picsure2QuerySyncHandler = picsure22.QuerySyncHandlerFunc(medco.QuerySyncHandlerFunc) // /medco/picsure2/search - api.Picsure2SearchHandler = picsure2.SearchHandlerFunc(medco.SearchHandlerFunc) + api.Picsure2SearchHandler = picsure22.SearchHandlerFunc(medco.SearchHandlerFunc) api.ServerShutdown = func() {} diff --git a/swagger/restapi/doc.go b/restapi/doc.go similarity index 100% rename from swagger/restapi/doc.go rename to restapi/doc.go diff --git a/swagger/restapi/embedded_spec.go b/restapi/embedded_spec.go similarity index 100% rename from swagger/restapi/embedded_spec.go rename to restapi/embedded_spec.go diff --git a/swagger/restapi/operations/medco_connector_api.go b/restapi/operations/medco_connector_api.go similarity index 99% rename from swagger/restapi/operations/medco_connector_api.go rename to restapi/operations/medco_connector_api.go index 87276998..6db81d32 100644 --- a/swagger/restapi/operations/medco_connector_api.go +++ b/restapi/operations/medco_connector_api.go @@ -19,9 +19,9 @@ import ( strfmt "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - "github.com/lca1/medco-connector/swagger/restapi/operations/picsure2" + "github.com/lca1/medco-connector/restapi/operations/picsure2" - models "github.com/lca1/medco-connector/swagger/models" + models "github.com/lca1/medco-connector/models" ) // NewMedcoConnectorAPI creates a new MedcoConnector instance diff --git a/swagger/restapi/operations/picsure2/get_info.go b/restapi/operations/picsure2/get_info.go similarity index 99% rename from swagger/restapi/operations/picsure2/get_info.go rename to restapi/operations/picsure2/get_info.go index b4d5de3c..cd921b17 100644 --- a/swagger/restapi/operations/picsure2/get_info.go +++ b/restapi/operations/picsure2/get_info.go @@ -14,7 +14,7 @@ import ( strfmt "github.com/go-openapi/strfmt" swag "github.com/go-openapi/swag" - models "github.com/lca1/medco-connector/swagger/models" + models "github.com/lca1/medco-connector/models" ) // GetInfoHandlerFunc turns a function with the right signature into a get info handler diff --git a/swagger/restapi/operations/picsure2/get_info_parameters.go b/restapi/operations/picsure2/get_info_parameters.go similarity index 100% rename from swagger/restapi/operations/picsure2/get_info_parameters.go rename to restapi/operations/picsure2/get_info_parameters.go diff --git a/swagger/restapi/operations/picsure2/get_info_responses.go b/restapi/operations/picsure2/get_info_responses.go similarity index 100% rename from swagger/restapi/operations/picsure2/get_info_responses.go rename to restapi/operations/picsure2/get_info_responses.go diff --git a/swagger/restapi/operations/picsure2/get_info_urlbuilder.go b/restapi/operations/picsure2/get_info_urlbuilder.go similarity index 100% rename from swagger/restapi/operations/picsure2/get_info_urlbuilder.go rename to restapi/operations/picsure2/get_info_urlbuilder.go diff --git a/swagger/restapi/operations/picsure2/query.go b/restapi/operations/picsure2/query.go similarity index 98% rename from swagger/restapi/operations/picsure2/query.go rename to restapi/operations/picsure2/query.go index df4dcfdc..4cb16e53 100644 --- a/swagger/restapi/operations/picsure2/query.go +++ b/restapi/operations/picsure2/query.go @@ -13,7 +13,7 @@ import ( strfmt "github.com/go-openapi/strfmt" swag "github.com/go-openapi/swag" - models "github.com/lca1/medco-connector/swagger/models" + models "github.com/lca1/medco-connector/models" ) // QueryHandlerFunc turns a function with the right signature into a query handler diff --git a/swagger/restapi/operations/picsure2/query_parameters.go b/restapi/operations/picsure2/query_parameters.go similarity index 100% rename from swagger/restapi/operations/picsure2/query_parameters.go rename to restapi/operations/picsure2/query_parameters.go diff --git a/swagger/restapi/operations/picsure2/query_responses.go b/restapi/operations/picsure2/query_responses.go similarity index 97% rename from swagger/restapi/operations/picsure2/query_responses.go rename to restapi/operations/picsure2/query_responses.go index a227f12f..91f9c977 100644 --- a/swagger/restapi/operations/picsure2/query_responses.go +++ b/restapi/operations/picsure2/query_responses.go @@ -10,7 +10,7 @@ import ( "github.com/go-openapi/runtime" - models "github.com/lca1/medco-connector/swagger/models" + models "github.com/lca1/medco-connector/models" ) // QueryOKCode is the HTTP code returned for type QueryOK diff --git a/swagger/restapi/operations/picsure2/query_result.go b/restapi/operations/picsure2/query_result.go similarity index 98% rename from swagger/restapi/operations/picsure2/query_result.go rename to restapi/operations/picsure2/query_result.go index fa94e9e1..c8ea4044 100644 --- a/swagger/restapi/operations/picsure2/query_result.go +++ b/restapi/operations/picsure2/query_result.go @@ -13,7 +13,7 @@ import ( strfmt "github.com/go-openapi/strfmt" swag "github.com/go-openapi/swag" - models "github.com/lca1/medco-connector/swagger/models" + models "github.com/lca1/medco-connector/models" ) // QueryResultHandlerFunc turns a function with the right signature into a query result handler diff --git a/swagger/restapi/operations/picsure2/query_result_parameters.go b/restapi/operations/picsure2/query_result_parameters.go similarity index 100% rename from swagger/restapi/operations/picsure2/query_result_parameters.go rename to restapi/operations/picsure2/query_result_parameters.go diff --git a/swagger/restapi/operations/picsure2/query_result_responses.go b/restapi/operations/picsure2/query_result_responses.go similarity index 98% rename from swagger/restapi/operations/picsure2/query_result_responses.go rename to restapi/operations/picsure2/query_result_responses.go index e1c1c7fa..6f11cc3b 100644 --- a/swagger/restapi/operations/picsure2/query_result_responses.go +++ b/restapi/operations/picsure2/query_result_responses.go @@ -10,7 +10,7 @@ import ( "github.com/go-openapi/runtime" - models "github.com/lca1/medco-connector/swagger/models" + models "github.com/lca1/medco-connector/models" ) // QueryResultOKCode is the HTTP code returned for type QueryResultOK diff --git a/swagger/restapi/operations/picsure2/query_result_urlbuilder.go b/restapi/operations/picsure2/query_result_urlbuilder.go similarity index 100% rename from swagger/restapi/operations/picsure2/query_result_urlbuilder.go rename to restapi/operations/picsure2/query_result_urlbuilder.go diff --git a/swagger/restapi/operations/picsure2/query_status.go b/restapi/operations/picsure2/query_status.go similarity index 98% rename from swagger/restapi/operations/picsure2/query_status.go rename to restapi/operations/picsure2/query_status.go index 9fa7ba77..a9751a7c 100644 --- a/swagger/restapi/operations/picsure2/query_status.go +++ b/restapi/operations/picsure2/query_status.go @@ -13,7 +13,7 @@ import ( strfmt "github.com/go-openapi/strfmt" swag "github.com/go-openapi/swag" - models "github.com/lca1/medco-connector/swagger/models" + models "github.com/lca1/medco-connector/models" ) // QueryStatusHandlerFunc turns a function with the right signature into a query status handler diff --git a/swagger/restapi/operations/picsure2/query_status_parameters.go b/restapi/operations/picsure2/query_status_parameters.go similarity index 100% rename from swagger/restapi/operations/picsure2/query_status_parameters.go rename to restapi/operations/picsure2/query_status_parameters.go diff --git a/swagger/restapi/operations/picsure2/query_status_responses.go b/restapi/operations/picsure2/query_status_responses.go similarity index 97% rename from swagger/restapi/operations/picsure2/query_status_responses.go rename to restapi/operations/picsure2/query_status_responses.go index a170eaa6..aa6aa343 100644 --- a/swagger/restapi/operations/picsure2/query_status_responses.go +++ b/restapi/operations/picsure2/query_status_responses.go @@ -10,7 +10,7 @@ import ( "github.com/go-openapi/runtime" - models "github.com/lca1/medco-connector/swagger/models" + models "github.com/lca1/medco-connector/models" ) // QueryStatusOKCode is the HTTP code returned for type QueryStatusOK diff --git a/swagger/restapi/operations/picsure2/query_status_urlbuilder.go b/restapi/operations/picsure2/query_status_urlbuilder.go similarity index 100% rename from swagger/restapi/operations/picsure2/query_status_urlbuilder.go rename to restapi/operations/picsure2/query_status_urlbuilder.go diff --git a/swagger/restapi/operations/picsure2/query_sync.go b/restapi/operations/picsure2/query_sync.go similarity index 98% rename from swagger/restapi/operations/picsure2/query_sync.go rename to restapi/operations/picsure2/query_sync.go index 9d3fa79b..3868daa1 100644 --- a/swagger/restapi/operations/picsure2/query_sync.go +++ b/restapi/operations/picsure2/query_sync.go @@ -13,7 +13,7 @@ import ( strfmt "github.com/go-openapi/strfmt" swag "github.com/go-openapi/swag" - models "github.com/lca1/medco-connector/swagger/models" + models "github.com/lca1/medco-connector/models" ) // QuerySyncHandlerFunc turns a function with the right signature into a query sync handler diff --git a/swagger/restapi/operations/picsure2/query_sync_parameters.go b/restapi/operations/picsure2/query_sync_parameters.go similarity index 100% rename from swagger/restapi/operations/picsure2/query_sync_parameters.go rename to restapi/operations/picsure2/query_sync_parameters.go diff --git a/swagger/restapi/operations/picsure2/query_sync_responses.go b/restapi/operations/picsure2/query_sync_responses.go similarity index 97% rename from swagger/restapi/operations/picsure2/query_sync_responses.go rename to restapi/operations/picsure2/query_sync_responses.go index e4a9ebb8..7d6e0649 100644 --- a/swagger/restapi/operations/picsure2/query_sync_responses.go +++ b/restapi/operations/picsure2/query_sync_responses.go @@ -10,7 +10,7 @@ import ( "github.com/go-openapi/runtime" - models "github.com/lca1/medco-connector/swagger/models" + models "github.com/lca1/medco-connector/models" ) // QuerySyncOKCode is the HTTP code returned for type QuerySyncOK diff --git a/swagger/restapi/operations/picsure2/query_sync_urlbuilder.go b/restapi/operations/picsure2/query_sync_urlbuilder.go similarity index 100% rename from swagger/restapi/operations/picsure2/query_sync_urlbuilder.go rename to restapi/operations/picsure2/query_sync_urlbuilder.go diff --git a/swagger/restapi/operations/picsure2/query_urlbuilder.go b/restapi/operations/picsure2/query_urlbuilder.go similarity index 100% rename from swagger/restapi/operations/picsure2/query_urlbuilder.go rename to restapi/operations/picsure2/query_urlbuilder.go diff --git a/swagger/restapi/operations/picsure2/search.go b/restapi/operations/picsure2/search.go similarity index 99% rename from swagger/restapi/operations/picsure2/search.go rename to restapi/operations/picsure2/search.go index 31222df1..250ac667 100644 --- a/swagger/restapi/operations/picsure2/search.go +++ b/restapi/operations/picsure2/search.go @@ -14,7 +14,7 @@ import ( strfmt "github.com/go-openapi/strfmt" swag "github.com/go-openapi/swag" - models "github.com/lca1/medco-connector/swagger/models" + models "github.com/lca1/medco-connector/models" ) // SearchHandlerFunc turns a function with the right signature into a search handler diff --git a/swagger/restapi/operations/picsure2/search_parameters.go b/restapi/operations/picsure2/search_parameters.go similarity index 100% rename from swagger/restapi/operations/picsure2/search_parameters.go rename to restapi/operations/picsure2/search_parameters.go diff --git a/swagger/restapi/operations/picsure2/search_responses.go b/restapi/operations/picsure2/search_responses.go similarity index 100% rename from swagger/restapi/operations/picsure2/search_responses.go rename to restapi/operations/picsure2/search_responses.go diff --git a/swagger/restapi/operations/picsure2/search_urlbuilder.go b/restapi/operations/picsure2/search_urlbuilder.go similarity index 100% rename from swagger/restapi/operations/picsure2/search_urlbuilder.go rename to restapi/operations/picsure2/search_urlbuilder.go diff --git a/swagger/restapi/server.go b/restapi/server.go similarity index 99% rename from swagger/restapi/server.go rename to restapi/server.go index 7c5f0551..0d008bba 100644 --- a/swagger/restapi/server.go +++ b/restapi/server.go @@ -25,7 +25,7 @@ import ( flags "github.com/jessevdk/go-flags" "golang.org/x/net/netutil" - "github.com/lca1/medco-connector/swagger/restapi/operations" + "github.com/lca1/medco-connector/restapi/operations" ) const ( diff --git a/swagger/swagger.yml b/swagger.yml similarity index 100% rename from swagger/swagger.yml rename to swagger.yml diff --git a/util/security.go b/util/security.go index 5901ac9c..8f502c8e 100644 --- a/util/security.go +++ b/util/security.go @@ -3,7 +3,7 @@ package util import ( "encoding/json" "errors" - "github.com/lca1/medco-connector/swagger/models" + "github.com/lca1/medco-connector/models" "github.com/lestrrat-go/jwx/jwk" "github.com/lestrrat-go/jwx/jws" "github.com/lestrrat-go/jwx/jwt" From 3be765216bb5a843fffe06ab9bb14a1211bf251d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Tue, 28 May 2019 16:27:39 +0200 Subject: [PATCH 16/41] reorganize packages --- cmd/medco-connector-server/main.go | 12 ++-- i2b2/ontology_query.go | 2 +- medco/picsure2_api_handlers.go | 4 +- medco/query_logic.go | 2 +- medco/query_type.go | 2 +- .../client}/medco_cli_client_client.go | 9 ++- .../client}/picsure2/get_info_parameters.go | 2 +- .../client}/picsure2/get_info_responses.go | 4 +- .../client}/picsure2/picsure2_client.go | 26 ++++----- .../client}/picsure2/query_parameters.go | 2 +- .../client}/picsure2/query_responses.go | 4 +- .../picsure2/query_result_parameters.go | 2 +- .../picsure2/query_result_responses.go | 4 +- .../picsure2/query_status_parameters.go | 2 +- .../picsure2/query_status_responses.go | 4 +- .../client}/picsure2/query_sync_parameters.go | 2 +- .../client}/picsure2/query_sync_responses.go | 4 +- .../client}/picsure2/search_parameters.go | 2 +- .../client}/picsure2/search_responses.go | 4 +- {models => restapi/models}/query.go | 4 +- .../models}/query_result_element.go | 4 +- {models => restapi/models}/query_status.go | 0 {models => restapi/models}/query_type.go | 0 .../models}/resource_credentials.go | 0 {models => restapi/models}/search_query.go | 0 .../models}/search_result_element.go | 0 {models => restapi/models}/user.go | 4 +- .../{ => server}/configure_medco_connector.go | 8 +-- restapi/{ => server}/doc.go | 2 +- restapi/{ => server}/embedded_spec.go | 2 +- .../operations/medco_connector_api.go | 55 +++++++++---------- .../operations/picsure2/get_info.go | 10 ++-- .../picsure2/get_info_parameters.go | 2 +- .../operations/picsure2/get_info_responses.go | 0 .../picsure2/get_info_urlbuilder.go | 0 .../{ => server}/operations/picsure2/query.go | 10 ++-- .../operations/picsure2/query_parameters.go | 2 +- .../operations/picsure2/query_responses.go | 2 +- .../operations/picsure2/query_result.go | 10 ++-- .../picsure2/query_result_parameters.go | 4 +- .../picsure2/query_result_responses.go | 2 +- .../picsure2/query_result_urlbuilder.go | 0 .../operations/picsure2/query_status.go | 10 ++-- .../picsure2/query_status_parameters.go | 4 +- .../picsure2/query_status_responses.go | 2 +- .../picsure2/query_status_urlbuilder.go | 0 .../operations/picsure2/query_sync.go | 10 ++-- .../picsure2/query_sync_parameters.go | 2 +- .../picsure2/query_sync_responses.go | 2 +- .../picsure2/query_sync_urlbuilder.go | 0 .../operations/picsure2/query_urlbuilder.go | 0 .../operations/picsure2/search.go | 10 ++-- .../operations/picsure2/search_parameters.go | 2 +- .../operations/picsure2/search_responses.go | 0 .../operations/picsure2/search_urlbuilder.go | 0 restapi/{ => server}/server.go | 6 +- util/security.go | 2 +- 57 files changed, 131 insertions(+), 133 deletions(-) rename {client => restapi/client}/medco_cli_client_client.go (94%) rename {client => restapi/client}/picsure2/get_info_parameters.go (98%) rename {client => restapi/client}/picsure2/get_info_responses.go (98%) rename {client => restapi/client}/picsure2/picsure2_client.go (91%) rename {client => restapi/client}/picsure2/query_parameters.go (98%) rename {client => restapi/client}/picsure2/query_responses.go (98%) rename {client => restapi/client}/picsure2/query_result_parameters.go (99%) rename {client => restapi/client}/picsure2/query_result_responses.go (98%) rename {client => restapi/client}/picsure2/query_status_parameters.go (99%) rename {client => restapi/client}/picsure2/query_status_responses.go (98%) rename {client => restapi/client}/picsure2/query_sync_parameters.go (98%) rename {client => restapi/client}/picsure2/query_sync_responses.go (98%) rename {client => restapi/client}/picsure2/search_parameters.go (98%) rename {client => restapi/client}/picsure2/search_responses.go (98%) rename {models => restapi/models}/query.go (98%) rename {models => restapi/models}/query_result_element.go (94%) rename {models => restapi/models}/query_status.go (100%) rename {models => restapi/models}/query_type.go (100%) rename {models => restapi/models}/resource_credentials.go (100%) rename {models => restapi/models}/search_query.go (100%) rename {models => restapi/models}/search_result_element.go (100%) rename {models => restapi/models}/user.go (96%) rename restapi/{ => server}/configure_medco_connector.go (94%) rename restapi/{ => server}/doc.go (97%) rename restapi/{ => server}/embedded_spec.go (99%) rename restapi/{ => server}/operations/medco_connector_api.go (83%) rename restapi/{ => server}/operations/picsure2/get_info.go (96%) rename restapi/{ => server}/operations/picsure2/get_info_parameters.go (97%) rename restapi/{ => server}/operations/picsure2/get_info_responses.go (100%) rename restapi/{ => server}/operations/picsure2/get_info_urlbuilder.go (100%) rename restapi/{ => server}/operations/picsure2/query.go (95%) rename restapi/{ => server}/operations/picsure2/query_parameters.go (96%) rename restapi/{ => server}/operations/picsure2/query_responses.go (98%) rename restapi/{ => server}/operations/picsure2/query_result.go (94%) rename restapi/{ => server}/operations/picsure2/query_result_parameters.go (96%) rename restapi/{ => server}/operations/picsure2/query_result_responses.go (98%) rename restapi/{ => server}/operations/picsure2/query_result_urlbuilder.go (100%) rename restapi/{ => server}/operations/picsure2/query_status.go (94%) rename restapi/{ => server}/operations/picsure2/query_status_parameters.go (96%) rename restapi/{ => server}/operations/picsure2/query_status_responses.go (98%) rename restapi/{ => server}/operations/picsure2/query_status_urlbuilder.go (100%) rename restapi/{ => server}/operations/picsure2/query_sync.go (95%) rename restapi/{ => server}/operations/picsure2/query_sync_parameters.go (97%) rename restapi/{ => server}/operations/picsure2/query_sync_responses.go (98%) rename restapi/{ => server}/operations/picsure2/query_sync_urlbuilder.go (100%) rename restapi/{ => server}/operations/picsure2/query_urlbuilder.go (100%) rename restapi/{ => server}/operations/picsure2/search.go (96%) rename restapi/{ => server}/operations/picsure2/search_parameters.go (97%) rename restapi/{ => server}/operations/picsure2/search_responses.go (100%) rename restapi/{ => server}/operations/picsure2/search_urlbuilder.go (100%) rename restapi/{ => server}/server.go (99%) diff --git a/cmd/medco-connector-server/main.go b/cmd/medco-connector-server/main.go index 2600bc46..8d0527f5 100644 --- a/cmd/medco-connector-server/main.go +++ b/cmd/medco-connector-server/main.go @@ -3,13 +3,13 @@ package main import ( + server2 "github.com/lca1/medco-connector/restapi/server" "log" "os" - loads "github.com/go-openapi/loads" - flags "github.com/jessevdk/go-flags" - "github.com/lca1/medco-connector/restapi" - "github.com/lca1/medco-connector/restapi/operations" + "github.com/go-openapi/loads" + "github.com/jessevdk/go-flags" + "github.com/lca1/medco-connector/restapi/server/operations" ) // This file was generated by the swagger tool. @@ -17,13 +17,13 @@ import ( func main() { - swaggerSpec, err := loads.Embedded(restapi.SwaggerJSON, restapi.FlatSwaggerJSON) + swaggerSpec, err := loads.Embedded(server2.SwaggerJSON, server2.FlatSwaggerJSON) if err != nil { log.Fatalln(err) } api := operations.NewMedcoConnectorAPI(swaggerSpec) - server := restapi.NewServer(api) + server := server2.NewServer(api) defer server.Shutdown() parser := flags.NewParser(server, flags.Default) diff --git a/i2b2/ontology_query.go b/i2b2/ontology_query.go index 31ac5464..9bebfc88 100644 --- a/i2b2/ontology_query.go +++ b/i2b2/ontology_query.go @@ -2,7 +2,7 @@ package i2b2 import ( "errors" - "github.com/lca1/medco-connector/models" + "github.com/lca1/medco-connector/restapi/models" "github.com/lca1/medco-connector/util" "github.com/sirupsen/logrus" "strconv" diff --git a/medco/picsure2_api_handlers.go b/medco/picsure2_api_handlers.go index cef54ab5..4273db49 100644 --- a/medco/picsure2_api_handlers.go +++ b/medco/picsure2_api_handlers.go @@ -3,8 +3,8 @@ package medco import( "github.com/go-openapi/runtime/middleware" "github.com/lca1/medco-connector/i2b2" - "github.com/lca1/medco-connector/models" - "github.com/lca1/medco-connector/restapi/operations/picsure2" + "github.com/lca1/medco-connector/restapi/models" + "github.com/lca1/medco-connector/restapi/server/operations/picsure2" "github.com/lca1/medco-connector/util" ) diff --git a/medco/query_logic.go b/medco/query_logic.go index d77f1976..96352ab1 100644 --- a/medco/query_logic.go +++ b/medco/query_logic.go @@ -2,7 +2,7 @@ package medco import ( "github.com/lca1/medco-connector/i2b2" - "github.com/lca1/medco-connector/models" + "github.com/lca1/medco-connector/restapi/models" "github.com/lca1/medco-connector/unlynx" "github.com/pkg/errors" "github.com/sirupsen/logrus" diff --git a/medco/query_type.go b/medco/query_type.go index d907629c..2ff305b6 100644 --- a/medco/query_type.go +++ b/medco/query_type.go @@ -2,7 +2,7 @@ package medco import ( "errors" - "github.com/lca1/medco-connector/models" + "github.com/lca1/medco-connector/restapi/models" ) // I2b2MedCoQueryType encodes the requested results from the query diff --git a/client/medco_cli_client_client.go b/restapi/client/medco_cli_client_client.go similarity index 94% rename from client/medco_cli_client_client.go rename to restapi/client/medco_cli_client_client.go index ce0cfa0f..0091d9e2 100644 --- a/client/medco_cli_client_client.go +++ b/restapi/client/medco_cli_client_client.go @@ -8,10 +8,9 @@ package client import ( "github.com/go-openapi/runtime" httptransport "github.com/go-openapi/runtime/client" + picsure22 "github.com/lca1/medco-connector/restapi/client/picsure2" - strfmt "github.com/go-openapi/strfmt" - - "github.com/lca1/medco-connector/client/picsure2" + "github.com/go-openapi/strfmt" ) // Default medco cli client HTTP client. @@ -57,7 +56,7 @@ func New(transport runtime.ClientTransport, formats strfmt.Registry) *MedcoCliCl cli := new(MedcoCliClient) cli.Transport = transport - cli.Picsure2 = picsure2.New(transport, formats) + cli.Picsure2 = picsure22.New(transport, formats) return cli } @@ -103,7 +102,7 @@ func (cfg *TransportConfig) WithSchemes(schemes []string) *TransportConfig { // MedcoCliClient is a client for medco cli client type MedcoCliClient struct { - Picsure2 *picsure2.Client + Picsure2 *picsure22.Client Transport runtime.ClientTransport } diff --git a/client/picsure2/get_info_parameters.go b/restapi/client/picsure2/get_info_parameters.go similarity index 98% rename from client/picsure2/get_info_parameters.go rename to restapi/client/picsure2/get_info_parameters.go index f21cd4ac..ef1c9d6c 100644 --- a/client/picsure2/get_info_parameters.go +++ b/restapi/client/picsure2/get_info_parameters.go @@ -14,7 +14,7 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) // NewGetInfoParams creates a new GetInfoParams object diff --git a/client/picsure2/get_info_responses.go b/restapi/client/picsure2/get_info_responses.go similarity index 98% rename from client/picsure2/get_info_responses.go rename to restapi/client/picsure2/get_info_responses.go index 932c9ab1..4fb24e7f 100644 --- a/client/picsure2/get_info_responses.go +++ b/restapi/client/picsure2/get_info_responses.go @@ -14,9 +14,9 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" - "github.com/lca1/medco-connector/models" + "github.com/lca1/medco-connector/restapi/models" ) // GetInfoReader is a Reader for the GetInfo structure. diff --git a/client/picsure2/picsure2_client.go b/restapi/client/picsure2/picsure2_client.go similarity index 91% rename from client/picsure2/picsure2_client.go rename to restapi/client/picsure2/picsure2_client.go index 31c5a96a..a9a0187b 100644 --- a/client/picsure2/picsure2_client.go +++ b/restapi/client/picsure2/picsure2_client.go @@ -8,7 +8,7 @@ package picsure2 import ( "github.com/go-openapi/runtime" - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) // New creates a new picsure2 API client. @@ -43,8 +43,8 @@ func (a *Client) GetInfo(params *GetInfoParams, authInfo runtime.ClientAuthInfoW Params: params, Reader: &GetInfoReader{formats: a.formats}, AuthInfo: authInfo, - Context: params.Context, - Client: params.HTTPClient, + Context: Context, + Client: HTTPClient, }) if err != nil { return nil, err @@ -72,8 +72,8 @@ func (a *Client) Query(params *QueryParams, authInfo runtime.ClientAuthInfoWrite Params: params, Reader: &QueryReader{formats: a.formats}, AuthInfo: authInfo, - Context: params.Context, - Client: params.HTTPClient, + Context: Context, + Client: HTTPClient, }) if err != nil { return nil, err @@ -101,8 +101,8 @@ func (a *Client) QueryResult(params *QueryResultParams, authInfo runtime.ClientA Params: params, Reader: &QueryResultReader{formats: a.formats}, AuthInfo: authInfo, - Context: params.Context, - Client: params.HTTPClient, + Context: Context, + Client: HTTPClient, }) if err != nil { return nil, err @@ -130,8 +130,8 @@ func (a *Client) QueryStatus(params *QueryStatusParams, authInfo runtime.ClientA Params: params, Reader: &QueryStatusReader{formats: a.formats}, AuthInfo: authInfo, - Context: params.Context, - Client: params.HTTPClient, + Context: Context, + Client: HTTPClient, }) if err != nil { return nil, err @@ -159,8 +159,8 @@ func (a *Client) QuerySync(params *QuerySyncParams, authInfo runtime.ClientAuthI Params: params, Reader: &QuerySyncReader{formats: a.formats}, AuthInfo: authInfo, - Context: params.Context, - Client: params.HTTPClient, + Context: Context, + Client: HTTPClient, }) if err != nil { return nil, err @@ -188,8 +188,8 @@ func (a *Client) Search(params *SearchParams, authInfo runtime.ClientAuthInfoWri Params: params, Reader: &SearchReader{formats: a.formats}, AuthInfo: authInfo, - Context: params.Context, - Client: params.HTTPClient, + Context: Context, + Client: HTTPClient, }) if err != nil { return nil, err diff --git a/client/picsure2/query_parameters.go b/restapi/client/picsure2/query_parameters.go similarity index 98% rename from client/picsure2/query_parameters.go rename to restapi/client/picsure2/query_parameters.go index bc88b8c4..96d53b2a 100644 --- a/client/picsure2/query_parameters.go +++ b/restapi/client/picsure2/query_parameters.go @@ -14,7 +14,7 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) // NewQueryParams creates a new QueryParams object diff --git a/client/picsure2/query_responses.go b/restapi/client/picsure2/query_responses.go similarity index 98% rename from client/picsure2/query_responses.go rename to restapi/client/picsure2/query_responses.go index d3ff6bc0..4c8d0f08 100644 --- a/client/picsure2/query_responses.go +++ b/restapi/client/picsure2/query_responses.go @@ -13,9 +13,9 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" - "github.com/lca1/medco-connector/models" + "github.com/lca1/medco-connector/restapi/models" ) // QueryReader is a Reader for the Query structure. diff --git a/client/picsure2/query_result_parameters.go b/restapi/client/picsure2/query_result_parameters.go similarity index 99% rename from client/picsure2/query_result_parameters.go rename to restapi/client/picsure2/query_result_parameters.go index 287bde86..e957f617 100644 --- a/client/picsure2/query_result_parameters.go +++ b/restapi/client/picsure2/query_result_parameters.go @@ -14,7 +14,7 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) // NewQueryResultParams creates a new QueryResultParams object diff --git a/client/picsure2/query_result_responses.go b/restapi/client/picsure2/query_result_responses.go similarity index 98% rename from client/picsure2/query_result_responses.go rename to restapi/client/picsure2/query_result_responses.go index 8e8677c6..005e9897 100644 --- a/client/picsure2/query_result_responses.go +++ b/restapi/client/picsure2/query_result_responses.go @@ -13,9 +13,9 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" - "github.com/lca1/medco-connector/models" + "github.com/lca1/medco-connector/restapi/models" ) // QueryResultReader is a Reader for the QueryResult structure. diff --git a/client/picsure2/query_status_parameters.go b/restapi/client/picsure2/query_status_parameters.go similarity index 99% rename from client/picsure2/query_status_parameters.go rename to restapi/client/picsure2/query_status_parameters.go index 13fccdb8..2a034eb1 100644 --- a/client/picsure2/query_status_parameters.go +++ b/restapi/client/picsure2/query_status_parameters.go @@ -14,7 +14,7 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) // NewQueryStatusParams creates a new QueryStatusParams object diff --git a/client/picsure2/query_status_responses.go b/restapi/client/picsure2/query_status_responses.go similarity index 98% rename from client/picsure2/query_status_responses.go rename to restapi/client/picsure2/query_status_responses.go index 0355e68b..0abae55f 100644 --- a/client/picsure2/query_status_responses.go +++ b/restapi/client/picsure2/query_status_responses.go @@ -13,9 +13,9 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" - "github.com/lca1/medco-connector/models" + "github.com/lca1/medco-connector/restapi/models" ) // QueryStatusReader is a Reader for the QueryStatus structure. diff --git a/client/picsure2/query_sync_parameters.go b/restapi/client/picsure2/query_sync_parameters.go similarity index 98% rename from client/picsure2/query_sync_parameters.go rename to restapi/client/picsure2/query_sync_parameters.go index 882f4430..3de088e7 100644 --- a/client/picsure2/query_sync_parameters.go +++ b/restapi/client/picsure2/query_sync_parameters.go @@ -14,7 +14,7 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) // NewQuerySyncParams creates a new QuerySyncParams object diff --git a/client/picsure2/query_sync_responses.go b/restapi/client/picsure2/query_sync_responses.go similarity index 98% rename from client/picsure2/query_sync_responses.go rename to restapi/client/picsure2/query_sync_responses.go index 9d6ebea7..2148e452 100644 --- a/client/picsure2/query_sync_responses.go +++ b/restapi/client/picsure2/query_sync_responses.go @@ -13,9 +13,9 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" - "github.com/lca1/medco-connector/models" + "github.com/lca1/medco-connector/restapi/models" ) // QuerySyncReader is a Reader for the QuerySync structure. diff --git a/client/picsure2/search_parameters.go b/restapi/client/picsure2/search_parameters.go similarity index 98% rename from client/picsure2/search_parameters.go rename to restapi/client/picsure2/search_parameters.go index 50e9d51a..3fb4acfa 100644 --- a/client/picsure2/search_parameters.go +++ b/restapi/client/picsure2/search_parameters.go @@ -14,7 +14,7 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) // NewSearchParams creates a new SearchParams object diff --git a/client/picsure2/search_responses.go b/restapi/client/picsure2/search_responses.go similarity index 98% rename from client/picsure2/search_responses.go rename to restapi/client/picsure2/search_responses.go index 537a6f5a..37e955c9 100644 --- a/client/picsure2/search_responses.go +++ b/restapi/client/picsure2/search_responses.go @@ -14,9 +14,9 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" - "github.com/lca1/medco-connector/models" + "github.com/lca1/medco-connector/restapi/models" ) // SearchReader is a Reader for the Search structure. diff --git a/models/query.go b/restapi/models/query.go similarity index 98% rename from models/query.go rename to restapi/models/query.go index 78abff03..ac296b73 100644 --- a/models/query.go +++ b/restapi/models/query.go @@ -9,7 +9,7 @@ import ( "encoding/json" "strconv" - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" "github.com/go-openapi/errors" "github.com/go-openapi/swag" @@ -168,7 +168,7 @@ func (m *QueryI2b2Medco) validateQueryType(formats strfmt.Registry) error { return nil } - if err := m.QueryType.Validate(formats); err != nil { + if err := Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("i2b2-medco" + "." + "queryType") } diff --git a/models/query_result_element.go b/restapi/models/query_result_element.go similarity index 94% rename from models/query_result_element.go rename to restapi/models/query_result_element.go index a547b3ca..48c23eaf 100644 --- a/models/query_result_element.go +++ b/restapi/models/query_result_element.go @@ -6,7 +6,7 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" "github.com/go-openapi/errors" "github.com/go-openapi/swag" @@ -49,7 +49,7 @@ func (m *QueryResultElement) validateQueryType(formats strfmt.Registry) error { return nil } - if err := m.QueryType.Validate(formats); err != nil { + if err := Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("queryType") } diff --git a/models/query_status.go b/restapi/models/query_status.go similarity index 100% rename from models/query_status.go rename to restapi/models/query_status.go diff --git a/models/query_type.go b/restapi/models/query_type.go similarity index 100% rename from models/query_type.go rename to restapi/models/query_type.go diff --git a/models/resource_credentials.go b/restapi/models/resource_credentials.go similarity index 100% rename from models/resource_credentials.go rename to restapi/models/resource_credentials.go diff --git a/models/search_query.go b/restapi/models/search_query.go similarity index 100% rename from models/search_query.go rename to restapi/models/search_query.go diff --git a/models/search_result_element.go b/restapi/models/search_result_element.go similarity index 100% rename from models/search_result_element.go rename to restapi/models/search_result_element.go diff --git a/models/user.go b/restapi/models/user.go similarity index 96% rename from models/user.go rename to restapi/models/user.go index b9fc3a41..6fc4e028 100644 --- a/models/user.go +++ b/restapi/models/user.go @@ -8,7 +8,7 @@ package models import ( "strconv" - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" "github.com/go-openapi/errors" "github.com/go-openapi/swag" @@ -108,7 +108,7 @@ func (m *UserAuthorizations) validateQueryType(formats strfmt.Registry) error { for i := 0; i < len(m.QueryType); i++ { - if err := m.QueryType[i].Validate(formats); err != nil { + if err := Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("authorizations" + "." + "queryType" + "." + strconv.Itoa(i)) } diff --git a/restapi/configure_medco_connector.go b/restapi/server/configure_medco_connector.go similarity index 94% rename from restapi/configure_medco_connector.go rename to restapi/server/configure_medco_connector.go index 3f2f156c..8cd27068 100644 --- a/restapi/configure_medco_connector.go +++ b/restapi/server/configure_medco_connector.go @@ -1,6 +1,6 @@ // This file is safe to edit. Once it exists it will not be overwritten -package restapi +package server import ( "crypto/tls" @@ -9,9 +9,9 @@ import ( "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/runtime/security" "github.com/lca1/medco-connector/medco" - "github.com/lca1/medco-connector/models" - "github.com/lca1/medco-connector/restapi/operations" - picsure22 "github.com/lca1/medco-connector/restapi/operations/picsure2" + "github.com/lca1/medco-connector/restapi/models" + "github.com/lca1/medco-connector/restapi/server/operations" + picsure22 "github.com/lca1/medco-connector/restapi/server/operations/picsure2" "github.com/sirupsen/logrus" "net/http" ) diff --git a/restapi/doc.go b/restapi/server/doc.go similarity index 97% rename from restapi/doc.go rename to restapi/server/doc.go index be6069cf..8583ea05 100644 --- a/restapi/doc.go +++ b/restapi/server/doc.go @@ -21,4 +21,4 @@ This is the API of the MedCo connector, that orchestrates the query at the MedCo swagger:meta */ -package restapi +package server diff --git a/restapi/embedded_spec.go b/restapi/server/embedded_spec.go similarity index 99% rename from restapi/embedded_spec.go rename to restapi/server/embedded_spec.go index fcf3f4e0..1b3da75a 100644 --- a/restapi/embedded_spec.go +++ b/restapi/server/embedded_spec.go @@ -1,6 +1,6 @@ // Code generated by go-swagger; DO NOT EDIT. -package restapi +package server // This file was generated by the swagger tool. // Editing this file might prove futile when you re-run the swagger generate command diff --git a/restapi/operations/medco_connector_api.go b/restapi/server/operations/medco_connector_api.go similarity index 83% rename from restapi/operations/medco_connector_api.go rename to restapi/server/operations/medco_connector_api.go index 6db81d32..faeef465 100644 --- a/restapi/operations/medco_connector_api.go +++ b/restapi/server/operations/medco_connector_api.go @@ -7,21 +7,20 @@ package operations import ( "fmt" + picsure22 "github.com/lca1/medco-connector/restapi/server/operations/picsure2" "net/http" "strings" - errors "github.com/go-openapi/errors" - loads "github.com/go-openapi/loads" - runtime "github.com/go-openapi/runtime" - middleware "github.com/go-openapi/runtime/middleware" - security "github.com/go-openapi/runtime/security" - spec "github.com/go-openapi/spec" - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/errors" + "github.com/go-openapi/loads" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/security" + "github.com/go-openapi/spec" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - "github.com/lca1/medco-connector/restapi/operations/picsure2" - - models "github.com/lca1/medco-connector/models" + "github.com/lca1/medco-connector/restapi/models" ) // NewMedcoConnectorAPI creates a new MedcoConnector instance @@ -41,22 +40,22 @@ func NewMedcoConnectorAPI(spec *loads.Document) *MedcoConnectorAPI { BearerAuthenticator: security.BearerAuth, JSONConsumer: runtime.JSONConsumer(), JSONProducer: runtime.JSONProducer(), - Picsure2GetInfoHandler: picsure2.GetInfoHandlerFunc(func(params picsure2.GetInfoParams, principal *models.User) middleware.Responder { + Picsure2GetInfoHandler: picsure22.GetInfoHandlerFunc(func(params picsure22.GetInfoParams, principal *models.User) middleware.Responder { return middleware.NotImplemented("operation Picsure2GetInfo has not yet been implemented") }), - Picsure2QueryHandler: picsure2.QueryHandlerFunc(func(params picsure2.QueryParams, principal *models.User) middleware.Responder { + Picsure2QueryHandler: picsure22.QueryHandlerFunc(func(params picsure22.QueryParams, principal *models.User) middleware.Responder { return middleware.NotImplemented("operation Picsure2Query has not yet been implemented") }), - Picsure2QueryResultHandler: picsure2.QueryResultHandlerFunc(func(params picsure2.QueryResultParams, principal *models.User) middleware.Responder { + Picsure2QueryResultHandler: picsure22.QueryResultHandlerFunc(func(params picsure22.QueryResultParams, principal *models.User) middleware.Responder { return middleware.NotImplemented("operation Picsure2QueryResult has not yet been implemented") }), - Picsure2QueryStatusHandler: picsure2.QueryStatusHandlerFunc(func(params picsure2.QueryStatusParams, principal *models.User) middleware.Responder { + Picsure2QueryStatusHandler: picsure22.QueryStatusHandlerFunc(func(params picsure22.QueryStatusParams, principal *models.User) middleware.Responder { return middleware.NotImplemented("operation Picsure2QueryStatus has not yet been implemented") }), - Picsure2QuerySyncHandler: picsure2.QuerySyncHandlerFunc(func(params picsure2.QuerySyncParams, principal *models.User) middleware.Responder { + Picsure2QuerySyncHandler: picsure22.QuerySyncHandlerFunc(func(params picsure22.QuerySyncParams, principal *models.User) middleware.Responder { return middleware.NotImplemented("operation Picsure2QuerySync has not yet been implemented") }), - Picsure2SearchHandler: picsure2.SearchHandlerFunc(func(params picsure2.SearchParams, principal *models.User) middleware.Responder { + Picsure2SearchHandler: picsure22.SearchHandlerFunc(func(params picsure22.SearchParams, principal *models.User) middleware.Responder { return middleware.NotImplemented("operation Picsure2Search has not yet been implemented") }), @@ -105,17 +104,17 @@ type MedcoConnectorAPI struct { APIAuthorizer runtime.Authorizer // Picsure2GetInfoHandler sets the operation handler for the get info operation - Picsure2GetInfoHandler picsure2.GetInfoHandler + Picsure2GetInfoHandler picsure22.GetInfoHandler // Picsure2QueryHandler sets the operation handler for the query operation - Picsure2QueryHandler picsure2.QueryHandler + Picsure2QueryHandler picsure22.QueryHandler // Picsure2QueryResultHandler sets the operation handler for the query result operation - Picsure2QueryResultHandler picsure2.QueryResultHandler + Picsure2QueryResultHandler picsure22.QueryResultHandler // Picsure2QueryStatusHandler sets the operation handler for the query status operation - Picsure2QueryStatusHandler picsure2.QueryStatusHandler + Picsure2QueryStatusHandler picsure22.QueryStatusHandler // Picsure2QuerySyncHandler sets the operation handler for the query sync operation - Picsure2QuerySyncHandler picsure2.QuerySyncHandler + Picsure2QuerySyncHandler picsure22.QuerySyncHandler // Picsure2SearchHandler sets the operation handler for the search operation - Picsure2SearchHandler picsure2.SearchHandler + Picsure2SearchHandler picsure22.SearchHandler // ServeError is called when an error is received, there is a default handler // but you can set your own with this @@ -320,32 +319,32 @@ func (o *MedcoConnectorAPI) initHandlerCache() { if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) } - o.handlers["POST"]["/picsure2/info"] = picsure2.NewGetInfo(o.context, o.Picsure2GetInfoHandler) + o.handlers["POST"]["/picsure2/info"] = picsure22.NewGetInfo(o.context, o.Picsure2GetInfoHandler) if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) } - o.handlers["POST"]["/picsure2/query"] = picsure2.NewQuery(o.context, o.Picsure2QueryHandler) + o.handlers["POST"]["/picsure2/query"] = picsure22.NewQuery(o.context, o.Picsure2QueryHandler) if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) } - o.handlers["POST"]["/picsure2/{queryId}/result"] = picsure2.NewQueryResult(o.context, o.Picsure2QueryResultHandler) + o.handlers["POST"]["/picsure2/{queryId}/result"] = picsure22.NewQueryResult(o.context, o.Picsure2QueryResultHandler) if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) } - o.handlers["POST"]["/picsure2/{queryId}/status"] = picsure2.NewQueryStatus(o.context, o.Picsure2QueryStatusHandler) + o.handlers["POST"]["/picsure2/{queryId}/status"] = picsure22.NewQueryStatus(o.context, o.Picsure2QueryStatusHandler) if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) } - o.handlers["POST"]["/picsure2/query/sync"] = picsure2.NewQuerySync(o.context, o.Picsure2QuerySyncHandler) + o.handlers["POST"]["/picsure2/query/sync"] = picsure22.NewQuerySync(o.context, o.Picsure2QuerySyncHandler) if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) } - o.handlers["POST"]["/picsure2/search"] = picsure2.NewSearch(o.context, o.Picsure2SearchHandler) + o.handlers["POST"]["/picsure2/search"] = picsure22.NewSearch(o.context, o.Picsure2SearchHandler) } diff --git a/restapi/operations/picsure2/get_info.go b/restapi/server/operations/picsure2/get_info.go similarity index 96% rename from restapi/operations/picsure2/get_info.go rename to restapi/server/operations/picsure2/get_info.go index cd921b17..ffa6e91f 100644 --- a/restapi/operations/picsure2/get_info.go +++ b/restapi/server/operations/picsure2/get_info.go @@ -9,12 +9,12 @@ import ( "net/http" "strconv" - errors "github.com/go-openapi/errors" - middleware "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" - swag "github.com/go-openapi/swag" + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" - models "github.com/lca1/medco-connector/models" + "github.com/lca1/medco-connector/restapi/models" ) // GetInfoHandlerFunc turns a function with the right signature into a get info handler diff --git a/restapi/operations/picsure2/get_info_parameters.go b/restapi/server/operations/picsure2/get_info_parameters.go similarity index 97% rename from restapi/operations/picsure2/get_info_parameters.go rename to restapi/server/operations/picsure2/get_info_parameters.go index 0cb82c3f..e041cca4 100644 --- a/restapi/operations/picsure2/get_info_parameters.go +++ b/restapi/server/operations/picsure2/get_info_parameters.go @@ -57,7 +57,7 @@ func (o *GetInfoParams) BindRequest(r *http.Request, route *middleware.MatchedRo } } else { // validate body object - if err := body.Validate(route.Formats); err != nil { + if err := Validate(route.Formats); err != nil { res = append(res, err) } diff --git a/restapi/operations/picsure2/get_info_responses.go b/restapi/server/operations/picsure2/get_info_responses.go similarity index 100% rename from restapi/operations/picsure2/get_info_responses.go rename to restapi/server/operations/picsure2/get_info_responses.go diff --git a/restapi/operations/picsure2/get_info_urlbuilder.go b/restapi/server/operations/picsure2/get_info_urlbuilder.go similarity index 100% rename from restapi/operations/picsure2/get_info_urlbuilder.go rename to restapi/server/operations/picsure2/get_info_urlbuilder.go diff --git a/restapi/operations/picsure2/query.go b/restapi/server/operations/picsure2/query.go similarity index 95% rename from restapi/operations/picsure2/query.go rename to restapi/server/operations/picsure2/query.go index 4cb16e53..e6782b35 100644 --- a/restapi/operations/picsure2/query.go +++ b/restapi/server/operations/picsure2/query.go @@ -8,12 +8,12 @@ package picsure2 import ( "net/http" - errors "github.com/go-openapi/errors" - middleware "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" - swag "github.com/go-openapi/swag" + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" - models "github.com/lca1/medco-connector/models" + "github.com/lca1/medco-connector/restapi/models" ) // QueryHandlerFunc turns a function with the right signature into a query handler diff --git a/restapi/operations/picsure2/query_parameters.go b/restapi/server/operations/picsure2/query_parameters.go similarity index 96% rename from restapi/operations/picsure2/query_parameters.go rename to restapi/server/operations/picsure2/query_parameters.go index 96cfa6cb..233aa731 100644 --- a/restapi/operations/picsure2/query_parameters.go +++ b/restapi/server/operations/picsure2/query_parameters.go @@ -57,7 +57,7 @@ func (o *QueryParams) BindRequest(r *http.Request, route *middleware.MatchedRout } } else { // validate body object - if err := body.Validate(route.Formats); err != nil { + if err := Validate(route.Formats); err != nil { res = append(res, err) } diff --git a/restapi/operations/picsure2/query_responses.go b/restapi/server/operations/picsure2/query_responses.go similarity index 98% rename from restapi/operations/picsure2/query_responses.go rename to restapi/server/operations/picsure2/query_responses.go index 91f9c977..38834b14 100644 --- a/restapi/operations/picsure2/query_responses.go +++ b/restapi/server/operations/picsure2/query_responses.go @@ -10,7 +10,7 @@ import ( "github.com/go-openapi/runtime" - models "github.com/lca1/medco-connector/models" + "github.com/lca1/medco-connector/restapi/models" ) // QueryOKCode is the HTTP code returned for type QueryOK diff --git a/restapi/operations/picsure2/query_result.go b/restapi/server/operations/picsure2/query_result.go similarity index 94% rename from restapi/operations/picsure2/query_result.go rename to restapi/server/operations/picsure2/query_result.go index c8ea4044..ad0ece06 100644 --- a/restapi/operations/picsure2/query_result.go +++ b/restapi/server/operations/picsure2/query_result.go @@ -8,12 +8,12 @@ package picsure2 import ( "net/http" - errors "github.com/go-openapi/errors" - middleware "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" - swag "github.com/go-openapi/swag" + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" - models "github.com/lca1/medco-connector/models" + "github.com/lca1/medco-connector/restapi/models" ) // QueryResultHandlerFunc turns a function with the right signature into a query result handler diff --git a/restapi/operations/picsure2/query_result_parameters.go b/restapi/server/operations/picsure2/query_result_parameters.go similarity index 96% rename from restapi/operations/picsure2/query_result_parameters.go rename to restapi/server/operations/picsure2/query_result_parameters.go index 973a9e56..61cd91c7 100644 --- a/restapi/operations/picsure2/query_result_parameters.go +++ b/restapi/server/operations/picsure2/query_result_parameters.go @@ -13,7 +13,7 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) // NewQueryResultParams creates a new QueryResultParams object @@ -64,7 +64,7 @@ func (o *QueryResultParams) BindRequest(r *http.Request, route *middleware.Match } } else { // validate body object - if err := body.Validate(route.Formats); err != nil { + if err := Validate(route.Formats); err != nil { res = append(res, err) } diff --git a/restapi/operations/picsure2/query_result_responses.go b/restapi/server/operations/picsure2/query_result_responses.go similarity index 98% rename from restapi/operations/picsure2/query_result_responses.go rename to restapi/server/operations/picsure2/query_result_responses.go index 6f11cc3b..c4acaea4 100644 --- a/restapi/operations/picsure2/query_result_responses.go +++ b/restapi/server/operations/picsure2/query_result_responses.go @@ -10,7 +10,7 @@ import ( "github.com/go-openapi/runtime" - models "github.com/lca1/medco-connector/models" + "github.com/lca1/medco-connector/restapi/models" ) // QueryResultOKCode is the HTTP code returned for type QueryResultOK diff --git a/restapi/operations/picsure2/query_result_urlbuilder.go b/restapi/server/operations/picsure2/query_result_urlbuilder.go similarity index 100% rename from restapi/operations/picsure2/query_result_urlbuilder.go rename to restapi/server/operations/picsure2/query_result_urlbuilder.go diff --git a/restapi/operations/picsure2/query_status.go b/restapi/server/operations/picsure2/query_status.go similarity index 94% rename from restapi/operations/picsure2/query_status.go rename to restapi/server/operations/picsure2/query_status.go index a9751a7c..3733e69c 100644 --- a/restapi/operations/picsure2/query_status.go +++ b/restapi/server/operations/picsure2/query_status.go @@ -8,12 +8,12 @@ package picsure2 import ( "net/http" - errors "github.com/go-openapi/errors" - middleware "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" - swag "github.com/go-openapi/swag" + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" - models "github.com/lca1/medco-connector/models" + "github.com/lca1/medco-connector/restapi/models" ) // QueryStatusHandlerFunc turns a function with the right signature into a query status handler diff --git a/restapi/operations/picsure2/query_status_parameters.go b/restapi/server/operations/picsure2/query_status_parameters.go similarity index 96% rename from restapi/operations/picsure2/query_status_parameters.go rename to restapi/server/operations/picsure2/query_status_parameters.go index 8e7c9cc2..9a9f07af 100644 --- a/restapi/operations/picsure2/query_status_parameters.go +++ b/restapi/server/operations/picsure2/query_status_parameters.go @@ -13,7 +13,7 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) // NewQueryStatusParams creates a new QueryStatusParams object @@ -64,7 +64,7 @@ func (o *QueryStatusParams) BindRequest(r *http.Request, route *middleware.Match } } else { // validate body object - if err := body.Validate(route.Formats); err != nil { + if err := Validate(route.Formats); err != nil { res = append(res, err) } diff --git a/restapi/operations/picsure2/query_status_responses.go b/restapi/server/operations/picsure2/query_status_responses.go similarity index 98% rename from restapi/operations/picsure2/query_status_responses.go rename to restapi/server/operations/picsure2/query_status_responses.go index aa6aa343..99e6ed5c 100644 --- a/restapi/operations/picsure2/query_status_responses.go +++ b/restapi/server/operations/picsure2/query_status_responses.go @@ -10,7 +10,7 @@ import ( "github.com/go-openapi/runtime" - models "github.com/lca1/medco-connector/models" + "github.com/lca1/medco-connector/restapi/models" ) // QueryStatusOKCode is the HTTP code returned for type QueryStatusOK diff --git a/restapi/operations/picsure2/query_status_urlbuilder.go b/restapi/server/operations/picsure2/query_status_urlbuilder.go similarity index 100% rename from restapi/operations/picsure2/query_status_urlbuilder.go rename to restapi/server/operations/picsure2/query_status_urlbuilder.go diff --git a/restapi/operations/picsure2/query_sync.go b/restapi/server/operations/picsure2/query_sync.go similarity index 95% rename from restapi/operations/picsure2/query_sync.go rename to restapi/server/operations/picsure2/query_sync.go index 3868daa1..905e3a0e 100644 --- a/restapi/operations/picsure2/query_sync.go +++ b/restapi/server/operations/picsure2/query_sync.go @@ -8,12 +8,12 @@ package picsure2 import ( "net/http" - errors "github.com/go-openapi/errors" - middleware "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" - swag "github.com/go-openapi/swag" + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" - models "github.com/lca1/medco-connector/models" + "github.com/lca1/medco-connector/restapi/models" ) // QuerySyncHandlerFunc turns a function with the right signature into a query sync handler diff --git a/restapi/operations/picsure2/query_sync_parameters.go b/restapi/server/operations/picsure2/query_sync_parameters.go similarity index 97% rename from restapi/operations/picsure2/query_sync_parameters.go rename to restapi/server/operations/picsure2/query_sync_parameters.go index 737d750f..e335f5ca 100644 --- a/restapi/operations/picsure2/query_sync_parameters.go +++ b/restapi/server/operations/picsure2/query_sync_parameters.go @@ -57,7 +57,7 @@ func (o *QuerySyncParams) BindRequest(r *http.Request, route *middleware.Matched } } else { // validate body object - if err := body.Validate(route.Formats); err != nil { + if err := Validate(route.Formats); err != nil { res = append(res, err) } diff --git a/restapi/operations/picsure2/query_sync_responses.go b/restapi/server/operations/picsure2/query_sync_responses.go similarity index 98% rename from restapi/operations/picsure2/query_sync_responses.go rename to restapi/server/operations/picsure2/query_sync_responses.go index 7d6e0649..012abe54 100644 --- a/restapi/operations/picsure2/query_sync_responses.go +++ b/restapi/server/operations/picsure2/query_sync_responses.go @@ -10,7 +10,7 @@ import ( "github.com/go-openapi/runtime" - models "github.com/lca1/medco-connector/models" + "github.com/lca1/medco-connector/restapi/models" ) // QuerySyncOKCode is the HTTP code returned for type QuerySyncOK diff --git a/restapi/operations/picsure2/query_sync_urlbuilder.go b/restapi/server/operations/picsure2/query_sync_urlbuilder.go similarity index 100% rename from restapi/operations/picsure2/query_sync_urlbuilder.go rename to restapi/server/operations/picsure2/query_sync_urlbuilder.go diff --git a/restapi/operations/picsure2/query_urlbuilder.go b/restapi/server/operations/picsure2/query_urlbuilder.go similarity index 100% rename from restapi/operations/picsure2/query_urlbuilder.go rename to restapi/server/operations/picsure2/query_urlbuilder.go diff --git a/restapi/operations/picsure2/search.go b/restapi/server/operations/picsure2/search.go similarity index 96% rename from restapi/operations/picsure2/search.go rename to restapi/server/operations/picsure2/search.go index 250ac667..83b54644 100644 --- a/restapi/operations/picsure2/search.go +++ b/restapi/server/operations/picsure2/search.go @@ -9,12 +9,12 @@ import ( "net/http" "strconv" - errors "github.com/go-openapi/errors" - middleware "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" - swag "github.com/go-openapi/swag" + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" - models "github.com/lca1/medco-connector/models" + "github.com/lca1/medco-connector/restapi/models" ) // SearchHandlerFunc turns a function with the right signature into a search handler diff --git a/restapi/operations/picsure2/search_parameters.go b/restapi/server/operations/picsure2/search_parameters.go similarity index 97% rename from restapi/operations/picsure2/search_parameters.go rename to restapi/server/operations/picsure2/search_parameters.go index 5c433433..1f483dcb 100644 --- a/restapi/operations/picsure2/search_parameters.go +++ b/restapi/server/operations/picsure2/search_parameters.go @@ -57,7 +57,7 @@ func (o *SearchParams) BindRequest(r *http.Request, route *middleware.MatchedRou } } else { // validate body object - if err := body.Validate(route.Formats); err != nil { + if err := Validate(route.Formats); err != nil { res = append(res, err) } diff --git a/restapi/operations/picsure2/search_responses.go b/restapi/server/operations/picsure2/search_responses.go similarity index 100% rename from restapi/operations/picsure2/search_responses.go rename to restapi/server/operations/picsure2/search_responses.go diff --git a/restapi/operations/picsure2/search_urlbuilder.go b/restapi/server/operations/picsure2/search_urlbuilder.go similarity index 100% rename from restapi/operations/picsure2/search_urlbuilder.go rename to restapi/server/operations/picsure2/search_urlbuilder.go diff --git a/restapi/server.go b/restapi/server/server.go similarity index 99% rename from restapi/server.go rename to restapi/server/server.go index 0d008bba..6d5d51c7 100644 --- a/restapi/server.go +++ b/restapi/server/server.go @@ -1,6 +1,6 @@ // Code generated by go-swagger; DO NOT EDIT. -package restapi +package server import ( "context" @@ -22,10 +22,10 @@ import ( "github.com/go-openapi/runtime/flagext" "github.com/go-openapi/swag" - flags "github.com/jessevdk/go-flags" + "github.com/jessevdk/go-flags" "golang.org/x/net/netutil" - "github.com/lca1/medco-connector/restapi/operations" + "github.com/lca1/medco-connector/restapi/server/operations" ) const ( diff --git a/util/security.go b/util/security.go index 8f502c8e..1e41247f 100644 --- a/util/security.go +++ b/util/security.go @@ -3,7 +3,7 @@ package util import ( "encoding/json" "errors" - "github.com/lca1/medco-connector/models" + "github.com/lca1/medco-connector/restapi/models" "github.com/lestrrat-go/jwx/jwk" "github.com/lestrrat-go/jwx/jws" "github.com/lestrrat-go/jwx/jwt" From a60c8444cc39a2dbb40f25e03c88b7e495e9389c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Tue, 28 May 2019 16:36:43 +0200 Subject: [PATCH 17/41] rerun swagger gen --- cmd/medco-connector-server/main.go | 10 ++-- ...i_client_client.go => medco_cli_client.go} | 31 ++++++----- .../client/picsure2/get_info_parameters.go | 2 +- restapi/client/picsure2/get_info_responses.go | 2 +- restapi/client/picsure2/picsure2_client.go | 26 ++++----- restapi/client/picsure2/query_parameters.go | 2 +- restapi/client/picsure2/query_responses.go | 2 +- .../picsure2/query_result_parameters.go | 2 +- .../client/picsure2/query_result_responses.go | 2 +- .../picsure2/query_status_parameters.go | 2 +- .../client/picsure2/query_status_responses.go | 2 +- .../client/picsure2/query_sync_parameters.go | 2 +- .../client/picsure2/query_sync_responses.go | 2 +- restapi/client/picsure2/search_parameters.go | 2 +- restapi/client/picsure2/search_responses.go | 2 +- restapi/models/query.go | 4 +- restapi/models/query_result_element.go | 4 +- restapi/models/user.go | 4 +- restapi/server/doc.go | 2 +- .../server/operations/medco_connector_api.go | 55 ++++++++++--------- .../server/operations/picsure2/get_info.go | 10 ++-- .../picsure2/get_info_parameters.go | 2 +- restapi/server/operations/picsure2/query.go | 10 ++-- .../operations/picsure2/query_parameters.go | 2 +- .../operations/picsure2/query_responses.go | 2 +- .../operations/picsure2/query_result.go | 10 ++-- .../picsure2/query_result_parameters.go | 4 +- .../picsure2/query_result_responses.go | 2 +- .../operations/picsure2/query_status.go | 10 ++-- .../picsure2/query_status_parameters.go | 4 +- .../picsure2/query_status_responses.go | 2 +- .../server/operations/picsure2/query_sync.go | 10 ++-- .../picsure2/query_sync_parameters.go | 2 +- .../picsure2/query_sync_responses.go | 2 +- restapi/server/operations/picsure2/search.go | 10 ++-- .../operations/picsure2/search_parameters.go | 2 +- restapi/server/server.go | 2 +- 37 files changed, 124 insertions(+), 122 deletions(-) rename restapi/client/{medco_cli_client_client.go => medco_cli_client.go} (78%) diff --git a/cmd/medco-connector-server/main.go b/cmd/medco-connector-server/main.go index 8d0527f5..cc746789 100644 --- a/cmd/medco-connector-server/main.go +++ b/cmd/medco-connector-server/main.go @@ -3,12 +3,12 @@ package main import ( - server2 "github.com/lca1/medco-connector/restapi/server" "log" "os" - "github.com/go-openapi/loads" - "github.com/jessevdk/go-flags" + loads "github.com/go-openapi/loads" + flags "github.com/jessevdk/go-flags" + "github.com/lca1/medco-connector/restapi/server" "github.com/lca1/medco-connector/restapi/server/operations" ) @@ -17,13 +17,13 @@ import ( func main() { - swaggerSpec, err := loads.Embedded(server2.SwaggerJSON, server2.FlatSwaggerJSON) + swaggerSpec, err := loads.Embedded(server.SwaggerJSON, server.FlatSwaggerJSON) if err != nil { log.Fatalln(err) } api := operations.NewMedcoConnectorAPI(swaggerSpec) - server := server2.NewServer(api) + server := server.NewServer(api) defer server.Shutdown() parser := flags.NewParser(server, flags.Default) diff --git a/restapi/client/medco_cli_client_client.go b/restapi/client/medco_cli_client.go similarity index 78% rename from restapi/client/medco_cli_client_client.go rename to restapi/client/medco_cli_client.go index 0091d9e2..803c5bb1 100644 --- a/restapi/client/medco_cli_client_client.go +++ b/restapi/client/medco_cli_client.go @@ -8,12 +8,13 @@ package client import ( "github.com/go-openapi/runtime" httptransport "github.com/go-openapi/runtime/client" - picsure22 "github.com/lca1/medco-connector/restapi/client/picsure2" - "github.com/go-openapi/strfmt" + strfmt "github.com/go-openapi/strfmt" + + "github.com/lca1/medco-connector/restapi/client/picsure2" ) -// Default medco cli client HTTP client. +// Default medco cli HTTP client. var Default = NewHTTPClient(nil) const ( @@ -28,14 +29,14 @@ const ( // DefaultSchemes are the default schemes found in Meta (info) section of spec file var DefaultSchemes = []string{"http"} -// NewHTTPClient creates a new medco cli client HTTP client. -func NewHTTPClient(formats strfmt.Registry) *MedcoCliClient { +// NewHTTPClient creates a new medco cli HTTP client. +func NewHTTPClient(formats strfmt.Registry) *MedcoCli { return NewHTTPClientWithConfig(formats, nil) } -// NewHTTPClientWithConfig creates a new medco cli client HTTP client, +// NewHTTPClientWithConfig creates a new medco cli HTTP client, // using a customizable transport config. -func NewHTTPClientWithConfig(formats strfmt.Registry, cfg *TransportConfig) *MedcoCliClient { +func NewHTTPClientWithConfig(formats strfmt.Registry, cfg *TransportConfig) *MedcoCli { // ensure nullable parameters have default if cfg == nil { cfg = DefaultTransportConfig() @@ -46,17 +47,17 @@ func NewHTTPClientWithConfig(formats strfmt.Registry, cfg *TransportConfig) *Med return New(transport, formats) } -// New creates a new medco cli client client -func New(transport runtime.ClientTransport, formats strfmt.Registry) *MedcoCliClient { +// New creates a new medco cli client +func New(transport runtime.ClientTransport, formats strfmt.Registry) *MedcoCli { // ensure nullable parameters have default if formats == nil { formats = strfmt.Default } - cli := new(MedcoCliClient) + cli := new(MedcoCli) cli.Transport = transport - cli.Picsure2 = picsure22.New(transport, formats) + cli.Picsure2 = picsure2.New(transport, formats) return cli } @@ -100,15 +101,15 @@ func (cfg *TransportConfig) WithSchemes(schemes []string) *TransportConfig { return cfg } -// MedcoCliClient is a client for medco cli client -type MedcoCliClient struct { - Picsure2 *picsure22.Client +// MedcoCli is a client for medco cli +type MedcoCli struct { + Picsure2 *picsure2.Client Transport runtime.ClientTransport } // SetTransport changes the transport on the client and all its subresources -func (c *MedcoCliClient) SetTransport(transport runtime.ClientTransport) { +func (c *MedcoCli) SetTransport(transport runtime.ClientTransport) { c.Transport = transport c.Picsure2.SetTransport(transport) diff --git a/restapi/client/picsure2/get_info_parameters.go b/restapi/client/picsure2/get_info_parameters.go index ef1c9d6c..f21cd4ac 100644 --- a/restapi/client/picsure2/get_info_parameters.go +++ b/restapi/client/picsure2/get_info_parameters.go @@ -14,7 +14,7 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - "github.com/go-openapi/strfmt" + strfmt "github.com/go-openapi/strfmt" ) // NewGetInfoParams creates a new GetInfoParams object diff --git a/restapi/client/picsure2/get_info_responses.go b/restapi/client/picsure2/get_info_responses.go index 4fb24e7f..967c2ee6 100644 --- a/restapi/client/picsure2/get_info_responses.go +++ b/restapi/client/picsure2/get_info_responses.go @@ -14,7 +14,7 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/swag" - "github.com/go-openapi/strfmt" + strfmt "github.com/go-openapi/strfmt" "github.com/lca1/medco-connector/restapi/models" ) diff --git a/restapi/client/picsure2/picsure2_client.go b/restapi/client/picsure2/picsure2_client.go index a9a0187b..31c5a96a 100644 --- a/restapi/client/picsure2/picsure2_client.go +++ b/restapi/client/picsure2/picsure2_client.go @@ -8,7 +8,7 @@ package picsure2 import ( "github.com/go-openapi/runtime" - "github.com/go-openapi/strfmt" + strfmt "github.com/go-openapi/strfmt" ) // New creates a new picsure2 API client. @@ -43,8 +43,8 @@ func (a *Client) GetInfo(params *GetInfoParams, authInfo runtime.ClientAuthInfoW Params: params, Reader: &GetInfoReader{formats: a.formats}, AuthInfo: authInfo, - Context: Context, - Client: HTTPClient, + Context: params.Context, + Client: params.HTTPClient, }) if err != nil { return nil, err @@ -72,8 +72,8 @@ func (a *Client) Query(params *QueryParams, authInfo runtime.ClientAuthInfoWrite Params: params, Reader: &QueryReader{formats: a.formats}, AuthInfo: authInfo, - Context: Context, - Client: HTTPClient, + Context: params.Context, + Client: params.HTTPClient, }) if err != nil { return nil, err @@ -101,8 +101,8 @@ func (a *Client) QueryResult(params *QueryResultParams, authInfo runtime.ClientA Params: params, Reader: &QueryResultReader{formats: a.formats}, AuthInfo: authInfo, - Context: Context, - Client: HTTPClient, + Context: params.Context, + Client: params.HTTPClient, }) if err != nil { return nil, err @@ -130,8 +130,8 @@ func (a *Client) QueryStatus(params *QueryStatusParams, authInfo runtime.ClientA Params: params, Reader: &QueryStatusReader{formats: a.formats}, AuthInfo: authInfo, - Context: Context, - Client: HTTPClient, + Context: params.Context, + Client: params.HTTPClient, }) if err != nil { return nil, err @@ -159,8 +159,8 @@ func (a *Client) QuerySync(params *QuerySyncParams, authInfo runtime.ClientAuthI Params: params, Reader: &QuerySyncReader{formats: a.formats}, AuthInfo: authInfo, - Context: Context, - Client: HTTPClient, + Context: params.Context, + Client: params.HTTPClient, }) if err != nil { return nil, err @@ -188,8 +188,8 @@ func (a *Client) Search(params *SearchParams, authInfo runtime.ClientAuthInfoWri Params: params, Reader: &SearchReader{formats: a.formats}, AuthInfo: authInfo, - Context: Context, - Client: HTTPClient, + Context: params.Context, + Client: params.HTTPClient, }) if err != nil { return nil, err diff --git a/restapi/client/picsure2/query_parameters.go b/restapi/client/picsure2/query_parameters.go index 96d53b2a..bc88b8c4 100644 --- a/restapi/client/picsure2/query_parameters.go +++ b/restapi/client/picsure2/query_parameters.go @@ -14,7 +14,7 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - "github.com/go-openapi/strfmt" + strfmt "github.com/go-openapi/strfmt" ) // NewQueryParams creates a new QueryParams object diff --git a/restapi/client/picsure2/query_responses.go b/restapi/client/picsure2/query_responses.go index 4c8d0f08..e9eb09f6 100644 --- a/restapi/client/picsure2/query_responses.go +++ b/restapi/client/picsure2/query_responses.go @@ -13,7 +13,7 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/swag" - "github.com/go-openapi/strfmt" + strfmt "github.com/go-openapi/strfmt" "github.com/lca1/medco-connector/restapi/models" ) diff --git a/restapi/client/picsure2/query_result_parameters.go b/restapi/client/picsure2/query_result_parameters.go index e957f617..287bde86 100644 --- a/restapi/client/picsure2/query_result_parameters.go +++ b/restapi/client/picsure2/query_result_parameters.go @@ -14,7 +14,7 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - "github.com/go-openapi/strfmt" + strfmt "github.com/go-openapi/strfmt" ) // NewQueryResultParams creates a new QueryResultParams object diff --git a/restapi/client/picsure2/query_result_responses.go b/restapi/client/picsure2/query_result_responses.go index 005e9897..bdbb03c8 100644 --- a/restapi/client/picsure2/query_result_responses.go +++ b/restapi/client/picsure2/query_result_responses.go @@ -13,7 +13,7 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/swag" - "github.com/go-openapi/strfmt" + strfmt "github.com/go-openapi/strfmt" "github.com/lca1/medco-connector/restapi/models" ) diff --git a/restapi/client/picsure2/query_status_parameters.go b/restapi/client/picsure2/query_status_parameters.go index 2a034eb1..13fccdb8 100644 --- a/restapi/client/picsure2/query_status_parameters.go +++ b/restapi/client/picsure2/query_status_parameters.go @@ -14,7 +14,7 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - "github.com/go-openapi/strfmt" + strfmt "github.com/go-openapi/strfmt" ) // NewQueryStatusParams creates a new QueryStatusParams object diff --git a/restapi/client/picsure2/query_status_responses.go b/restapi/client/picsure2/query_status_responses.go index 0abae55f..ca067d75 100644 --- a/restapi/client/picsure2/query_status_responses.go +++ b/restapi/client/picsure2/query_status_responses.go @@ -13,7 +13,7 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/swag" - "github.com/go-openapi/strfmt" + strfmt "github.com/go-openapi/strfmt" "github.com/lca1/medco-connector/restapi/models" ) diff --git a/restapi/client/picsure2/query_sync_parameters.go b/restapi/client/picsure2/query_sync_parameters.go index 3de088e7..882f4430 100644 --- a/restapi/client/picsure2/query_sync_parameters.go +++ b/restapi/client/picsure2/query_sync_parameters.go @@ -14,7 +14,7 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - "github.com/go-openapi/strfmt" + strfmt "github.com/go-openapi/strfmt" ) // NewQuerySyncParams creates a new QuerySyncParams object diff --git a/restapi/client/picsure2/query_sync_responses.go b/restapi/client/picsure2/query_sync_responses.go index 2148e452..f1fa088b 100644 --- a/restapi/client/picsure2/query_sync_responses.go +++ b/restapi/client/picsure2/query_sync_responses.go @@ -13,7 +13,7 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/swag" - "github.com/go-openapi/strfmt" + strfmt "github.com/go-openapi/strfmt" "github.com/lca1/medco-connector/restapi/models" ) diff --git a/restapi/client/picsure2/search_parameters.go b/restapi/client/picsure2/search_parameters.go index 3fb4acfa..50e9d51a 100644 --- a/restapi/client/picsure2/search_parameters.go +++ b/restapi/client/picsure2/search_parameters.go @@ -14,7 +14,7 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" - "github.com/go-openapi/strfmt" + strfmt "github.com/go-openapi/strfmt" ) // NewSearchParams creates a new SearchParams object diff --git a/restapi/client/picsure2/search_responses.go b/restapi/client/picsure2/search_responses.go index 37e955c9..1c2bf978 100644 --- a/restapi/client/picsure2/search_responses.go +++ b/restapi/client/picsure2/search_responses.go @@ -14,7 +14,7 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/swag" - "github.com/go-openapi/strfmt" + strfmt "github.com/go-openapi/strfmt" "github.com/lca1/medco-connector/restapi/models" ) diff --git a/restapi/models/query.go b/restapi/models/query.go index ac296b73..78abff03 100644 --- a/restapi/models/query.go +++ b/restapi/models/query.go @@ -9,7 +9,7 @@ import ( "encoding/json" "strconv" - "github.com/go-openapi/strfmt" + strfmt "github.com/go-openapi/strfmt" "github.com/go-openapi/errors" "github.com/go-openapi/swag" @@ -168,7 +168,7 @@ func (m *QueryI2b2Medco) validateQueryType(formats strfmt.Registry) error { return nil } - if err := Validate(formats); err != nil { + if err := m.QueryType.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("i2b2-medco" + "." + "queryType") } diff --git a/restapi/models/query_result_element.go b/restapi/models/query_result_element.go index 48c23eaf..a547b3ca 100644 --- a/restapi/models/query_result_element.go +++ b/restapi/models/query_result_element.go @@ -6,7 +6,7 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( - "github.com/go-openapi/strfmt" + strfmt "github.com/go-openapi/strfmt" "github.com/go-openapi/errors" "github.com/go-openapi/swag" @@ -49,7 +49,7 @@ func (m *QueryResultElement) validateQueryType(formats strfmt.Registry) error { return nil } - if err := Validate(formats); err != nil { + if err := m.QueryType.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("queryType") } diff --git a/restapi/models/user.go b/restapi/models/user.go index 6fc4e028..b9fc3a41 100644 --- a/restapi/models/user.go +++ b/restapi/models/user.go @@ -8,7 +8,7 @@ package models import ( "strconv" - "github.com/go-openapi/strfmt" + strfmt "github.com/go-openapi/strfmt" "github.com/go-openapi/errors" "github.com/go-openapi/swag" @@ -108,7 +108,7 @@ func (m *UserAuthorizations) validateQueryType(formats strfmt.Registry) error { for i := 0; i < len(m.QueryType); i++ { - if err := Validate(formats); err != nil { + if err := m.QueryType[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("authorizations" + "." + "queryType" + "." + strconv.Itoa(i)) } diff --git a/restapi/server/doc.go b/restapi/server/doc.go index 8583ea05..54a66906 100644 --- a/restapi/server/doc.go +++ b/restapi/server/doc.go @@ -1,7 +1,7 @@ // Code generated by go-swagger; DO NOT EDIT. /* -Package restapi MedCo Connector +Package server MedCo Connector This is the API of the MedCo connector, that orchestrates the query at the MedCo node. It implements the PIC-SURE 2 API. diff --git a/restapi/server/operations/medco_connector_api.go b/restapi/server/operations/medco_connector_api.go index faeef465..8b45b01b 100644 --- a/restapi/server/operations/medco_connector_api.go +++ b/restapi/server/operations/medco_connector_api.go @@ -7,20 +7,21 @@ package operations import ( "fmt" - picsure22 "github.com/lca1/medco-connector/restapi/server/operations/picsure2" "net/http" "strings" - "github.com/go-openapi/errors" - "github.com/go-openapi/loads" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/runtime/security" - "github.com/go-openapi/spec" - "github.com/go-openapi/strfmt" + errors "github.com/go-openapi/errors" + loads "github.com/go-openapi/loads" + runtime "github.com/go-openapi/runtime" + middleware "github.com/go-openapi/runtime/middleware" + security "github.com/go-openapi/runtime/security" + spec "github.com/go-openapi/spec" + strfmt "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - "github.com/lca1/medco-connector/restapi/models" + "github.com/lca1/medco-connector/restapi/server/operations/picsure2" + + models "github.com/lca1/medco-connector/restapi/models" ) // NewMedcoConnectorAPI creates a new MedcoConnector instance @@ -40,22 +41,22 @@ func NewMedcoConnectorAPI(spec *loads.Document) *MedcoConnectorAPI { BearerAuthenticator: security.BearerAuth, JSONConsumer: runtime.JSONConsumer(), JSONProducer: runtime.JSONProducer(), - Picsure2GetInfoHandler: picsure22.GetInfoHandlerFunc(func(params picsure22.GetInfoParams, principal *models.User) middleware.Responder { + Picsure2GetInfoHandler: picsure2.GetInfoHandlerFunc(func(params picsure2.GetInfoParams, principal *models.User) middleware.Responder { return middleware.NotImplemented("operation Picsure2GetInfo has not yet been implemented") }), - Picsure2QueryHandler: picsure22.QueryHandlerFunc(func(params picsure22.QueryParams, principal *models.User) middleware.Responder { + Picsure2QueryHandler: picsure2.QueryHandlerFunc(func(params picsure2.QueryParams, principal *models.User) middleware.Responder { return middleware.NotImplemented("operation Picsure2Query has not yet been implemented") }), - Picsure2QueryResultHandler: picsure22.QueryResultHandlerFunc(func(params picsure22.QueryResultParams, principal *models.User) middleware.Responder { + Picsure2QueryResultHandler: picsure2.QueryResultHandlerFunc(func(params picsure2.QueryResultParams, principal *models.User) middleware.Responder { return middleware.NotImplemented("operation Picsure2QueryResult has not yet been implemented") }), - Picsure2QueryStatusHandler: picsure22.QueryStatusHandlerFunc(func(params picsure22.QueryStatusParams, principal *models.User) middleware.Responder { + Picsure2QueryStatusHandler: picsure2.QueryStatusHandlerFunc(func(params picsure2.QueryStatusParams, principal *models.User) middleware.Responder { return middleware.NotImplemented("operation Picsure2QueryStatus has not yet been implemented") }), - Picsure2QuerySyncHandler: picsure22.QuerySyncHandlerFunc(func(params picsure22.QuerySyncParams, principal *models.User) middleware.Responder { + Picsure2QuerySyncHandler: picsure2.QuerySyncHandlerFunc(func(params picsure2.QuerySyncParams, principal *models.User) middleware.Responder { return middleware.NotImplemented("operation Picsure2QuerySync has not yet been implemented") }), - Picsure2SearchHandler: picsure22.SearchHandlerFunc(func(params picsure22.SearchParams, principal *models.User) middleware.Responder { + Picsure2SearchHandler: picsure2.SearchHandlerFunc(func(params picsure2.SearchParams, principal *models.User) middleware.Responder { return middleware.NotImplemented("operation Picsure2Search has not yet been implemented") }), @@ -104,17 +105,17 @@ type MedcoConnectorAPI struct { APIAuthorizer runtime.Authorizer // Picsure2GetInfoHandler sets the operation handler for the get info operation - Picsure2GetInfoHandler picsure22.GetInfoHandler + Picsure2GetInfoHandler picsure2.GetInfoHandler // Picsure2QueryHandler sets the operation handler for the query operation - Picsure2QueryHandler picsure22.QueryHandler + Picsure2QueryHandler picsure2.QueryHandler // Picsure2QueryResultHandler sets the operation handler for the query result operation - Picsure2QueryResultHandler picsure22.QueryResultHandler + Picsure2QueryResultHandler picsure2.QueryResultHandler // Picsure2QueryStatusHandler sets the operation handler for the query status operation - Picsure2QueryStatusHandler picsure22.QueryStatusHandler + Picsure2QueryStatusHandler picsure2.QueryStatusHandler // Picsure2QuerySyncHandler sets the operation handler for the query sync operation - Picsure2QuerySyncHandler picsure22.QuerySyncHandler + Picsure2QuerySyncHandler picsure2.QuerySyncHandler // Picsure2SearchHandler sets the operation handler for the search operation - Picsure2SearchHandler picsure22.SearchHandler + Picsure2SearchHandler picsure2.SearchHandler // ServeError is called when an error is received, there is a default handler // but you can set your own with this @@ -319,32 +320,32 @@ func (o *MedcoConnectorAPI) initHandlerCache() { if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) } - o.handlers["POST"]["/picsure2/info"] = picsure22.NewGetInfo(o.context, o.Picsure2GetInfoHandler) + o.handlers["POST"]["/picsure2/info"] = picsure2.NewGetInfo(o.context, o.Picsure2GetInfoHandler) if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) } - o.handlers["POST"]["/picsure2/query"] = picsure22.NewQuery(o.context, o.Picsure2QueryHandler) + o.handlers["POST"]["/picsure2/query"] = picsure2.NewQuery(o.context, o.Picsure2QueryHandler) if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) } - o.handlers["POST"]["/picsure2/{queryId}/result"] = picsure22.NewQueryResult(o.context, o.Picsure2QueryResultHandler) + o.handlers["POST"]["/picsure2/{queryId}/result"] = picsure2.NewQueryResult(o.context, o.Picsure2QueryResultHandler) if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) } - o.handlers["POST"]["/picsure2/{queryId}/status"] = picsure22.NewQueryStatus(o.context, o.Picsure2QueryStatusHandler) + o.handlers["POST"]["/picsure2/{queryId}/status"] = picsure2.NewQueryStatus(o.context, o.Picsure2QueryStatusHandler) if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) } - o.handlers["POST"]["/picsure2/query/sync"] = picsure22.NewQuerySync(o.context, o.Picsure2QuerySyncHandler) + o.handlers["POST"]["/picsure2/query/sync"] = picsure2.NewQuerySync(o.context, o.Picsure2QuerySyncHandler) if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) } - o.handlers["POST"]["/picsure2/search"] = picsure22.NewSearch(o.context, o.Picsure2SearchHandler) + o.handlers["POST"]["/picsure2/search"] = picsure2.NewSearch(o.context, o.Picsure2SearchHandler) } diff --git a/restapi/server/operations/picsure2/get_info.go b/restapi/server/operations/picsure2/get_info.go index ffa6e91f..84fe80ad 100644 --- a/restapi/server/operations/picsure2/get_info.go +++ b/restapi/server/operations/picsure2/get_info.go @@ -9,12 +9,12 @@ import ( "net/http" "strconv" - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + errors "github.com/go-openapi/errors" + middleware "github.com/go-openapi/runtime/middleware" + strfmt "github.com/go-openapi/strfmt" + swag "github.com/go-openapi/swag" - "github.com/lca1/medco-connector/restapi/models" + models "github.com/lca1/medco-connector/restapi/models" ) // GetInfoHandlerFunc turns a function with the right signature into a get info handler diff --git a/restapi/server/operations/picsure2/get_info_parameters.go b/restapi/server/operations/picsure2/get_info_parameters.go index e041cca4..0cb82c3f 100644 --- a/restapi/server/operations/picsure2/get_info_parameters.go +++ b/restapi/server/operations/picsure2/get_info_parameters.go @@ -57,7 +57,7 @@ func (o *GetInfoParams) BindRequest(r *http.Request, route *middleware.MatchedRo } } else { // validate body object - if err := Validate(route.Formats); err != nil { + if err := body.Validate(route.Formats); err != nil { res = append(res, err) } diff --git a/restapi/server/operations/picsure2/query.go b/restapi/server/operations/picsure2/query.go index e6782b35..28de0b8c 100644 --- a/restapi/server/operations/picsure2/query.go +++ b/restapi/server/operations/picsure2/query.go @@ -8,12 +8,12 @@ package picsure2 import ( "net/http" - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + errors "github.com/go-openapi/errors" + middleware "github.com/go-openapi/runtime/middleware" + strfmt "github.com/go-openapi/strfmt" + swag "github.com/go-openapi/swag" - "github.com/lca1/medco-connector/restapi/models" + models "github.com/lca1/medco-connector/restapi/models" ) // QueryHandlerFunc turns a function with the right signature into a query handler diff --git a/restapi/server/operations/picsure2/query_parameters.go b/restapi/server/operations/picsure2/query_parameters.go index 233aa731..96cfa6cb 100644 --- a/restapi/server/operations/picsure2/query_parameters.go +++ b/restapi/server/operations/picsure2/query_parameters.go @@ -57,7 +57,7 @@ func (o *QueryParams) BindRequest(r *http.Request, route *middleware.MatchedRout } } else { // validate body object - if err := Validate(route.Formats); err != nil { + if err := body.Validate(route.Formats); err != nil { res = append(res, err) } diff --git a/restapi/server/operations/picsure2/query_responses.go b/restapi/server/operations/picsure2/query_responses.go index 38834b14..3ae547d0 100644 --- a/restapi/server/operations/picsure2/query_responses.go +++ b/restapi/server/operations/picsure2/query_responses.go @@ -10,7 +10,7 @@ import ( "github.com/go-openapi/runtime" - "github.com/lca1/medco-connector/restapi/models" + models "github.com/lca1/medco-connector/restapi/models" ) // QueryOKCode is the HTTP code returned for type QueryOK diff --git a/restapi/server/operations/picsure2/query_result.go b/restapi/server/operations/picsure2/query_result.go index ad0ece06..74c1feb8 100644 --- a/restapi/server/operations/picsure2/query_result.go +++ b/restapi/server/operations/picsure2/query_result.go @@ -8,12 +8,12 @@ package picsure2 import ( "net/http" - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + errors "github.com/go-openapi/errors" + middleware "github.com/go-openapi/runtime/middleware" + strfmt "github.com/go-openapi/strfmt" + swag "github.com/go-openapi/swag" - "github.com/lca1/medco-connector/restapi/models" + models "github.com/lca1/medco-connector/restapi/models" ) // QueryResultHandlerFunc turns a function with the right signature into a query result handler diff --git a/restapi/server/operations/picsure2/query_result_parameters.go b/restapi/server/operations/picsure2/query_result_parameters.go index 61cd91c7..973a9e56 100644 --- a/restapi/server/operations/picsure2/query_result_parameters.go +++ b/restapi/server/operations/picsure2/query_result_parameters.go @@ -13,7 +13,7 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/strfmt" + strfmt "github.com/go-openapi/strfmt" ) // NewQueryResultParams creates a new QueryResultParams object @@ -64,7 +64,7 @@ func (o *QueryResultParams) BindRequest(r *http.Request, route *middleware.Match } } else { // validate body object - if err := Validate(route.Formats); err != nil { + if err := body.Validate(route.Formats); err != nil { res = append(res, err) } diff --git a/restapi/server/operations/picsure2/query_result_responses.go b/restapi/server/operations/picsure2/query_result_responses.go index c4acaea4..f003e8ec 100644 --- a/restapi/server/operations/picsure2/query_result_responses.go +++ b/restapi/server/operations/picsure2/query_result_responses.go @@ -10,7 +10,7 @@ import ( "github.com/go-openapi/runtime" - "github.com/lca1/medco-connector/restapi/models" + models "github.com/lca1/medco-connector/restapi/models" ) // QueryResultOKCode is the HTTP code returned for type QueryResultOK diff --git a/restapi/server/operations/picsure2/query_status.go b/restapi/server/operations/picsure2/query_status.go index 3733e69c..3c76c984 100644 --- a/restapi/server/operations/picsure2/query_status.go +++ b/restapi/server/operations/picsure2/query_status.go @@ -8,12 +8,12 @@ package picsure2 import ( "net/http" - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + errors "github.com/go-openapi/errors" + middleware "github.com/go-openapi/runtime/middleware" + strfmt "github.com/go-openapi/strfmt" + swag "github.com/go-openapi/swag" - "github.com/lca1/medco-connector/restapi/models" + models "github.com/lca1/medco-connector/restapi/models" ) // QueryStatusHandlerFunc turns a function with the right signature into a query status handler diff --git a/restapi/server/operations/picsure2/query_status_parameters.go b/restapi/server/operations/picsure2/query_status_parameters.go index 9a9f07af..8e7c9cc2 100644 --- a/restapi/server/operations/picsure2/query_status_parameters.go +++ b/restapi/server/operations/picsure2/query_status_parameters.go @@ -13,7 +13,7 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/strfmt" + strfmt "github.com/go-openapi/strfmt" ) // NewQueryStatusParams creates a new QueryStatusParams object @@ -64,7 +64,7 @@ func (o *QueryStatusParams) BindRequest(r *http.Request, route *middleware.Match } } else { // validate body object - if err := Validate(route.Formats); err != nil { + if err := body.Validate(route.Formats); err != nil { res = append(res, err) } diff --git a/restapi/server/operations/picsure2/query_status_responses.go b/restapi/server/operations/picsure2/query_status_responses.go index 99e6ed5c..34c437b2 100644 --- a/restapi/server/operations/picsure2/query_status_responses.go +++ b/restapi/server/operations/picsure2/query_status_responses.go @@ -10,7 +10,7 @@ import ( "github.com/go-openapi/runtime" - "github.com/lca1/medco-connector/restapi/models" + models "github.com/lca1/medco-connector/restapi/models" ) // QueryStatusOKCode is the HTTP code returned for type QueryStatusOK diff --git a/restapi/server/operations/picsure2/query_sync.go b/restapi/server/operations/picsure2/query_sync.go index 905e3a0e..fde47883 100644 --- a/restapi/server/operations/picsure2/query_sync.go +++ b/restapi/server/operations/picsure2/query_sync.go @@ -8,12 +8,12 @@ package picsure2 import ( "net/http" - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + errors "github.com/go-openapi/errors" + middleware "github.com/go-openapi/runtime/middleware" + strfmt "github.com/go-openapi/strfmt" + swag "github.com/go-openapi/swag" - "github.com/lca1/medco-connector/restapi/models" + models "github.com/lca1/medco-connector/restapi/models" ) // QuerySyncHandlerFunc turns a function with the right signature into a query sync handler diff --git a/restapi/server/operations/picsure2/query_sync_parameters.go b/restapi/server/operations/picsure2/query_sync_parameters.go index e335f5ca..737d750f 100644 --- a/restapi/server/operations/picsure2/query_sync_parameters.go +++ b/restapi/server/operations/picsure2/query_sync_parameters.go @@ -57,7 +57,7 @@ func (o *QuerySyncParams) BindRequest(r *http.Request, route *middleware.Matched } } else { // validate body object - if err := Validate(route.Formats); err != nil { + if err := body.Validate(route.Formats); err != nil { res = append(res, err) } diff --git a/restapi/server/operations/picsure2/query_sync_responses.go b/restapi/server/operations/picsure2/query_sync_responses.go index 012abe54..65b43945 100644 --- a/restapi/server/operations/picsure2/query_sync_responses.go +++ b/restapi/server/operations/picsure2/query_sync_responses.go @@ -10,7 +10,7 @@ import ( "github.com/go-openapi/runtime" - "github.com/lca1/medco-connector/restapi/models" + models "github.com/lca1/medco-connector/restapi/models" ) // QuerySyncOKCode is the HTTP code returned for type QuerySyncOK diff --git a/restapi/server/operations/picsure2/search.go b/restapi/server/operations/picsure2/search.go index 83b54644..657af362 100644 --- a/restapi/server/operations/picsure2/search.go +++ b/restapi/server/operations/picsure2/search.go @@ -9,12 +9,12 @@ import ( "net/http" "strconv" - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + errors "github.com/go-openapi/errors" + middleware "github.com/go-openapi/runtime/middleware" + strfmt "github.com/go-openapi/strfmt" + swag "github.com/go-openapi/swag" - "github.com/lca1/medco-connector/restapi/models" + models "github.com/lca1/medco-connector/restapi/models" ) // SearchHandlerFunc turns a function with the right signature into a search handler diff --git a/restapi/server/operations/picsure2/search_parameters.go b/restapi/server/operations/picsure2/search_parameters.go index 1f483dcb..5c433433 100644 --- a/restapi/server/operations/picsure2/search_parameters.go +++ b/restapi/server/operations/picsure2/search_parameters.go @@ -57,7 +57,7 @@ func (o *SearchParams) BindRequest(r *http.Request, route *middleware.MatchedRou } } else { // validate body object - if err := Validate(route.Formats); err != nil { + if err := body.Validate(route.Formats); err != nil { res = append(res, err) } diff --git a/restapi/server/server.go b/restapi/server/server.go index 6d5d51c7..7116c481 100644 --- a/restapi/server/server.go +++ b/restapi/server/server.go @@ -22,7 +22,7 @@ import ( "github.com/go-openapi/runtime/flagext" "github.com/go-openapi/swag" - "github.com/jessevdk/go-flags" + flags "github.com/jessevdk/go-flags" "golang.org/x/net/netutil" "github.com/lca1/medco-connector/restapi/server/operations" From e36f46d652262976806e190a2353ac78d9b0b8e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Tue, 28 May 2019 16:37:27 +0200 Subject: [PATCH 18/41] fix swagger configuration --- restapi/server/configure_medco_connector.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/restapi/server/configure_medco_connector.go b/restapi/server/configure_medco_connector.go index 8cd27068..e50bae30 100644 --- a/restapi/server/configure_medco_connector.go +++ b/restapi/server/configure_medco_connector.go @@ -11,7 +11,7 @@ import ( "github.com/lca1/medco-connector/medco" "github.com/lca1/medco-connector/restapi/models" "github.com/lca1/medco-connector/restapi/server/operations" - picsure22 "github.com/lca1/medco-connector/restapi/server/operations/picsure2" + "github.com/lca1/medco-connector/restapi/server/operations/picsure2" "github.com/sirupsen/logrus" "net/http" ) @@ -38,28 +38,28 @@ func configureAPI(api *operations.MedcoConnectorAPI) http.Handler { } // /medco/picsure2/info - api.Picsure2GetInfoHandler = picsure22.GetInfoHandlerFunc(medco.GetInfoHandlerFunc) + api.Picsure2GetInfoHandler = picsure2.GetInfoHandlerFunc(medco.GetInfoHandlerFunc) // /medco/picsure2/query - api.Picsure2QueryHandler = picsure22.QueryHandlerFunc(func(params picsure22.QueryParams, principal *models.User) middleware.Responder { + api.Picsure2QueryHandler = picsure2.QueryHandlerFunc(func(params picsure2.QueryParams, principal *models.User) middleware.Responder { return middleware.NotImplemented("operation picsure2.Query has not yet been implemented") }) // /medco/picsure2/query/{id}/result - api.Picsure2QueryResultHandler = picsure22.QueryResultHandlerFunc(func(params picsure22.QueryResultParams, principal *models.User) middleware.Responder { + api.Picsure2QueryResultHandler = picsure2.QueryResultHandlerFunc(func(params picsure2.QueryResultParams, principal *models.User) middleware.Responder { return middleware.NotImplemented("operation picsure2.QueryResult has not yet been implemented") }) // /medco/picsure2/query/{id}/status - api.Picsure2QueryStatusHandler = picsure22.QueryStatusHandlerFunc(func(params picsure22.QueryStatusParams, principal *models.User) middleware.Responder { + api.Picsure2QueryStatusHandler = picsure2.QueryStatusHandlerFunc(func(params picsure2.QueryStatusParams, principal *models.User) middleware.Responder { return middleware.NotImplemented("operation picsure2.QueryStatus has not yet been implemented") }) // /medco/picsure2/query/sync - api.Picsure2QuerySyncHandler = picsure22.QuerySyncHandlerFunc(medco.QuerySyncHandlerFunc) + api.Picsure2QuerySyncHandler = picsure2.QuerySyncHandlerFunc(medco.QuerySyncHandlerFunc) // /medco/picsure2/search - api.Picsure2SearchHandler = picsure22.SearchHandlerFunc(medco.SearchHandlerFunc) + api.Picsure2SearchHandler = picsure2.SearchHandlerFunc(medco.SearchHandlerFunc) api.ServerShutdown = func() {} From ed72ee1d56ebaafb100cb80be160b20f5e15a7d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Tue, 28 May 2019 16:40:31 +0200 Subject: [PATCH 19/41] swagger generation update --- Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 17aa0153..298fdb58 100644 --- a/Makefile +++ b/Makefile @@ -4,16 +4,20 @@ EXCLUDE_LINT = "_test.go" swagger-gen: swagger validate ./swagger.yml swagger generate server \ + --server-package=restapi/server \ + --model-package=restapi/models \ --principal=models.User \ --target=./ \ --spec=./swagger.yml \ --name=medco-connector swagger generate client \ + --client-package=restapi/client \ + --existing-models=github.com/lca1/medco-connector/restapi/models \ + --skip-models \ --principal=models.User \ --target=./ \ --spec=./swagger.yml \ - --name=medco-cli-client \ - --existing-models=github.com/lca1/medco-connector/models \ + --name=medco-cli \ --default-scheme=https test_lint: From e4ae1754658b890abf63d42d36580fef634cb358 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Tue, 11 Jun 2019 18:35:23 +0200 Subject: [PATCH 20/41] revert boolean fix previously removed --- i2b2/ontology_query.go | 15 ++++++---- medco/query_logic.go | 6 ++-- restapi/models/query.go | 32 +++++++++++++++++++-- restapi/models/search_result_element.go | 37 +++++++++++++++++++++++-- restapi/server/embedded_spec.go | 24 ++++++++++++++++ swagger.yml => swagger/swagger.yml | 4 +++ 6 files changed, 105 insertions(+), 13 deletions(-) rename swagger.yml => swagger/swagger.yml (98%) diff --git a/i2b2/ontology_query.go b/i2b2/ontology_query.go index 9bebfc88..ce345736 100644 --- a/i2b2/ontology_query.go +++ b/i2b2/ontology_query.go @@ -62,12 +62,15 @@ func parseI2b2Concept(concept Concept) (result *models.SearchResultElement) { // - CONCEPT_PARENT_NODE // - CONCEPT_INTERNAL_NODE // - CONCEPT_LEAF + true := true + false := false + result = &models.SearchResultElement{ Name: concept.Name, DisplayName: concept.Name, Code: concept.Basecode, MedcoEncryption: &models.SearchResultElementMedcoEncryption{ - Encrypted: false, + Encrypted: &false, ID: -1, ChildrenIds: []int64{}, }, @@ -80,19 +83,19 @@ func parseI2b2Concept(concept Concept) (result *models.SearchResultElement) { switch concept.Visualattributes[0] { // i2b2 leaf case 'L': - result.Leaf = true + result.Leaf = &true result.Type = models.SearchResultElementTypeConcept // i2b2 container case 'C': - result.Leaf = false + result.Leaf = &false result.Type = models.SearchResultElementTypeContainer // i2b2 folder (& default) default: fallthrough case 'F': - result.Leaf = false + result.Leaf = &false result.Type = models.SearchResultElementTypeConcept } @@ -101,12 +104,12 @@ func parseI2b2Concept(concept Concept) (result *models.SearchResultElement) { // if clinical concept from data loader v0 (from concept code) if splitCode[0] == "ENC_ID" { - result.MedcoEncryption.Encrypted = true + result.MedcoEncryption.Encrypted = &true result.MedcoEncryption.ID, _ = strconv.ParseInt(splitCode[1], 10, 64) // if concept from loader v1 encrypted (from metadata xml) } else if concept.Metadataxml.ValueMetadata.EncryptedType != "" { - result.MedcoEncryption.Encrypted = true + result.MedcoEncryption.Encrypted = &true result.MedcoEncryption.ID, _ = strconv.ParseInt(concept.Metadataxml.ValueMetadata.NodeEncryptID, 10, 64) for _, childEncryptIDString := range strings.Split(concept.Metadataxml.ValueMetadata.ChildrenEncryptIDs, ",") { diff --git a/medco/query_logic.go b/medco/query_logic.go index 96352ab1..b0a1fd45 100644 --- a/medco/query_logic.go +++ b/medco/query_logic.go @@ -147,7 +147,7 @@ func (q *I2b2MedCoQuery) maskPatientIDs(patientIDs []string, patientDummyFlags [ func (q *I2b2MedCoQuery) getEncQueryTerms() (encQueryTerms []string) { for _, panel := range q.query.Panels { for _, item := range panel.Items { - if item.Encrypted { + if *item.Encrypted { encQueryTerms = append(encQueryTerms, item.QueryTerm) } } @@ -157,12 +157,12 @@ func (q *I2b2MedCoQuery) getEncQueryTerms() (encQueryTerms []string) { func (q *I2b2MedCoQuery) getI2b2PsmQueryTerms(taggedQueryTerms map[string]string) (panelsItemKeys [][]string, panelsIsNot []bool, err error) { for panelIdx, panel := range q.query.Panels { - panelsIsNot = append(panelsIsNot, panel.Not) + panelsIsNot = append(panelsIsNot, *panel.Not) panelsItemKeys = append(panelsItemKeys, []string{}) for _, item := range panel.Items { var itemKey string - if item.Encrypted { + if *item.Encrypted { if tag, ok := taggedQueryTerms[item.QueryTerm]; ok { itemKey = `\\SENSITIVE_TAGGED\medco\tagged\` + tag + `\` diff --git a/restapi/models/query.go b/restapi/models/query.go index 78abff03..89c3c8d5 100644 --- a/restapi/models/query.go +++ b/restapi/models/query.go @@ -235,7 +235,8 @@ type QueryI2b2MedcoPanelsItems0 struct { Items []*QueryI2b2MedcoPanelsItems0ItemsItems0 `json:"items"` // exclude the i2b2 panel - Not bool `json:"not,omitempty"` + // Required: true + Not *bool `json:"not"` } // Validate validates this query i2b2 medco panels items0 @@ -246,6 +247,10 @@ func (m *QueryI2b2MedcoPanelsItems0) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateNot(formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -277,6 +282,15 @@ func (m *QueryI2b2MedcoPanelsItems0) validateItems(formats strfmt.Registry) erro return nil } +func (m *QueryI2b2MedcoPanelsItems0) validateNot(formats strfmt.Registry) error { + + if err := validate.Required("not", "body", m.Not); err != nil { + return err + } + + return nil +} + // MarshalBinary interface implementation func (m *QueryI2b2MedcoPanelsItems0) MarshalBinary() ([]byte, error) { if m == nil { @@ -300,7 +314,8 @@ func (m *QueryI2b2MedcoPanelsItems0) UnmarshalBinary(b []byte) error { type QueryI2b2MedcoPanelsItems0ItemsItems0 struct { // encrypted - Encrypted bool `json:"encrypted,omitempty"` + // Required: true + Encrypted *bool `json:"encrypted"` // operator // Enum: [exists equals] @@ -317,6 +332,10 @@ type QueryI2b2MedcoPanelsItems0ItemsItems0 struct { func (m *QueryI2b2MedcoPanelsItems0ItemsItems0) Validate(formats strfmt.Registry) error { var res []error + if err := m.validateEncrypted(formats); err != nil { + res = append(res, err) + } + if err := m.validateOperator(formats); err != nil { res = append(res, err) } @@ -327,6 +346,15 @@ func (m *QueryI2b2MedcoPanelsItems0ItemsItems0) Validate(formats strfmt.Registry return nil } +func (m *QueryI2b2MedcoPanelsItems0ItemsItems0) validateEncrypted(formats strfmt.Registry) error { + + if err := validate.Required("encrypted", "body", m.Encrypted); err != nil { + return err + } + + return nil +} + var queryI2b2MedcoPanelsItems0ItemsItems0TypeOperatorPropEnum []interface{} func init() { diff --git a/restapi/models/search_result_element.go b/restapi/models/search_result_element.go index 6a1a3dd8..6d2b4d63 100644 --- a/restapi/models/search_result_element.go +++ b/restapi/models/search_result_element.go @@ -26,7 +26,8 @@ type SearchResultElement struct { DisplayName string `json:"displayName,omitempty"` // leaf - Leaf bool `json:"leaf,omitempty"` + // Required: true + Leaf *bool `json:"leaf"` // medco encryption MedcoEncryption *SearchResultElementMedcoEncryption `json:"medcoEncryption,omitempty"` @@ -49,6 +50,10 @@ type SearchResultElement struct { func (m *SearchResultElement) Validate(formats strfmt.Registry) error { var res []error + if err := m.validateLeaf(formats); err != nil { + res = append(res, err) + } + if err := m.validateMedcoEncryption(formats); err != nil { res = append(res, err) } @@ -63,6 +68,15 @@ func (m *SearchResultElement) Validate(formats strfmt.Registry) error { return nil } +func (m *SearchResultElement) validateLeaf(formats strfmt.Registry) error { + + if err := validate.Required("leaf", "body", m.Leaf); err != nil { + return err + } + + return nil +} + func (m *SearchResultElement) validateMedcoEncryption(formats strfmt.Registry) error { if swag.IsZero(m.MedcoEncryption) { // not required @@ -162,7 +176,8 @@ type SearchResultElementMedcoEncryption struct { ChildrenIds []int64 `json:"childrenIds"` // encrypted - Encrypted bool `json:"encrypted,omitempty"` + // Required: true + Encrypted *bool `json:"encrypted"` // id ID int64 `json:"id,omitempty"` @@ -170,6 +185,24 @@ type SearchResultElementMedcoEncryption struct { // Validate validates this search result element medco encryption func (m *SearchResultElementMedcoEncryption) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateEncrypted(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SearchResultElementMedcoEncryption) validateEncrypted(formats strfmt.Registry) error { + + if err := validate.Required("medcoEncryption"+"."+"encrypted", "body", m.Encrypted); err != nil { + return err + } + return nil } diff --git a/restapi/server/embedded_spec.go b/restapi/server/embedded_spec.go index 1b3da75a..f3c43693 100644 --- a/restapi/server/embedded_spec.go +++ b/restapi/server/embedded_spec.go @@ -329,12 +329,18 @@ func init() { "type": "array", "items": { "type": "object", + "required": [ + "not" + ], "properties": { "items": { "description": "i2b2 items (linked by an OR)", "type": "array", "items": { "type": "object", + "required": [ + "encrypted" + ], "properties": { "encrypted": { "type": "boolean" @@ -479,6 +485,9 @@ func init() { }, "searchResultElement": { "type": "object", + "required": [ + "leaf" + ], "properties": { "code": { "type": "string" @@ -491,6 +500,9 @@ func init() { }, "medcoEncryption": { "type": "object", + "required": [ + "encrypted" + ], "properties": { "childrenIds": { "type": "array", @@ -1076,12 +1088,18 @@ func init() { "type": "array", "items": { "type": "object", + "required": [ + "not" + ], "properties": { "items": { "description": "i2b2 items (linked by an OR)", "type": "array", "items": { "type": "object", + "required": [ + "encrypted" + ], "properties": { "encrypted": { "type": "boolean" @@ -1226,6 +1244,9 @@ func init() { }, "searchResultElement": { "type": "object", + "required": [ + "leaf" + ], "properties": { "code": { "type": "string" @@ -1238,6 +1259,9 @@ func init() { }, "medcoEncryption": { "type": "object", + "required": [ + "encrypted" + ], "properties": { "childrenIds": { "type": "array", diff --git a/swagger.yml b/swagger/swagger.yml similarity index 98% rename from swagger.yml rename to swagger/swagger.yml index 496ebbf8..9001de5f 100644 --- a/swagger.yml +++ b/swagger/swagger.yml @@ -283,6 +283,7 @@ definitions: searchResultElement: type: "object" + required: [leaf] properties: path: type: "string" @@ -305,6 +306,7 @@ definitions: type: "boolean" medcoEncryption: type: "object" + required: [encrypted] properties: encrypted: type: "boolean" @@ -341,6 +343,7 @@ definitions: description: "i2b2 panels (linked by an AND)" items: type: "object" + required: [not] properties: not: type: "boolean" @@ -350,6 +353,7 @@ definitions: description: "i2b2 items (linked by an OR)" items: type: "object" + required: [encrypted] properties: queryTerm: type: "string" From 22ca5d7383492d8ef78d858ef060fc9e804bc4af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Thu, 13 Jun 2019 16:42:41 +0200 Subject: [PATCH 21/41] move swagger file in dedicated folder; fix links of some paths --- restapi/server/embedded_spec.go | 136 +++++++++--------- .../server/operations/medco_connector_api.go | 4 +- .../operations/picsure2/query_result.go | 2 +- .../picsure2/query_result_urlbuilder.go | 2 +- .../operations/picsure2/query_status.go | 2 +- .../picsure2/query_status_urlbuilder.go | 2 +- ...swagger.yml => medco-connector-server.yml} | 4 +- 7 files changed, 76 insertions(+), 76 deletions(-) rename swagger/{swagger.yml => medco-connector-server.yml} (99%) diff --git a/restapi/server/embedded_spec.go b/restapi/server/embedded_spec.go index f3c43693..51f3c504 100644 --- a/restapi/server/embedded_spec.go +++ b/restapi/server/embedded_spec.go @@ -165,7 +165,7 @@ func init() { } } }, - "/picsure2/search": { + "/picsure2/query/{queryId}/result": { "post": { "consumes": [ "application/json" @@ -176,25 +176,26 @@ func init() { "tags": [ "picsure2" ], - "summary": "Search through the ontology.", - "operationId": "search", + "summary": "Get result of query.", + "operationId": "queryResult", "parameters": [ { - "description": "Search request.", + "type": "string", + "description": "Query ID", + "name": "queryId", + "in": "path", + "required": true + }, + { + "description": "Credentials to be used.", "name": "body", "in": "body", "required": true, "schema": { "type": "object", "properties": { - "query": { - "$ref": "#/definitions/searchQuery" - }, "resourceCredentials": { "$ref": "#/definitions/resourceCredentials" - }, - "resourceUUID": { - "type": "string" } } } @@ -202,7 +203,7 @@ func init() { ], "responses": { "200": { - "$ref": "#/responses/searchResult" + "$ref": "#/responses/queryResult" }, "default": { "$ref": "#/responses/error" @@ -210,7 +211,7 @@ func init() { } } }, - "/picsure2/{queryId}/result": { + "/picsure2/query/{queryId}/status": { "post": { "consumes": [ "application/json" @@ -221,8 +222,8 @@ func init() { "tags": [ "picsure2" ], - "summary": "Get result of query.", - "operationId": "queryResult", + "summary": "Get status of query.", + "operationId": "queryStatus", "parameters": [ { "type": "string", @@ -248,7 +249,7 @@ func init() { ], "responses": { "200": { - "$ref": "#/responses/queryResult" + "$ref": "#/responses/queryStatus" }, "default": { "$ref": "#/responses/error" @@ -256,7 +257,7 @@ func init() { } } }, - "/picsure2/{queryId}/status": { + "/picsure2/search": { "post": { "consumes": [ "application/json" @@ -267,26 +268,25 @@ func init() { "tags": [ "picsure2" ], - "summary": "Get status of query.", - "operationId": "queryStatus", + "summary": "Search through the ontology.", + "operationId": "search", "parameters": [ { - "type": "string", - "description": "Query ID", - "name": "queryId", - "in": "path", - "required": true - }, - { - "description": "Credentials to be used.", + "description": "Search request.", "name": "body", "in": "body", "required": true, "schema": { "type": "object", "properties": { + "query": { + "$ref": "#/definitions/searchQuery" + }, "resourceCredentials": { "$ref": "#/definitions/resourceCredentials" + }, + "resourceUUID": { + "type": "string" } } } @@ -294,7 +294,7 @@ func init() { ], "responses": { "200": { - "$ref": "#/responses/queryStatus" + "$ref": "#/responses/searchResult" }, "default": { "$ref": "#/responses/error" @@ -880,7 +880,7 @@ func init() { } } }, - "/picsure2/search": { + "/picsure2/query/{queryId}/result": { "post": { "consumes": [ "application/json" @@ -891,25 +891,26 @@ func init() { "tags": [ "picsure2" ], - "summary": "Search through the ontology.", - "operationId": "search", + "summary": "Get result of query.", + "operationId": "queryResult", "parameters": [ { - "description": "Search request.", + "type": "string", + "description": "Query ID", + "name": "queryId", + "in": "path", + "required": true + }, + { + "description": "Credentials to be used.", "name": "body", "in": "body", "required": true, "schema": { "type": "object", "properties": { - "query": { - "$ref": "#/definitions/searchQuery" - }, "resourceCredentials": { "$ref": "#/definitions/resourceCredentials" - }, - "resourceUUID": { - "type": "string" } } } @@ -917,20 +918,9 @@ func init() { ], "responses": { "200": { - "description": "Search results.", + "description": "Query result.", "schema": { - "type": "object", - "properties": { - "results": { - "type": "array", - "items": { - "$ref": "#/definitions/searchResultElement" - } - }, - "searchQuery": { - "type": "string" - } - } + "$ref": "#/definitions/queryResultElement" } }, "default": { @@ -947,7 +937,7 @@ func init() { } } }, - "/picsure2/{queryId}/result": { + "/picsure2/query/{queryId}/status": { "post": { "consumes": [ "application/json" @@ -958,8 +948,8 @@ func init() { "tags": [ "picsure2" ], - "summary": "Get result of query.", - "operationId": "queryResult", + "summary": "Get status of query.", + "operationId": "queryStatus", "parameters": [ { "type": "string", @@ -985,9 +975,9 @@ func init() { ], "responses": { "200": { - "description": "Query result.", + "description": "Query status.", "schema": { - "$ref": "#/definitions/queryResultElement" + "$ref": "#/definitions/queryStatus" } }, "default": { @@ -1004,7 +994,7 @@ func init() { } } }, - "/picsure2/{queryId}/status": { + "/picsure2/search": { "post": { "consumes": [ "application/json" @@ -1015,26 +1005,25 @@ func init() { "tags": [ "picsure2" ], - "summary": "Get status of query.", - "operationId": "queryStatus", + "summary": "Search through the ontology.", + "operationId": "search", "parameters": [ { - "type": "string", - "description": "Query ID", - "name": "queryId", - "in": "path", - "required": true - }, - { - "description": "Credentials to be used.", + "description": "Search request.", "name": "body", "in": "body", "required": true, "schema": { "type": "object", "properties": { + "query": { + "$ref": "#/definitions/searchQuery" + }, "resourceCredentials": { "$ref": "#/definitions/resourceCredentials" + }, + "resourceUUID": { + "type": "string" } } } @@ -1042,9 +1031,20 @@ func init() { ], "responses": { "200": { - "description": "Query status.", + "description": "Search results.", "schema": { - "$ref": "#/definitions/queryStatus" + "type": "object", + "properties": { + "results": { + "type": "array", + "items": { + "$ref": "#/definitions/searchResultElement" + } + }, + "searchQuery": { + "type": "string" + } + } } }, "default": { diff --git a/restapi/server/operations/medco_connector_api.go b/restapi/server/operations/medco_connector_api.go index 8b45b01b..448efd57 100644 --- a/restapi/server/operations/medco_connector_api.go +++ b/restapi/server/operations/medco_connector_api.go @@ -330,12 +330,12 @@ func (o *MedcoConnectorAPI) initHandlerCache() { if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) } - o.handlers["POST"]["/picsure2/{queryId}/result"] = picsure2.NewQueryResult(o.context, o.Picsure2QueryResultHandler) + o.handlers["POST"]["/picsure2/query/{queryId}/result"] = picsure2.NewQueryResult(o.context, o.Picsure2QueryResultHandler) if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) } - o.handlers["POST"]["/picsure2/{queryId}/status"] = picsure2.NewQueryStatus(o.context, o.Picsure2QueryStatusHandler) + o.handlers["POST"]["/picsure2/query/{queryId}/status"] = picsure2.NewQueryStatus(o.context, o.Picsure2QueryStatusHandler) if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) diff --git a/restapi/server/operations/picsure2/query_result.go b/restapi/server/operations/picsure2/query_result.go index 74c1feb8..a409a43f 100644 --- a/restapi/server/operations/picsure2/query_result.go +++ b/restapi/server/operations/picsure2/query_result.go @@ -34,7 +34,7 @@ func NewQueryResult(ctx *middleware.Context, handler QueryResultHandler) *QueryR return &QueryResult{Context: ctx, Handler: handler} } -/*QueryResult swagger:route POST /picsure2/{queryId}/result picsure2 queryResult +/*QueryResult swagger:route POST /picsure2/query/{queryId}/result picsure2 queryResult Get result of query. diff --git a/restapi/server/operations/picsure2/query_result_urlbuilder.go b/restapi/server/operations/picsure2/query_result_urlbuilder.go index bb94e602..90d9fa32 100644 --- a/restapi/server/operations/picsure2/query_result_urlbuilder.go +++ b/restapi/server/operations/picsure2/query_result_urlbuilder.go @@ -40,7 +40,7 @@ func (o *QueryResultURL) SetBasePath(bp string) { func (o *QueryResultURL) Build() (*url.URL, error) { var _result url.URL - var _path = "/picsure2/{queryId}/result" + var _path = "/picsure2/query/{queryId}/result" queryID := o.QueryID if queryID != "" { diff --git a/restapi/server/operations/picsure2/query_status.go b/restapi/server/operations/picsure2/query_status.go index 3c76c984..95a284ed 100644 --- a/restapi/server/operations/picsure2/query_status.go +++ b/restapi/server/operations/picsure2/query_status.go @@ -34,7 +34,7 @@ func NewQueryStatus(ctx *middleware.Context, handler QueryStatusHandler) *QueryS return &QueryStatus{Context: ctx, Handler: handler} } -/*QueryStatus swagger:route POST /picsure2/{queryId}/status picsure2 queryStatus +/*QueryStatus swagger:route POST /picsure2/query/{queryId}/status picsure2 queryStatus Get status of query. diff --git a/restapi/server/operations/picsure2/query_status_urlbuilder.go b/restapi/server/operations/picsure2/query_status_urlbuilder.go index a5b303dc..c235a9a0 100644 --- a/restapi/server/operations/picsure2/query_status_urlbuilder.go +++ b/restapi/server/operations/picsure2/query_status_urlbuilder.go @@ -40,7 +40,7 @@ func (o *QueryStatusURL) SetBasePath(bp string) { func (o *QueryStatusURL) Build() (*url.URL, error) { var _result url.URL - var _path = "/picsure2/{queryId}/status" + var _path = "/picsure2/query/{queryId}/status" queryID := o.QueryID if queryID != "" { diff --git a/swagger/swagger.yml b/swagger/medco-connector-server.yml similarity index 99% rename from swagger/swagger.yml rename to swagger/medco-connector-server.yml index 9001de5f..d3e5f0aa 100644 --- a/swagger/swagger.yml +++ b/swagger/medco-connector-server.yml @@ -137,7 +137,7 @@ paths: default: $ref: "#/responses/error" - /picsure2/{queryId}/status: + /picsure2/query/{queryId}/status: post: tags: - "picsure2" @@ -168,7 +168,7 @@ paths: default: $ref: "#/responses/error" - /picsure2/{queryId}/result: + /picsure2/query/{queryId}/result: post: tags: - "picsure2" From b0328d8e3e152cd059bbd9ad3dcecdd02281dd24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Thu, 13 Jun 2019 16:45:49 +0200 Subject: [PATCH 22/41] add client implementation --- Makefile | 7 +- cmd/medco-cli-client/main.go | 95 ++++++++ deployment/client.Dockerfile | 30 +++ medco/client/client.go | 225 ++++++++++++++++++ medco/client/query.go | 216 +++++++++++++++++ medco/client/query_result.go | 46 ++++ restapi/client/medco_cli_client.go | 2 +- restapi/client/picsure2/get_info_responses.go | 4 +- .../picsure2/get_resources_parameters.go | 113 +++++++++ .../picsure2/get_resources_responses.go | 185 ++++++++++++++ restapi/client/picsure2/picsure2_client.go | 41 +++- restapi/client/picsure2/query_responses.go | 4 +- .../client/picsure2/query_result_responses.go | 4 +- .../client/picsure2/query_status_responses.go | 4 +- .../client/picsure2/query_sync_responses.go | 4 +- restapi/client/picsure2/search_responses.go | 4 +- swagger/medco-cli-client.yml | 107 +++++++++ util/client/configuration.go | 39 +++ util/client/security.go | 52 ++++ 19 files changed, 1160 insertions(+), 22 deletions(-) create mode 100644 cmd/medco-cli-client/main.go create mode 100644 deployment/client.Dockerfile create mode 100644 medco/client/client.go create mode 100644 medco/client/query.go create mode 100644 medco/client/query_result.go create mode 100644 restapi/client/picsure2/get_resources_parameters.go create mode 100644 restapi/client/picsure2/get_resources_responses.go create mode 100644 swagger/medco-cli-client.yml create mode 100644 util/client/configuration.go create mode 100644 util/client/security.go diff --git a/Makefile b/Makefile index 298fdb58..74adff11 100644 --- a/Makefile +++ b/Makefile @@ -2,21 +2,22 @@ EXCLUDE_LINT = "_test.go" # generate/update go server based on swagger specifications swagger-gen: - swagger validate ./swagger.yml + swagger validate ./swagger/medco-connector-server.yml swagger generate server \ --server-package=restapi/server \ --model-package=restapi/models \ --principal=models.User \ --target=./ \ - --spec=./swagger.yml \ + --spec=./swagger/medco-connector-server.yml \ --name=medco-connector + swagger validate ./swagger/medco-cli-client.yml swagger generate client \ --client-package=restapi/client \ --existing-models=github.com/lca1/medco-connector/restapi/models \ --skip-models \ --principal=models.User \ --target=./ \ - --spec=./swagger.yml \ + --spec=./swagger/medco-cli-client.yml \ --name=medco-cli \ --default-scheme=https diff --git a/cmd/medco-cli-client/main.go b/cmd/medco-cli-client/main.go new file mode 100644 index 00000000..a5c5e5ab --- /dev/null +++ b/cmd/medco-cli-client/main.go @@ -0,0 +1,95 @@ +package main + +import ( + medcoclient "github.com/lca1/medco-connector/medco/client" + "github.com/sirupsen/logrus" + "github.com/urfave/cli" + "os" + "strings" +) + +func main() { + + cliApp := cli.NewApp() + cliApp.Name = "medco-cli-client" + cliApp.Usage = "Command-line query tool for MedCo." + cliApp.Version = "0.2.1" // todo: dynamically get version from build process + + // from env / config: whatever is in the config of GB : debug, + // cli: whatever is user input + + // --- global app flags + cliApp.Flags = []cli.Flag{ + cli.StringFlag{ + Name: "user, u", + Usage: "OIDC user login", + }, + cli.StringFlag{ + Name: "password, p", + Usage: "OIDC password login", + }, + cli.StringFlag{ + Name: "token, t", + Usage: "OIDC token", + }, + } + + // --- search command flags + //searchCommandFlags := []cli.Flag{ + // cli.StringFlag{ + // Name: "path", + // Usage: "File containing the query definition", + // + // }, + //} + + //--- query command flags + queryCommandFlags := []cli.Flag{ + cli.StringFlag{ + Name: "resultFile, r", + Usage: "Output file for the result CSV. Printed to stdout if omitted.", + Value: "", + }, + } + + // --- app commands + cliApp.Commands = []cli.Command{ + //{ + // Name: "search", + // Aliases: []string{"s"}, + // Usage: "Browse the MedCo tree ontology", + // Action: encryptIntFromApp, + // Flags: searchCommandFlags, + // ArgsUsage: "", + // + //}, + { + Name: "query", + Aliases: []string{"q"}, + Usage: "Query the MedCo network", + Flags: queryCommandFlags, + ArgsUsage: "[patient_list|count_per_site|count_per_site_obfuscated|count_per_site_shuffled|" + + "count_per_site_shuffled_obfuscated|count_global|count_global_obfuscated] [query string]", + Action: func(c *cli.Context) error { + return medcoclient.ExecuteClientQuery( + c.GlobalString("token"), + c.GlobalString("user"), + c.GlobalString("password"), + c.Args().First(), + strings.Join(c.Args().Tail(), " "), + c.String("resultFile"), + ) + }, + }, + + } + + //cliApp.Before = func(c *cli.Context) error { + // log.SetDebugVisible(c.GlobalInt("debug")) + // return nil + //} + err := cliApp.Run(os.Args) + if err != nil { + logrus.Error(err) + } +} diff --git a/deployment/client.Dockerfile b/deployment/client.Dockerfile new file mode 100644 index 00000000..da134ac1 --- /dev/null +++ b/deployment/client.Dockerfile @@ -0,0 +1,30 @@ +FROM golang:1.12.5 as build + +COPY ./ /src + +# compile and install medco-cli-client +WORKDIR /src +RUN CGO_ENABLED=0 go install -v ./cmd/medco-cli-client/... + +# ------------------------------------------- +FROM golang:1.12.5-alpine as release + +COPY deployment/docker-entrypoint.sh /usr/local/bin/ +RUN apk update && apk add bash && rm -rf /var/cache/apk/* && \ + chmod a+x /usr/local/bin/docker-entrypoint.sh + +COPY --from=build /go/bin/medco-cli-client /go/bin/ + +# run-time environment +ENV LOG_LEVEL=5 \ + UNLYNX_GROUP_FILE_PATH=/medco-configuration/group.toml \ + UNLYNX_GROUP_FILE_IDX=0 \ + OIDC_CLIENT_ID=medco \ + CLIENT_QUERY_TIMEOUT_SECONDS=1200 \ + PICSURE2_API_HOST=picsure:8080/pic-sure-api-2/PICSURE \ + PICSURE2_API_BASE_PATH="" \ + PICSURE2_API_SCHEME=https \ + PICSURE2_RESOURCES=MEDCO_testnetwork_0_a,MEDCO_testnetwork_1_b,MEDCO_testnetwork_2_c \ + OIDC_REQ_TOKEN_URL=http://keycloak:8080/auth/realms/master/protocol/openid-connect/token + +ENTRYPOINT ["docker-entrypoint.sh", "medco-cli-client"] diff --git a/medco/client/client.go b/medco/client/client.go new file mode 100644 index 00000000..81994a12 --- /dev/null +++ b/medco/client/client.go @@ -0,0 +1,225 @@ +package medcoclient + +import ( + "bufio" + "encoding/csv" + "errors" + "fmt" + "github.com/lca1/medco-connector/restapi/models" + "github.com/lca1/medco-connector/unlynx" + utilclient "github.com/lca1/medco-connector/util/client" + "github.com/lca1/medco-loader/loader/identifiers" + "github.com/sirupsen/logrus" + "io" + "os" + "strconv" + "strings" +) + +// ExecuteClientQuery execute and display the results of the MedCo client query +func ExecuteClientQuery(token, username, password, queryType, queryString, resultOutputFilePath string) (err error) { + + // get token + var accessToken string + if len(token) > 0 { + accessToken = token + } else { + accessToken, err = utilclient.RetrieveAccessToken(username, password) + if err != nil { + return + } + } + + // parse query type + queryTypeParsed := models.QueryType(queryType) + err = queryTypeParsed.Validate(nil) + if err != nil { + logrus.Error("invalid query type") + return + } + + // parse query string + panelsItemKeys, panelsIsNot, err := parseQueryString(queryString) + + // encrypt the item keys + encPanelsItemKeys := make([][]string, 0) + for _, panel := range panelsItemKeys { + encItemKeys := make([]string, 0) + for _, itemKey := range panel { + encrypted, err := unlynx.EncryptWithCothorityKey(itemKey) + if err != nil { + return err + } + encItemKeys = append(encItemKeys, encrypted) + } + encPanelsItemKeys = append(encPanelsItemKeys, encItemKeys) + } + + // execute query + clientQuery, err := NewQuery(accessToken, queryTypeParsed, encPanelsItemKeys, panelsIsNot) + if err != nil { + return + } + + nodesResult, err := clientQuery.Execute() + if err != nil { + return + } + + // output results + var output io.Writer + if resultOutputFilePath == "" { + output = os.Stdout + } else { + output, err = os.Create(resultOutputFilePath) + if err != nil { + logrus.Error("error opening file: ", err) + } + } + err = printResultsCSV(nodesResult, output) + return +} + +// printResultsCSV prints on a specified output in a CSV format the results, each node being one line +func printResultsCSV(nodesResult map[string]*QueryResult, output io.Writer) (err error) { + + csvHeaders := []string{"node_name", "count", "patient_list"} + csvNodesResults := make([][]string, 0) + + // results lines + for nodeName, queryResult := range nodesResult { + csvNodesResults = append(csvNodesResults, []string{ + nodeName, + strconv.FormatInt(queryResult.Count, 10), + fmt.Sprint(queryResult.PatientList), + }) + } + + // timers name + for _, queryResult := range nodesResult { + for timerName := range queryResult.Times { + csvHeaders = append(csvHeaders, timerName) + } + break + } + + // timers value: iter over results, then iter over timer names from csvHeaders + for csvNodeResultsIdx, csvNodeResults := range csvNodesResults { + nodeName := csvNodeResults[0] + + for timerNameIdx := 3 ; timerNameIdx < len(csvHeaders) ; timerNameIdx++ { + timerName := csvHeaders[timerNameIdx] + timerValue := nodesResult[nodeName].Times[timerName] + + csvNodesResults[csvNodeResultsIdx] = append(csvNodesResults[csvNodeResultsIdx], timerValue) + } + } + + // write to output + csvWriter := csv.NewWriter(output) + err = csvWriter.Write(csvHeaders) + if err != nil { + logrus.Warn("error printing results: ", err) + } + err = csvWriter.WriteAll(csvNodesResults) + if err != nil { + logrus.Warn("error printing results: ", err) + } + return +} + +// parseQueryString parses the query string given as input +func parseQueryString(queryString string) (panelsItemKeys [][]int64, panelsIsNot []bool, err error) { + logrus.Info("Client query is: ", queryString) + + panelsItemKeys = make([][]int64, 0) + panelsIsNot = make([]bool, 0) + + for _, queryPanel := range strings.Split(queryString, " AND ") { + + // parse panel negation + if strings.HasPrefix(queryPanel, "NOT ") { + panelsIsNot = append(panelsIsNot, true) + queryPanel = queryPanel[4:] + } else { + panelsIsNot = append(panelsIsNot, false) + } + + // parse query items + itemKeys := make([]int64, 0) + for _, queryItem := range strings.Split(queryPanel, " OR ") { + + parsedInt, parsedErr := strconv.ParseInt(queryItem, 10, 64) + if parsedErr == nil { + logrus.Debug("Client query integer item: ", queryItem) + + // if a parsable integer: use as is + itemKeys = append(itemKeys, parsedInt) + + } else { + logrus.Debug("Client query file item: ", queryItem) + + // else assume it is a file + itemKeysFromFile, err := loadQueryFile(queryItem) + if err != nil { + return nil, nil, err + } + itemKeys = append(itemKeys, itemKeysFromFile...) + } + } + panelsItemKeys = append(panelsItemKeys, itemKeys) + } + return +} + +// todo: might fail if alleles of queries are too big, what to do? ignore +// loadQueryFile load and parse a query file (either simple integer or genomic) into integers +func loadQueryFile(queryFilePath string) (queryTerms []int64, err error) { + logrus.Debug("Client query: loading file ", queryFilePath) + + queryFile, err := os.Open(queryFilePath) + if err != nil { + logrus.Error("error opening query file: ", err) + return + } + + fileScanner := bufio.NewScanner(queryFile) + for fileScanner.Scan() { + queryTermFields := strings.Split(fileScanner.Text(), ",") + var queryTerm int64 + + if len(queryTermFields) == 1 { + + // simple integer identifier + queryTerm, err = strconv.ParseInt(queryTermFields[0], 10, 64) + if err != nil { + logrus.Error("error parsing query term: ", err) + return + } + + } else if len(queryTermFields) == 4 { + + // genomic identifier, generate the variant ID + startPos, err := strconv.ParseInt(queryTermFields[1], 10, 64) + if err != nil { + logrus.Error("error parsing start position: ", err) + return nil, err + } + + queryTerm, err = identifiers.GetVariantID(queryTermFields[0], startPos, queryTermFields[2], queryTermFields[3]) + if err != nil { + logrus.Error("error generating genomic query term: ", err) + return nil, err + } + + } else { + err = errors.New("dataset with "+ string(len(queryTermFields)) + " fields is not supported") + logrus.Error(err) + return + } + + queryTerms = append(queryTerms, queryTerm) + } + + return +} diff --git a/medco/client/query.go b/medco/client/query.go new file mode 100644 index 00000000..b50a6096 --- /dev/null +++ b/medco/client/query.go @@ -0,0 +1,216 @@ +package medcoclient + +import ( + "errors" + httptransport "github.com/go-openapi/runtime/client" + "github.com/lca1/medco-connector/restapi/client" + "github.com/lca1/medco-connector/restapi/client/picsure2" + "github.com/lca1/medco-connector/restapi/models" + "github.com/lca1/medco-connector/unlynx" + utilclient "github.com/lca1/medco-connector/util/client" + "github.com/sirupsen/logrus" + "time" +) + +// todo: times should be parsed + +// Query is a MedCo client query +type Query struct { + + // httpMedcoClient is the HTTP client for the MedCo connectors through PIC-SURE + httpMedcoClient *client.MedcoCli + // picsureResourceNames is the list of PIC-SURE resources names corresponding to the MedCo connector of each node + picsureResourceNames []string + // picsureResourceUUIDs is the list of PIC-SURE resources UUIDs corresponding to the MedCo connector of each node + picsureResourceUUIDs []string + // authToken is the OIDC authentication JWT + authToken string + + // userPublicKey is the user public key + userPublicKey string + // userPrivateKey is the user private key + userPrivateKey string + + // queryType is the type of query requested + queryType models.QueryType + // encPanelsItemKeys is part of the query: contains the encrypted item keys organized by panel + encPanelsItemKeys [][]string + // panelsIsNot is part of the query: indicates which panels are negated + panelsIsNot []bool +} + +// NewQuery creates a new MedCo client query +func NewQuery(authToken string, queryType models.QueryType, encPanelsItemKeys [][]string, panelsIsNot []bool) (q *Query, err error) { + transport := httptransport.New(utilclient.Picsure2APIHost, utilclient.Picsure2APIBasePath, []string{utilclient.Picsure2APIScheme}) + q = &Query{ + + httpMedcoClient: client.New(transport, nil), + picsureResourceNames: utilclient.Picsure2Resources, + picsureResourceUUIDs: []string{}, + authToken: authToken, + + queryType: queryType, + encPanelsItemKeys: encPanelsItemKeys, + panelsIsNot: panelsIsNot, + } + + // retrieve resource UUIDs + err = q.loadResourceUUIDs() + if err != nil { + return + } + + // generate ephemeral pair of user keys + q.userPublicKey, q.userPrivateKey, err = unlynx.GenerateKeyPair() + if err != nil { + return + } + + return +} + +// Execute executes the MedCo client query synchronously on all the nodes through PIC-SURE +func (clientQuery *Query) Execute() (nodesResult map [string]*QueryResult, err error) { + + queryResultsChan := make(chan *models.QueryResultElement) + queryErrChan := make(chan error) + + // execute requests on all nodes + for idx := range clientQuery.picsureResourceUUIDs { + go func() { + + queryResult, err := clientQuery.submitToNode(idx) + if err != nil { + queryErrChan <- err + } else { + queryResultsChan <- queryResult + } + + }() + } + + // parse the results as they come, or interrupt if one of them errors, or if a timeout occurs + timeout := time.After(time.Duration(utilclient.QueryTimeoutSeconds) * time.Second) + nodesResult = make(map [string]*QueryResult) + forLoop: for _, picsureResourceName := range clientQuery.picsureResourceNames { + select { + case queryResult := <-queryResultsChan: + parsedQueryResult, err := newQueryResult(queryResult, clientQuery.userPrivateKey) + if err != nil { + return nil, err + } + + nodesResult[picsureResourceName] = parsedQueryResult + logrus.Info("MedCo client query successful for resource ", picsureResourceName) + + if len(nodesResult) == len(clientQuery.picsureResourceUUIDs) { + logrus.Info("MedCo client query successful for all resources") + return nodesResult, nil + } + + case err = <- queryErrChan: + logrus.Error("MedCo client query error: ", err) + break forLoop + + case <-timeout: + err = errors.New("MedCo client query timeout") + logrus.Error(err) + break forLoop + } + } + + // if execution reaches that stage, there was an error + if err == nil { + // this should not happen + err = errors.New("inconsistent state") + logrus.Error(err) + } + return nil, err +} + +// loadResourceUUIDs requests the list of PIC-SURE resources, and retrieves their UUID from the names configured +func (clientQuery *Query) loadResourceUUIDs() (err error) { + getResourcesParams := picsure2.NewGetResourcesParamsWithTimeout(30 * time.Second) + resp, err := clientQuery.httpMedcoClient.Picsure2.GetResources(getResourcesParams, httptransport.BearerToken(clientQuery.authToken)) + if err != nil { + logrus.Error("query error: ", err) + return + } + + // add in the same order the resources + for _, resourceName := range clientQuery.picsureResourceNames { + for _, respResource := range resp.Payload { + if resourceName == respResource.Name { + clientQuery.picsureResourceUUIDs = append(clientQuery.picsureResourceUUIDs, respResource.UUID) + } + } + } + + // check all resources were indeed present + if len(clientQuery.picsureResourceUUIDs) != len(clientQuery.picsureResourceNames) { + err = errors.New("some resources were not found") + logrus.Error(err) + return + } + + return +} + +// submitToNode sends a query to a node of the network, from the list of PIC-SURE resources +func (clientQuery *Query) submitToNode(picsureResourceUUIDIdx int) (result *models.QueryResultElement, err error) { + + queryParams := picsure2.NewQuerySyncParamsWithTimeout(time.Duration(utilclient.QueryTimeoutSeconds) * time.Second) + queryParams.Body = picsure2.QuerySyncBody{ + ResourceCredentials: &models.ResourceCredentials{ + MEDCOTOKEN: clientQuery.authToken, + }, + ResourceUUID: clientQuery.picsureResourceUUIDs[picsureResourceUUIDIdx], + Query: clientQuery.generateModel(), + } + + resp, err := clientQuery.httpMedcoClient.Picsure2.QuerySync(queryParams, httptransport.BearerToken(clientQuery.authToken)) + if err != nil { + logrus.Error("query error: ", err) + return + } + + return resp.Payload, nil +} + +// generateModel parses the query terms and generate the model to be sent +func (clientQuery *Query) generateModel() (queryModel *models.Query) { + + // query model + queryModel = &models.Query{ + Name: "MedCo_CLI_Query_" + time.Now().Format(time.RFC3339), + I2b2Medco: &models.QueryI2b2Medco{ + UserPublicKey: clientQuery.userPublicKey, + QueryType: clientQuery.queryType, + Panels: []*models.QueryI2b2MedcoPanelsItems0{}, + }, + } + + // query terms + for panelIdx, panel := range clientQuery.encPanelsItemKeys { + + panelModel := &models.QueryI2b2MedcoPanelsItems0{ + Items: []*models.QueryI2b2MedcoPanelsItems0ItemsItems0{}, + Not: &clientQuery.panelsIsNot[panelIdx], + } + + true := true + for _, encItem := range panel { + panelModel.Items = append(panelModel.Items, &models.QueryI2b2MedcoPanelsItems0ItemsItems0{ + Encrypted: &true, + Operator: "exists", + QueryTerm: encItem, + Value: "", + }) + + } + + queryModel.I2b2Medco.Panels = append(queryModel.I2b2Medco.Panels, panelModel) + } + + return +} diff --git a/medco/client/query_result.go b/medco/client/query_result.go new file mode 100644 index 00000000..96e881d4 --- /dev/null +++ b/medco/client/query_result.go @@ -0,0 +1,46 @@ +package medcoclient + +import ( + "github.com/lca1/medco-connector/restapi/models" + "github.com/lca1/medco-connector/unlynx" + "github.com/sirupsen/logrus" +) + +// QueryResult contains the decrypted results of a node +type QueryResult struct { + Count int64 + PatientList []int64 + Times map[string]string +} + +// newQueryResult parses a query result from a node and decrypts its fields +func newQueryResult(nodeResult *models.QueryResultElement, privateKey string) (parsedResult *QueryResult, err error) { + parsedResult = &QueryResult{} + + // decrypt count + parsedResult.Count, err = unlynx.Decrypt(nodeResult.EncryptedCount, privateKey) + if err != nil { + logrus.Error("error decrypting count: ", err) + return + } + + // decrypt patient list + for _, patientID := range nodeResult.EncryptedPatientList { + decryptedPatientID, err := unlynx.Decrypt(patientID, privateKey) + if err != nil { + logrus.Error("error decrypting patient ID: ", err) + return nil, err + } + + if decryptedPatientID != 0 { + parsedResult.PatientList = append(parsedResult.PatientList, decryptedPatientID) + } + } + + // parse times + // todo: nodeResult. + + logrus.Info("Node result: count=", parsedResult.Count, ", # patient IDs decrypted=", + len(nodeResult.EncryptedPatientList), ", # non dummy patients=", len(parsedResult.PatientList)) + return +} diff --git a/restapi/client/medco_cli_client.go b/restapi/client/medco_cli_client.go index 803c5bb1..8628abe3 100644 --- a/restapi/client/medco_cli_client.go +++ b/restapi/client/medco_cli_client.go @@ -23,7 +23,7 @@ const ( DefaultHost string = "localhost" // DefaultBasePath is the default BasePath // found in Meta (info) section of spec file - DefaultBasePath string = "/medco-connector" + DefaultBasePath string = "/pic-sure-api-2/PICSURE" ) // DefaultSchemes are the default schemes found in Meta (info) section of spec file diff --git a/restapi/client/picsure2/get_info_responses.go b/restapi/client/picsure2/get_info_responses.go index 967c2ee6..6bf491f1 100644 --- a/restapi/client/picsure2/get_info_responses.go +++ b/restapi/client/picsure2/get_info_responses.go @@ -61,7 +61,7 @@ type GetInfoOK struct { } func (o *GetInfoOK) Error() string { - return fmt.Sprintf("[POST /picsure2/info][%d] getInfoOK %+v", 200, o.Payload) + return fmt.Sprintf("[POST /info][%d] getInfoOK %+v", 200, o.Payload) } func (o *GetInfoOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -99,7 +99,7 @@ func (o *GetInfoDefault) Code() int { } func (o *GetInfoDefault) Error() string { - return fmt.Sprintf("[POST /picsure2/info][%d] getInfo default %+v", o._statusCode, o.Payload) + return fmt.Sprintf("[POST /info][%d] getInfo default %+v", o._statusCode, o.Payload) } func (o *GetInfoDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { diff --git a/restapi/client/picsure2/get_resources_parameters.go b/restapi/client/picsure2/get_resources_parameters.go new file mode 100644 index 00000000..bd080521 --- /dev/null +++ b/restapi/client/picsure2/get_resources_parameters.go @@ -0,0 +1,113 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package picsure2 + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + + strfmt "github.com/go-openapi/strfmt" +) + +// NewGetResourcesParams creates a new GetResourcesParams object +// with the default values initialized. +func NewGetResourcesParams() *GetResourcesParams { + + return &GetResourcesParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewGetResourcesParamsWithTimeout creates a new GetResourcesParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewGetResourcesParamsWithTimeout(timeout time.Duration) *GetResourcesParams { + + return &GetResourcesParams{ + + timeout: timeout, + } +} + +// NewGetResourcesParamsWithContext creates a new GetResourcesParams object +// with the default values initialized, and the ability to set a context for a request +func NewGetResourcesParamsWithContext(ctx context.Context) *GetResourcesParams { + + return &GetResourcesParams{ + + Context: ctx, + } +} + +// NewGetResourcesParamsWithHTTPClient creates a new GetResourcesParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewGetResourcesParamsWithHTTPClient(client *http.Client) *GetResourcesParams { + + return &GetResourcesParams{ + HTTPClient: client, + } +} + +/*GetResourcesParams contains all the parameters to send to the API endpoint +for the get resources operation typically these are written to a http.Request +*/ +type GetResourcesParams struct { + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the get resources params +func (o *GetResourcesParams) WithTimeout(timeout time.Duration) *GetResourcesParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the get resources params +func (o *GetResourcesParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the get resources params +func (o *GetResourcesParams) WithContext(ctx context.Context) *GetResourcesParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the get resources params +func (o *GetResourcesParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the get resources params +func (o *GetResourcesParams) WithHTTPClient(client *http.Client) *GetResourcesParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the get resources params +func (o *GetResourcesParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WriteToRequest writes these params to a swagger request +func (o *GetResourcesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/restapi/client/picsure2/get_resources_responses.go b/restapi/client/picsure2/get_resources_responses.go new file mode 100644 index 00000000..455343b7 --- /dev/null +++ b/restapi/client/picsure2/get_resources_responses.go @@ -0,0 +1,185 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package picsure2 + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/swag" + + strfmt "github.com/go-openapi/strfmt" +) + +// GetResourcesReader is a Reader for the GetResources structure. +type GetResourcesReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *GetResourcesReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + + case 200: + result := NewGetResourcesOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + + default: + result := NewGetResourcesDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result + } +} + +// NewGetResourcesOK creates a GetResourcesOK with default headers values +func NewGetResourcesOK() *GetResourcesOK { + return &GetResourcesOK{} +} + +/*GetResourcesOK handles this case with default header values. + +PIC-SURE 2 list of resources. +*/ +type GetResourcesOK struct { + Payload []*GetResourcesOKBodyItems0 +} + +func (o *GetResourcesOK) Error() string { + return fmt.Sprintf("[GET /resource][%d] getResourcesOK %+v", 200, o.Payload) +} + +func (o *GetResourcesOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetResourcesDefault creates a GetResourcesDefault with default headers values +func NewGetResourcesDefault(code int) *GetResourcesDefault { + return &GetResourcesDefault{ + _statusCode: code, + } +} + +/*GetResourcesDefault handles this case with default header values. + +Error response +*/ +type GetResourcesDefault struct { + _statusCode int + + Payload *GetResourcesDefaultBody +} + +// Code gets the status code for the get resources default response +func (o *GetResourcesDefault) Code() int { + return o._statusCode +} + +func (o *GetResourcesDefault) Error() string { + return fmt.Sprintf("[GET /resource][%d] getResources default %+v", o._statusCode, o.Payload) +} + +func (o *GetResourcesDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(GetResourcesDefaultBody) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +/*GetResourcesDefaultBody get resources default body +swagger:model GetResourcesDefaultBody +*/ +type GetResourcesDefaultBody struct { + + // message + Message string `json:"message,omitempty"` +} + +// Validate validates this get resources default body +func (o *GetResourcesDefaultBody) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *GetResourcesDefaultBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *GetResourcesDefaultBody) UnmarshalBinary(b []byte) error { + var res GetResourcesDefaultBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} + +/*GetResourcesOKBodyItems0 get resources o k body items0 +swagger:model GetResourcesOKBodyItems0 +*/ +type GetResourcesOKBodyItems0 struct { + + // description + Description string `json:"description,omitempty"` + + // name + Name string `json:"name,omitempty"` + + // resource r s path + ResourceRSPath string `json:"resourceRSPath,omitempty"` + + // target URL + TargetURL string `json:"targetURL,omitempty"` + + // uuid + UUID string `json:"uuid,omitempty"` +} + +// Validate validates this get resources o k body items0 +func (o *GetResourcesOKBodyItems0) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *GetResourcesOKBodyItems0) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *GetResourcesOKBodyItems0) UnmarshalBinary(b []byte) error { + var res GetResourcesOKBodyItems0 + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} diff --git a/restapi/client/picsure2/picsure2_client.go b/restapi/client/picsure2/picsure2_client.go index 31c5a96a..63994441 100644 --- a/restapi/client/picsure2/picsure2_client.go +++ b/restapi/client/picsure2/picsure2_client.go @@ -36,7 +36,7 @@ func (a *Client) GetInfo(params *GetInfoParams, authInfo runtime.ClientAuthInfoW result, err := a.transport.Submit(&runtime.ClientOperation{ ID: "getInfo", Method: "POST", - PathPattern: "/picsure2/info", + PathPattern: "/info", ProducesMediaTypes: []string{"application/json"}, ConsumesMediaTypes: []string{"application/json"}, Schemes: []string{"http"}, @@ -53,6 +53,35 @@ func (a *Client) GetInfo(params *GetInfoParams, authInfo runtime.ClientAuthInfoW } +/* +GetResources returns the list of p i c s u r e resources +*/ +func (a *Client) GetResources(params *GetResourcesParams, authInfo runtime.ClientAuthInfoWriter) (*GetResourcesOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewGetResourcesParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "getResources", + Method: "GET", + PathPattern: "/resource", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &GetResourcesReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + return result.(*GetResourcesOK), nil + +} + /* Query queries med co node */ @@ -65,7 +94,7 @@ func (a *Client) Query(params *QueryParams, authInfo runtime.ClientAuthInfoWrite result, err := a.transport.Submit(&runtime.ClientOperation{ ID: "query", Method: "POST", - PathPattern: "/picsure2/query", + PathPattern: "/query", ProducesMediaTypes: []string{"application/json"}, ConsumesMediaTypes: []string{"application/json"}, Schemes: []string{"http"}, @@ -94,7 +123,7 @@ func (a *Client) QueryResult(params *QueryResultParams, authInfo runtime.ClientA result, err := a.transport.Submit(&runtime.ClientOperation{ ID: "queryResult", Method: "POST", - PathPattern: "/picsure2/{queryId}/result", + PathPattern: "/query/{queryId}/result", ProducesMediaTypes: []string{"application/json"}, ConsumesMediaTypes: []string{"application/json"}, Schemes: []string{"http"}, @@ -123,7 +152,7 @@ func (a *Client) QueryStatus(params *QueryStatusParams, authInfo runtime.ClientA result, err := a.transport.Submit(&runtime.ClientOperation{ ID: "queryStatus", Method: "POST", - PathPattern: "/picsure2/{queryId}/status", + PathPattern: "/query/{queryId}/status", ProducesMediaTypes: []string{"application/json"}, ConsumesMediaTypes: []string{"application/json"}, Schemes: []string{"http"}, @@ -152,7 +181,7 @@ func (a *Client) QuerySync(params *QuerySyncParams, authInfo runtime.ClientAuthI result, err := a.transport.Submit(&runtime.ClientOperation{ ID: "querySync", Method: "POST", - PathPattern: "/picsure2/query/sync", + PathPattern: "/query/sync", ProducesMediaTypes: []string{"application/json"}, ConsumesMediaTypes: []string{"application/json"}, Schemes: []string{"http"}, @@ -181,7 +210,7 @@ func (a *Client) Search(params *SearchParams, authInfo runtime.ClientAuthInfoWri result, err := a.transport.Submit(&runtime.ClientOperation{ ID: "search", Method: "POST", - PathPattern: "/picsure2/search", + PathPattern: "/search", ProducesMediaTypes: []string{"application/json"}, ConsumesMediaTypes: []string{"application/json"}, Schemes: []string{"http"}, diff --git a/restapi/client/picsure2/query_responses.go b/restapi/client/picsure2/query_responses.go index e9eb09f6..ed8961ec 100644 --- a/restapi/client/picsure2/query_responses.go +++ b/restapi/client/picsure2/query_responses.go @@ -60,7 +60,7 @@ type QueryOK struct { } func (o *QueryOK) Error() string { - return fmt.Sprintf("[POST /picsure2/query][%d] queryOK %+v", 200, o.Payload) + return fmt.Sprintf("[POST /query][%d] queryOK %+v", 200, o.Payload) } func (o *QueryOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -98,7 +98,7 @@ func (o *QueryDefault) Code() int { } func (o *QueryDefault) Error() string { - return fmt.Sprintf("[POST /picsure2/query][%d] query default %+v", o._statusCode, o.Payload) + return fmt.Sprintf("[POST /query][%d] query default %+v", o._statusCode, o.Payload) } func (o *QueryDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { diff --git a/restapi/client/picsure2/query_result_responses.go b/restapi/client/picsure2/query_result_responses.go index bdbb03c8..21ff55d8 100644 --- a/restapi/client/picsure2/query_result_responses.go +++ b/restapi/client/picsure2/query_result_responses.go @@ -60,7 +60,7 @@ type QueryResultOK struct { } func (o *QueryResultOK) Error() string { - return fmt.Sprintf("[POST /picsure2/{queryId}/result][%d] queryResultOK %+v", 200, o.Payload) + return fmt.Sprintf("[POST /query/{queryId}/result][%d] queryResultOK %+v", 200, o.Payload) } func (o *QueryResultOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -98,7 +98,7 @@ func (o *QueryResultDefault) Code() int { } func (o *QueryResultDefault) Error() string { - return fmt.Sprintf("[POST /picsure2/{queryId}/result][%d] queryResult default %+v", o._statusCode, o.Payload) + return fmt.Sprintf("[POST /query/{queryId}/result][%d] queryResult default %+v", o._statusCode, o.Payload) } func (o *QueryResultDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { diff --git a/restapi/client/picsure2/query_status_responses.go b/restapi/client/picsure2/query_status_responses.go index ca067d75..66ea2c22 100644 --- a/restapi/client/picsure2/query_status_responses.go +++ b/restapi/client/picsure2/query_status_responses.go @@ -60,7 +60,7 @@ type QueryStatusOK struct { } func (o *QueryStatusOK) Error() string { - return fmt.Sprintf("[POST /picsure2/{queryId}/status][%d] queryStatusOK %+v", 200, o.Payload) + return fmt.Sprintf("[POST /query/{queryId}/status][%d] queryStatusOK %+v", 200, o.Payload) } func (o *QueryStatusOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -98,7 +98,7 @@ func (o *QueryStatusDefault) Code() int { } func (o *QueryStatusDefault) Error() string { - return fmt.Sprintf("[POST /picsure2/{queryId}/status][%d] queryStatus default %+v", o._statusCode, o.Payload) + return fmt.Sprintf("[POST /query/{queryId}/status][%d] queryStatus default %+v", o._statusCode, o.Payload) } func (o *QueryStatusDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { diff --git a/restapi/client/picsure2/query_sync_responses.go b/restapi/client/picsure2/query_sync_responses.go index f1fa088b..01aa2a2d 100644 --- a/restapi/client/picsure2/query_sync_responses.go +++ b/restapi/client/picsure2/query_sync_responses.go @@ -60,7 +60,7 @@ type QuerySyncOK struct { } func (o *QuerySyncOK) Error() string { - return fmt.Sprintf("[POST /picsure2/query/sync][%d] querySyncOK %+v", 200, o.Payload) + return fmt.Sprintf("[POST /query/sync][%d] querySyncOK %+v", 200, o.Payload) } func (o *QuerySyncOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -98,7 +98,7 @@ func (o *QuerySyncDefault) Code() int { } func (o *QuerySyncDefault) Error() string { - return fmt.Sprintf("[POST /picsure2/query/sync][%d] querySync default %+v", o._statusCode, o.Payload) + return fmt.Sprintf("[POST /query/sync][%d] querySync default %+v", o._statusCode, o.Payload) } func (o *QuerySyncDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { diff --git a/restapi/client/picsure2/search_responses.go b/restapi/client/picsure2/search_responses.go index 1c2bf978..7f800f78 100644 --- a/restapi/client/picsure2/search_responses.go +++ b/restapi/client/picsure2/search_responses.go @@ -61,7 +61,7 @@ type SearchOK struct { } func (o *SearchOK) Error() string { - return fmt.Sprintf("[POST /picsure2/search][%d] searchOK %+v", 200, o.Payload) + return fmt.Sprintf("[POST /search][%d] searchOK %+v", 200, o.Payload) } func (o *SearchOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { @@ -99,7 +99,7 @@ func (o *SearchDefault) Code() int { } func (o *SearchDefault) Error() string { - return fmt.Sprintf("[POST /picsure2/search][%d] search default %+v", o._statusCode, o.Payload) + return fmt.Sprintf("[POST /search][%d] search default %+v", o._statusCode, o.Payload) } func (o *SearchDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { diff --git a/swagger/medco-cli-client.yml b/swagger/medco-cli-client.yml new file mode 100644 index 00000000..3e8e8848 --- /dev/null +++ b/swagger/medco-cli-client.yml @@ -0,0 +1,107 @@ +swagger: "2.0" +info: + description: "This is the PIC-SURE 2 API exposed by MedCo, and used by the MedCo CLI client." + version: "0.2.0" + title: "MedCo CLI Client (PIC-SURE 2 API)" + contact: + email: "medco-dev@listes.epfl.ch" + license: + name: "EULA" + url: "https://raw.githubusercontent.com/lca1/medco-connector/master/LICENSE" +basePath: "/pic-sure-api-2/PICSURE" +tags: + - name: "picsure2" + description: "PIC-SURE 2 API" +schemes: + - "http" +externalDocs: + description: "MedCo Technical Documentation" + url: "https://medco.epfl.ch/documentation" +security: + - MedCoToken: [] + +securityDefinitions: + MedCoToken: + type: "oauth2" + flow: "application" + tokenUrl: "https://medco-demo.epfl.ch/auth" + description: "MedCo JWT token." + +paths: + /resource: + get: + tags: + - "picsure2" + summary: "Returns the list of PIC-SURE resources." + operationId: "getResources" + consumes: + - "application/json" + produces: + - "application/json" + responses: + 200: + $ref: "#/responses/resources" + default: + $ref: "medco-connector-server.yml#/responses/error" + + /info: + $ref: "medco-connector-server.yml#/paths/~1picsure2~1info" + + /search: + $ref: "medco-connector-server.yml#/paths/~1picsure2~1search" + + /query: + $ref: "medco-connector-server.yml#/paths/~1picsure2~1query" + + /query/sync: + $ref: "medco-connector-server.yml#/paths/~1picsure2~1query~1sync" + + /query/{queryId}/status: + $ref: "medco-connector-server.yml#/paths/~1picsure2~1query~1{queryId}~1status" + + /query/{queryId}/result: + $ref: "medco-connector-server.yml#/paths/~1picsure2~1query~1{queryId}~1result" + +responses: + resources: + description: "PIC-SURE 2 list of resources." + schema: + type: "array" + items: + type: "object" + properties: + uuid: + type: "string" + name: + type: "string" + description: + type: "string" + targetURL: + type: "string" + resourceRSPath: + type: "string" + +definitions: + resourceCredentials: + $ref: "medco-connector-server.yml#/definitions/resourceCredentials" + + searchQuery: + $ref: "medco-connector-server.yml#/definitions/searchQuery" + + searchResultElement: + $ref: "medco-connector-server.yml#/definitions/searchResultElement" + + query: + $ref: "medco-connector-server.yml#/definitions/query" + + queryType: + $ref: "medco-connector-server.yml#/definitions/queryType" + + queryResultElement: + $ref: "medco-connector-server.yml#/definitions/queryResultElement" + + queryStatus: + $ref: "medco-connector-server.yml#/definitions/queryStatus" + + user: + $ref: "medco-connector-server.yml#/definitions/user" diff --git a/util/client/configuration.go b/util/client/configuration.go new file mode 100644 index 00000000..3a6bedeb --- /dev/null +++ b/util/client/configuration.go @@ -0,0 +1,39 @@ +package utilclient + +import ( + "github.com/sirupsen/logrus" + "os" + "strconv" + "strings" +) + +// QueryTimeoutSeconds is the timeout for the client query in seconds (default to 3 minutes) +var QueryTimeoutSeconds int64 +// Picsure2APIHost is the PIC-SURE host that broadcasts the query to the MedCo connectors +var Picsure2APIHost string +// Picsure2APIBasePath is the PIC-SURE hosts that broadcasts the query to the MedCo connectors +var Picsure2APIBasePath string +// Picsure2APIScheme is the PIC-SURE hosts that broadcasts the query to the MedCo connectors +var Picsure2APIScheme string +// Picsure2Resources are the resources to be queried by the client, corresponding to the medco connectors +var Picsure2Resources []string + +// OidcReqTokenURL is the URL from which the JWT is retrieved +var OidcReqTokenURL string + +func init() { + var err error + + QueryTimeoutSeconds, err = strconv.ParseInt(os.Getenv("CLIENT_QUERY_TIMEOUT_SECONDS"), 10, 64) + if err != nil || QueryTimeoutSeconds < 0 { + logrus.Warn("invalid client query timeout") + QueryTimeoutSeconds = 3 * 60 + } + + Picsure2APIHost = os.Getenv("PICSURE2_API_HOST") + Picsure2APIBasePath = os.Getenv("PICSURE2_API_BASE_PATH") + Picsure2APIScheme = os.Getenv("PICSURE2_API_SCHEME") + Picsure2Resources = strings.Split(os.Getenv("PICSURE2_RESOURCES"), ",") + + OidcReqTokenURL = os.Getenv("OIDC_REQ_TOKEN_URL") +} diff --git a/util/client/security.go b/util/client/security.go new file mode 100644 index 00000000..626a1820 --- /dev/null +++ b/util/client/security.go @@ -0,0 +1,52 @@ +package utilclient + +import ( + "encoding/json" + "errors" + "github.com/lca1/medco-connector/util" + "github.com/sirupsen/logrus" + "io/ioutil" + "net/http" + "net/url" +) + +// oidcTokenResp contains the response to an OIDC token request +type oidcTokenResp struct { + AccessToken string `json:"access_token"` + TokenType string `json:"token_type"` + Scope string `json:"scope"` +} + +// RetrieveAccessToken requests JWT from OIDC provider +func RetrieveAccessToken(username string, password string) (token string, err error) { + + httpResp, err := http.PostForm(OidcReqTokenURL, url.Values{ + "grant_type": {"password"}, + "client_id": {util.OidcClientID}, + "username": {username}, + "password": {password}, + }) + + if err != nil { + logrus.Error("OIDC request token error: ", err) + return + } + + if httpResp.StatusCode != 200 { + err = errors.New("OIDC request token error (code " + string(httpResp.StatusCode) + ")") + logrus.Error(err) + return + } + + bodyBytes, err := ioutil.ReadAll(httpResp.Body) + parsedResp := &oidcTokenResp{} + err = json.Unmarshal(bodyBytes, parsedResp) + if err != nil { + logrus.Error("OIDC request token error unmarshalling: ", err) + return + } + + logrus.Info("OIDC request token successfully authenticated") + logrus.Debug("OIDC request token: " + parsedResp.AccessToken) + return parsedResp.AccessToken, nil +} From 735500e6eb8e50230262bfc2ce85dce7bf247a67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Thu, 13 Jun 2019 16:46:33 +0200 Subject: [PATCH 23/41] update deployment for client --- deployment/Dockerfile | 7 +++---- deployment/docker-compose.yml | 22 ++++++++++++++++++++++ deployment/docker-entrypoint.sh | 2 +- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/deployment/Dockerfile b/deployment/Dockerfile index 5cbbefc7..ad0199cd 100644 --- a/deployment/Dockerfile +++ b/deployment/Dockerfile @@ -2,10 +2,9 @@ FROM golang:1.12 as build COPY ./ /src -# compile and install medco-connector +# compile and install medco-connector-server WORKDIR /src -RUN CGO_ENABLED=0 go build -v ./... && \ - CGO_ENABLED=0 go install -v ./... +RUN CGO_ENABLED=0 go install -v ./cmd/medco-connector-server/... # ------------------------------------------- FROM golang:1.12-alpine as release @@ -35,4 +34,4 @@ ENV I2B2_HIVE_URL=http://i2b2:8080/i2b2/services \ OIDC_JWT_USER_ID_CLAIM=preferred_username EXPOSE 1999 -ENTRYPOINT ["docker-entrypoint.sh"] +ENTRYPOINT ["docker-entrypoint.sh", "medco-connector-server"] diff --git a/deployment/docker-compose.yml b/deployment/docker-compose.yml index 11f96e14..661aeb11 100644 --- a/deployment/docker-compose.yml +++ b/deployment/docker-compose.yml @@ -22,3 +22,25 @@ services: - OIDC_JWT_USER_ID_CLAIM=preferred_username volumes: - ./configuration-profile:/medco-configuration + + medco-cli-client: + image: medco/medco-cli-client:dev + build: + context: ../ + dockerfile: deployment/client.Dockerfile + environment: + - LOG_LEVEL=5 + - UNLYNX_GROUP_FILE_PATH=/medco-configuration/group.toml + - UNLYNX_GROUP_FILE_IDX=0 + - OIDC_CLIENT_ID=medco + - CLIENT_QUERY_TIMEOUT_SECONDS=1200 + - PICSURE2_API_HOST=localhost + - PICSURE2_API_BASE_PATH=/pic-sure-api-2/PICSURE + - PICSURE2_API_SCHEME=http + - PICSURE2_RESOURCES=MEDCO_testnetwork_0_a,MEDCO_testnetwork_1_b,MEDCO_testnetwork_2_c + - OIDC_REQ_TOKEN_URL=http://localhost/auth/realms/master/protocol/openid-connect/token + volumes: + - ~/MedCo/repositories/medco-deployment/configuration-profiles/dev-local-3nodes:/medco-configuration + network_mode: host + command: >- + todo: default e2e query command; diff --git a/deployment/docker-entrypoint.sh b/deployment/docker-entrypoint.sh index 0cf65b70..13786130 100644 --- a/deployment/docker-entrypoint.sh +++ b/deployment/docker-entrypoint.sh @@ -7,4 +7,4 @@ if [[ `ls -1 /medco-configuration/srv*-certificate.crt 2>/dev/null | wc -l` != 0 update-ca-certificates fi -exec medco-connector-server +exec $@ From c616741e053e78fdfd3548549a84565d0b2753db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Thu, 13 Jun 2019 16:47:07 +0200 Subject: [PATCH 24/41] style --- util/configuration.go | 1 - 1 file changed, 1 deletion(-) diff --git a/util/configuration.go b/util/configuration.go index fd123b07..af919d2b 100644 --- a/util/configuration.go +++ b/util/configuration.go @@ -84,5 +84,4 @@ func SetLogLevel(lvl string) { LogLevel = int(intLvl) logrus.SetLevel(logrus.Level(LogLevel + 1)) onetLog.SetDebugVisible(LogLevel) - } From 749fc4d756ac8fb80f4ae339763330c8fbc42ed4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Thu, 13 Jun 2019 16:47:38 +0200 Subject: [PATCH 25/41] add local unlynx calls --- unlynx/client_local.go | 48 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/unlynx/client_local.go b/unlynx/client_local.go index 91bd4948..61f6b3a6 100644 --- a/unlynx/client_local.go +++ b/unlynx/client_local.go @@ -51,3 +51,51 @@ func LocallyMultiplyScalar(encValue string, scalar int64) (res string, err error } return } + +// EncryptWithCothorityKey encrypts an integer with the public key of the cothority +func EncryptWithCothorityKey(value int64) (encrypted string, err error) { + _, cothorityRoster := newUnlynxClient() + encrypted, err = libunlynx.EncryptInt(cothorityRoster.Aggregate, value).Serialize() + if err != nil { + logrus.Error("unlynx failed serializing encrypted value: ", err) + } + return +} + +// Decrypt decrypts an integer with a private key +func Decrypt(value string, privKey string) (decrypted int64, err error) { + valueDes := libunlynx.CipherText{} + err = valueDes.Deserialize(value) + if err != nil { + logrus.Error("unlynx error deserializing cipher text: ", err) + return + } + + privKeyDes, err := libunlynx.DeserializeScalar(privKey) + if err != nil { + logrus.Error("unlynx error deserializing scalar: ", err) + return + } + + decrypted = libunlynx.DecryptInt(privKeyDes, valueDes) + return +} + +// GenerateKeyPair generates a matching pair of public and private keys +func GenerateKeyPair() (pubKey string, privKey string, err error) { + rawPrivKey, rawPubKey := libunlynx.GenKey() + + privKey, err = libunlynx.SerializeScalar(rawPrivKey) + if err != nil { + logrus.Error("unlynx error serializing private key: ", err) + return + } + + pubKey, err = libunlynx.SerializePoint(rawPubKey) + if err != nil { + logrus.Error("unlynx error serializing private key: ", err) + return + } + + return +} \ No newline at end of file From ccab91d2a919439d73b778b3337501994842f90b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Thu, 13 Jun 2019 16:48:00 +0200 Subject: [PATCH 26/41] adapt calls to distributed calls of unlynx for times --- unlynx/client_distributed.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/unlynx/client_distributed.go b/unlynx/client_distributed.go index 22c6200e..f62f9343 100644 --- a/unlynx/client_distributed.go +++ b/unlynx/client_distributed.go @@ -30,7 +30,7 @@ func DDTagValues(queryName string, values []string) (taggedValues map[string]str ddtResultsChan := make(chan []libunlynx.GroupingKey) ddtErrChan := make(chan error) go func() { - _, ddtResults, ddtErr := unlynxClient.SendSurveyDDTRequestTerms( + _, ddtResults, _, ddtErr := unlynxClient.SendSurveyDDTRequestTerms( cothorityRoster, servicesmedco.SurveyID(queryName + "_DDT"), desValues, @@ -89,7 +89,7 @@ func KeySwitchValues(queryName string, values []string, targetPubKey string) (ke ksResultsChan := make(chan libunlynx.CipherVector) ksErrChan := make(chan error) go func() { - _, ksResult, ksErr := unlynxClient.SendSurveyKSRequest( + _, ksResult, _, ksErr := unlynxClient.SendSurveyKSRequest( cothorityRoster, servicesmedco.SurveyID(queryName + "_KS"), desTargetKey, @@ -141,7 +141,7 @@ func ShuffleAndKeySwitchValue(queryName string, value string, targetPubKey strin shuffleKsResultsChan := make(chan libunlynx.CipherText) shuffleKsErrChan := make(chan error) go func() { - _, shuffleKsResult, shuffleKsErr := unlynxClient.SendSurveyShuffleRequest( + _, shuffleKsResult, _, shuffleKsErr := unlynxClient.SendSurveyShuffleRequest( cothorityRoster, servicesmedco.SurveyID(queryName + "_SHUFFLE"), desTargetKey, @@ -193,7 +193,7 @@ func AggregateAndKeySwitchValue(queryName string, value string, targetPubKey str aggKsResultsChan := make(chan libunlynx.CipherText) aggKsErrChan := make(chan error) go func() { - _, aggKsResult, aggKsErr := unlynxClient.SendSurveyAggRequest( + _, aggKsResult, _, aggKsErr := unlynxClient.SendSurveyAggRequest( cothorityRoster, servicesmedco.SurveyID(queryName + "_AGG"), desTargetKey, From a2806465223299e578ac1cd61c88f338e9b2ae0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Thu, 13 Jun 2019 16:48:42 +0200 Subject: [PATCH 27/41] update dependencies --- go.mod | 17 ++++++++--------- go.sum | 45 ++++++++++++++++++++++++++++++++++----------- 2 files changed, 42 insertions(+), 20 deletions(-) diff --git a/go.mod b/go.mod index a97ab1de..6666100c 100644 --- a/go.mod +++ b/go.mod @@ -13,20 +13,19 @@ require ( github.com/go-openapi/strfmt v0.19.0 github.com/go-openapi/swag v0.19.0 github.com/go-openapi/validate v0.19.0 - github.com/gopherjs/gopherjs v0.0.0-20190430165422-3e4dfb77656c // indirect github.com/jessevdk/go-flags v1.4.0 github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect - github.com/lca1/medco-unlynx v0.0.0-20190520135023-7273e0cd4409 + github.com/lca1/medco-loader v0.0.0-20190607142358-eb601905cd14 + github.com/lca1/medco-unlynx v0.0.0-20190607122735-0645e9b99b36 github.com/lca1/unlynx v1.3.1 github.com/lestrrat-go/jwx v0.9.0 github.com/mailru/easyjson v0.0.0-20190403194419-1ea4449da983 // indirect github.com/pkg/errors v0.8.1 github.com/sirupsen/logrus v1.4.2 - github.com/smartystreets/assertions v0.0.0-20190401211740-f487f9de1cd3 // indirect - go.dedis.ch/kyber/v3 v3.0.3 // indirect - go.dedis.ch/onet/v3 v3.0.13 - golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f // indirect - golang.org/x/net v0.0.0-20190522155817-f3200d17e092 - golang.org/x/sys v0.0.0-20190522044717-8097e1b27ff5 // indirect - golang.org/x/text v0.3.2 // indirect + github.com/smartystreets/assertions v1.0.0 // indirect + github.com/urfave/cli v1.20.0 + go.dedis.ch/onet/v3 v3.0.14 + golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5 // indirect + golang.org/x/net v0.0.0-20190606173856-1492cefac77f + golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444 // indirect ) diff --git a/go.sum b/go.sum index 59f5cb12..96e626e6 100644 --- a/go.sum +++ b/go.sum @@ -26,6 +26,7 @@ github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/fanliao/go-concurrentMap v0.0.0-20141114143905-7d2d7a5ea67b h1:aHrWACMJZJ160Pl0qlH6s0/+5Kb1KYG/kEUTaZCW7QY= github.com/fanliao/go-concurrentMap v0.0.0-20141114143905-7d2d7a5ea67b/go.mod h1:DRc7ieGsJItxOsZ2lnqemj92zsSsBjBepuritZaumSE= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8 h1:DujepqpGd1hyOd7aW59XpK7Qymp8iy83xq74fLr21is= github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= @@ -77,6 +78,8 @@ github.com/go-openapi/validate v0.18.0 h1:PVXYcP1GkTl+XIAJnyJxOmK6CSG5Q1UcvoCvNO github.com/go-openapi/validate v0.18.0/go.mod h1:Uh4HdOzKt19xGIGm1qHf/ofbX1YQ4Y+MYsct2VUrAJ4= github.com/go-openapi/validate v0.19.0 h1:SF5vyj6PBFM6D1cw2NJIFrlS8Su2YKk6ADPPjAH70Bw= github.com/go-openapi/validate v0.19.0/go.mod h1:Uh4HdOzKt19xGIGm1qHf/ofbX1YQ4Y+MYsct2VUrAJ4= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golangplus/bytes v0.0.0-20160111154220-45c989fe5450 h1:7xqw01UYS+KCI25bMrPxwNYkSns2Db1ziQPpVq99FpE= github.com/golangplus/bytes v0.0.0-20160111154220-45c989fe5450/go.mod h1:Bk6SMAONeMXrxql8uvOKuAZSu8aM5RUGv+1C6IJaEho= github.com/golangplus/fmt v0.0.0-20150411045040-2a5d6d7d2995 h1:f5gsjBiF9tRRVomCvrkGMMWI8W1f2OBFar2c5oakAP0= @@ -92,6 +95,7 @@ github.com/gopherjs/gopherjs v0.0.0-20190430165422-3e4dfb77656c h1:7lF+Vz0LqiRid github.com/gopherjs/gopherjs v0.0.0-20190430165422-3e4dfb77656c/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= @@ -103,15 +107,17 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxv github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/pty v1.1.4/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/lca1/medco-unlynx v0.0.0-20190520135023-7273e0cd4409 h1:JMzXDulliMydz3vckJePLq7bApeQ5ZopsoEE2Og6Z9I= -github.com/lca1/medco-unlynx v0.0.0-20190520135023-7273e0cd4409/go.mod h1:ye1nTpn1fuEoRC5V+cM0ykbjEwvcgN6eXsM2rIN89T0= +github.com/lca1/medco-loader v0.0.0-20190607142358-eb601905cd14/go.mod h1:llUindDQeDVOP3ggoALLYaL8mAuh6K953vesHrrrFpo= +github.com/lca1/medco-unlynx v0.0.0-20190607122735-0645e9b99b36 h1:zi204zXP+JkBc9w8KXBJEkoMqlDON8+fCniY1k0EQJc= +github.com/lca1/medco-unlynx v0.0.0-20190607122735-0645e9b99b36/go.mod h1:00I2j2isD6K3z8Xj4MIM5IOStT3rZQQtDkq59betkDo= github.com/lca1/unlynx v1.3.1 h1:l/sLi4DGL9Rlvk6ySzR13VYjgbubY1tMHPyXGvd2zZU= github.com/lca1/unlynx v1.3.1/go.mod h1:HOR8K2JLrylJjIDdMdFev5rE5q6XGifs0OnH7rvreqY= github.com/lestrrat-go/jwx v0.9.0 h1:Fnd0EWzTm0kFrBPzE/PEPp9nzllES5buMkksPMjEKpM= github.com/lestrrat-go/jwx v0.9.0/go.mod h1:iEoxlYfZjvoGpuWwxUz+eR5e6KTJGsaRcy/YNA/UnBk= -github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190403194419-1ea4449da983 h1:wL11wNW7dhKIcRCHSm4sHKPWz0tt4mwBsVodG7+Xyqg= @@ -121,7 +127,9 @@ github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh github.com/montanaflynn/stats v0.5.0 h1:2EkzeTSqBB4V4bJwWrt5gIIrZmpJBcoIRGS2kWLgzmk= github.com/montanaflynn/stats v0.5.0/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= +github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/pborman/uuid v1.2.0 h1:J7Q5mO4ysT1dv8hyrUGHb9+ooztCXu1D8MY8DZYsu3g= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= @@ -135,15 +143,19 @@ github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4 github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= -github.com/smartystreets/assertions v0.0.0-20190401211740-f487f9de1cd3 h1:hBSHahWMEgzwRyS6dRpxY0XyjZsHyQ61s084wo5PJe0= github.com/smartystreets/assertions v0.0.0-20190401211740-f487f9de1cd3/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/assertions v1.0.0 h1:UVQPSSmc3qtTi+zPPkCXvZX9VvW/xT/NsRvKfwY81a8= +github.com/smartystreets/assertions v1.0.0/go.mod h1:kHHU4qYBaI3q23Pp3VPrmWhuIUrLW/7eUrw0BU5VaoM= github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a h1:pa8hGb/2YqsZKovtsgrwcDH1RZhVbTKCjLp47XpqCDs= github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw= +github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= go.dedis.ch/fixbuf v1.0.3 h1:hGcV9Cd/znUxlusJ64eAlExS+5cJDIyTyEG+otu5wQs= go.dedis.ch/fixbuf v1.0.3/go.mod h1:yzJMt34Wa5xD37V5RTdmp38cz3QhMagdGoem9anUalw= go.dedis.ch/kyber/v3 v3.0.0-pre2/go.mod h1:OzvaEnPvKlyrWyp3kGXlFdp7ap1VC6RkZDTaPikqhsQ= @@ -154,9 +166,8 @@ go.dedis.ch/kyber/v3 v3.0.3 h1:XdqCfDQSuSJli/KhO5jnUFfcr8GWfMimwnwScOH5Lg8= go.dedis.ch/kyber/v3 v3.0.3/go.mod h1:OzvaEnPvKlyrWyp3kGXlFdp7ap1VC6RkZDTaPikqhsQ= go.dedis.ch/onet/v3 v3.0.0 h1:haBqkwkNNu/jHz7+PoZJS+xbtA5JheQvt0SSIjGyk5I= go.dedis.ch/onet/v3 v3.0.0/go.mod h1:xqmP2+NvxeNzgmNj/4hf56EZm3KT0Qksz98miZw5G3A= -go.dedis.ch/onet/v3 v3.0.6/go.mod h1:0wrof0zfyD+Qfw9Pfhu9jW+bTbwwWBzC1hMuV/c8v2w= -go.dedis.ch/onet/v3 v3.0.13 h1:3qF14IUvSqwq8z3ivGuXrB8T0S0wZSbku0d0quJIPQ8= -go.dedis.ch/onet/v3 v3.0.13/go.mod h1:8zNbWaMMpTiBfa8gftpoe726sivOF1ymxqkiPuvpdFA= +go.dedis.ch/onet/v3 v3.0.14 h1:KvYzHbhb74WufinPXoeICjD4/pJ4Jduw9r0enj/YzQI= +go.dedis.ch/onet/v3 v3.0.14/go.mod h1:8zNbWaMMpTiBfa8gftpoe726sivOF1ymxqkiPuvpdFA= go.dedis.ch/protobuf v1.0.5/go.mod h1:eIV4wicvi6JK0q/QnfIEGeSFNG0ZeB24kzut5+HaRLo= go.dedis.ch/protobuf v1.0.6 h1:E61p2XjYbYrTf3WeXE8M8Ui5WA3hX/NgbHHi5D0FLxI= go.dedis.ch/protobuf v1.0.6/go.mod h1:YHYXW6dQ9p2iJ3f+2fxKnOpjGx0MvL4cwpg1RVNXaV8= @@ -168,37 +179,49 @@ golang.org/x/crypto v0.0.0-20190123085648-057139ce5d2b/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190320223903-b7391e95e576/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f h1:R423Cnkcp5JABoeemiGEPlt9tHXFfw5kvc0yqlxRPWo= golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5 h1:58fnuSXlxZmFdJyvtTFVmVhcMLU6v5fEb/ok4wyqtNU= +golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190320064053-1272bf9dcd53/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190522155817-f3200d17e092 h1:4QSRKanuywn15aTZvI/mIDEgPQpswuFndXpOj3rKEco= golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190606173856-1492cefac77f h1:IWHgpgFqnL5AhBUBZSgBdjl2vkQUEzcY+JNKWfcgAU0= +golang.org/x/net v0.0.0-20190606173856-1492cefac77f/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190124100055-b90733256f2e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190321052220-f7bb7a8bee54/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190522044717-8097e1b27ff5 h1:f005F/Jl5JLP036x7QIvUVhNTqxvSYwFIiyOh2q12iU= -golang.org/x/sys v0.0.0-20190522044717-8097e1b27ff5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190528183647-3626398d7749/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444 h1:/d2cWp6PSamH4jDPFLyO150psQdqvtoNX8Zjg3AQ31g= +golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384 h1:TFlARGu6Czu1z7q93HTxcP1P+/ZFC/IKythI5RzrnRg= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190529010454-aa71c3f32488/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/satori/go.uuid.v1 v1.2.0 h1:AH9uksa7bGe9rluapecRKBCpZvxaBEyu0RepitcD0Hw= gopkg.in/satori/go.uuid.v1 v1.2.0/go.mod h1:kjjdhYBBaa5W5DYP+OcVG3fRM6VWu14hqDYST4Zvw+E= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/tylerb/graceful.v1 v1.2.15 h1:1JmOyhKqAyX3BgTXMI84LwT6FOJ4tP2N9e2kwTCM0nQ= gopkg.in/tylerb/graceful.v1 v1.2.15/go.mod h1:yBhekWvR20ACXVObSSdD3u6S9DeSylanL2PAbAC/uJ8= gopkg.in/urfave/cli.v1 v1.20.0/go.mod h1:vuBzUtMdQeixQj8LVd+/98pzhxNGQoyuPBlsXHOQNO0= From 25e193ee6d8850e3a9115cfea00f8f8145f1d8bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Fri, 14 Jun 2019 16:03:18 +0200 Subject: [PATCH 28/41] add option to bypass TLS cert check --- cmd/medco-cli-client/main.go | 5 +++++ medco/client/client.go | 7 ++++--- medco/client/query.go | 7 ++++++- util/client/security.go | 13 +++++++++++-- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/cmd/medco-cli-client/main.go b/cmd/medco-cli-client/main.go index a5c5e5ab..96deaa08 100644 --- a/cmd/medco-cli-client/main.go +++ b/cmd/medco-cli-client/main.go @@ -32,6 +32,10 @@ func main() { Name: "token, t", Usage: "OIDC token", }, + cli.BoolFlag{ + Name: "disableTLSCheck", + Usage: "Disable check of TLS certificates", + }, } // --- search command flags @@ -78,6 +82,7 @@ func main() { c.Args().First(), strings.Join(c.Args().Tail(), " "), c.String("resultFile"), + c.GlobalBool("disableTLSCheck"), ) }, }, diff --git a/medco/client/client.go b/medco/client/client.go index 81994a12..7b347390 100644 --- a/medco/client/client.go +++ b/medco/client/client.go @@ -17,14 +17,15 @@ import ( ) // ExecuteClientQuery execute and display the results of the MedCo client query -func ExecuteClientQuery(token, username, password, queryType, queryString, resultOutputFilePath string) (err error) { +func ExecuteClientQuery(token, username, password, queryType, queryString, resultOutputFilePath string, disableTLSCheck bool) (err error) { // get token var accessToken string if len(token) > 0 { accessToken = token } else { - accessToken, err = utilclient.RetrieveAccessToken(username, password) + logrus.Debug("No token provided, requesting token for user ", username, ", disable TLS check: ", disableTLSCheck) + accessToken, err = utilclient.RetrieveAccessToken(username, password, disableTLSCheck) if err != nil { return } @@ -56,7 +57,7 @@ func ExecuteClientQuery(token, username, password, queryType, queryString, resul } // execute query - clientQuery, err := NewQuery(accessToken, queryTypeParsed, encPanelsItemKeys, panelsIsNot) + clientQuery, err := NewQuery(accessToken, queryTypeParsed, encPanelsItemKeys, panelsIsNot, disableTLSCheck) if err != nil { return } diff --git a/medco/client/query.go b/medco/client/query.go index b50a6096..7d3cb5d2 100644 --- a/medco/client/query.go +++ b/medco/client/query.go @@ -1,6 +1,7 @@ package medcoclient import ( + "crypto/tls" "errors" httptransport "github.com/go-openapi/runtime/client" "github.com/lca1/medco-connector/restapi/client" @@ -9,6 +10,7 @@ import ( "github.com/lca1/medco-connector/unlynx" utilclient "github.com/lca1/medco-connector/util/client" "github.com/sirupsen/logrus" + "net/http" "time" ) @@ -40,8 +42,11 @@ type Query struct { } // NewQuery creates a new MedCo client query -func NewQuery(authToken string, queryType models.QueryType, encPanelsItemKeys [][]string, panelsIsNot []bool) (q *Query, err error) { +func NewQuery(authToken string, queryType models.QueryType, encPanelsItemKeys [][]string, panelsIsNot []bool, disableTLSCheck bool) (q *Query, err error) { + transport := httptransport.New(utilclient.Picsure2APIHost, utilclient.Picsure2APIBasePath, []string{utilclient.Picsure2APIScheme}) + transport.Transport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: disableTLSCheck} + q = &Query{ httpMedcoClient: client.New(transport, nil), diff --git a/util/client/security.go b/util/client/security.go index 626a1820..2fd989ad 100644 --- a/util/client/security.go +++ b/util/client/security.go @@ -1,6 +1,7 @@ package utilclient import ( + "crypto/tls" "encoding/json" "errors" "github.com/lca1/medco-connector/util" @@ -18,9 +19,17 @@ type oidcTokenResp struct { } // RetrieveAccessToken requests JWT from OIDC provider -func RetrieveAccessToken(username string, password string) (token string, err error) { +func RetrieveAccessToken(username string, password string, disableTLSCheck bool) (token string, err error) { + + httpClient := http.Client{ + Transport: &http.Transport{ + TLSClientConfig: &tls.Config{ + InsecureSkipVerify: disableTLSCheck, + }, + }, + } - httpResp, err := http.PostForm(OidcReqTokenURL, url.Values{ + httpResp, err := httpClient.PostForm(OidcReqTokenURL, url.Values{ "grant_type": {"password"}, "client_id": {util.OidcClientID}, "username": {username}, From 6685a5f474be3cb382ba279cc8b95d49e86988b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Thu, 20 Jun 2019 11:05:52 +0200 Subject: [PATCH 29/41] timers: make implementation functional --- medco/client/client.go | 7 +- medco/client/query_result.go | 11 +- medco/picsure2_api_handlers.go | 11 ++ medco/query_logic.go | 49 ++++++-- restapi/models/query_result_element.go | 68 +++++++++++ restapi/server/embedded_spec.go | 30 +++++ swagger/medco-connector-server.yml | 10 ++ unlynx/client_distributed.go | 152 ++++++++++++++----------- 8 files changed, 257 insertions(+), 81 deletions(-) diff --git a/medco/client/client.go b/medco/client/client.go index 7b347390..ca6df5c5 100644 --- a/medco/client/client.go +++ b/medco/client/client.go @@ -14,6 +14,7 @@ import ( "os" "strconv" "strings" + "time" ) // ExecuteClientQuery execute and display the results of the MedCo client query @@ -41,6 +42,9 @@ func ExecuteClientQuery(token, username, password, queryType, queryString, resul // parse query string panelsItemKeys, panelsIsNot, err := parseQueryString(queryString) + if err != nil { + return + } // encrypt the item keys encPanelsItemKeys := make([][]string, 0) @@ -112,7 +116,8 @@ func printResultsCSV(nodesResult map[string]*QueryResult, output io.Writer) (err timerName := csvHeaders[timerNameIdx] timerValue := nodesResult[nodeName].Times[timerName] - csvNodesResults[csvNodeResultsIdx] = append(csvNodesResults[csvNodeResultsIdx], timerValue) + csvNodesResults[csvNodeResultsIdx] = append(csvNodesResults[csvNodeResultsIdx], + strconv.FormatInt(int64(timerValue / time.Millisecond), 10)) } } diff --git a/medco/client/query_result.go b/medco/client/query_result.go index 96e881d4..3125788c 100644 --- a/medco/client/query_result.go +++ b/medco/client/query_result.go @@ -4,18 +4,21 @@ import ( "github.com/lca1/medco-connector/restapi/models" "github.com/lca1/medco-connector/unlynx" "github.com/sirupsen/logrus" + "time" ) // QueryResult contains the decrypted results of a node type QueryResult struct { Count int64 PatientList []int64 - Times map[string]string + Times map[string]time.Duration } // newQueryResult parses a query result from a node and decrypts its fields func newQueryResult(nodeResult *models.QueryResultElement, privateKey string) (parsedResult *QueryResult, err error) { - parsedResult = &QueryResult{} + parsedResult = &QueryResult{ + Times: make( map[string]time.Duration), + } // decrypt count parsedResult.Count, err = unlynx.Decrypt(nodeResult.EncryptedCount, privateKey) @@ -38,7 +41,9 @@ func newQueryResult(nodeResult *models.QueryResultElement, privateKey string) (p } // parse times - // todo: nodeResult. + for _, timer := range nodeResult.Timers { + parsedResult.Times[timer.Name] = time.Duration(timer.Milliseconds) * time.Millisecond + } logrus.Info("Node result: count=", parsedResult.Count, ", # patient IDs decrypted=", len(nodeResult.EncryptedPatientList), ", # non dummy patients=", len(parsedResult.PatientList)) diff --git a/medco/picsure2_api_handlers.go b/medco/picsure2_api_handlers.go index 4273db49..51520cb2 100644 --- a/medco/picsure2_api_handlers.go +++ b/medco/picsure2_api_handlers.go @@ -6,6 +6,7 @@ import( "github.com/lca1/medco-connector/restapi/models" "github.com/lca1/medco-connector/restapi/server/operations/picsure2" "github.com/lca1/medco-connector/util" + "time" ) // GetInfoHandlerFunc handles /info API endpoint @@ -98,10 +99,20 @@ func QuerySyncHandlerFunc(params picsure2.QuerySyncParams, principal *models.Use }) } + // parse timers + timers := make([]*models.QueryResultElementTimersItems0, 0) + for timerName, timerDuration := range query.queryResult.timers { + timers = append(timers, &models.QueryResultElementTimersItems0{ + Name: timerName, + Milliseconds: int64(timerDuration / time.Millisecond), + }) + } + return picsure2.NewQuerySyncOK().WithPayload(&models.QueryResultElement{ QueryType: query.query.QueryType, EncryptedCount: query.queryResult.encCount, EncryptionKey: query.query.UserPublicKey, EncryptedPatientList: query.queryResult.encPatientList, + Timers: timers, }) } diff --git a/medco/query_logic.go b/medco/query_logic.go index b0a1fd45..006db5e9 100644 --- a/medco/query_logic.go +++ b/medco/query_logic.go @@ -7,11 +7,10 @@ import ( "github.com/pkg/errors" "github.com/sirupsen/logrus" "strconv" + "time" ) -// todo: timers // todo: log query (with associated status) -// todo: query type obfuscated (DP) // todo: put user + query type + unique ID in query name // I2b2MedCoQuery represents an i2b2-MedCo query to be executed @@ -21,6 +20,7 @@ type I2b2MedCoQuery struct { queryResult struct { encCount string encPatientList []string + timers map[string]time.Duration } } @@ -30,13 +30,29 @@ func NewI2b2MedCoQuery(queryName string, query *models.QueryI2b2Medco) (new I2b2 name: queryName, query: query, } + new.queryResult.timers = make(map[string]time.Duration) return new, new.isValid() } +// addTimers adds timers to the query results +func (q *I2b2MedCoQuery) addTimers(timerName string, since time.Time, additionalTimers map[string]time.Duration) { + if timerName != "" { + q.queryResult.timers[timerName] = time.Since(since) + } + + if additionalTimers != nil { + for k, v := range additionalTimers { + q.queryResult.timers[k] = v + } + } +} + // Execute implements the I2b2 MedCo query logic func (q *I2b2MedCoQuery) Execute(queryType I2b2MedCoQueryType) (err error) { + overallTimer := time.Now() + var timer time.Time + // todo: breakdown in i2b2 / count / patient list - // todo: implement obfuscation err = q.isValid() if err != nil { @@ -44,13 +60,16 @@ func (q *I2b2MedCoQuery) Execute(queryType I2b2MedCoQueryType) (err error) { } // tag query terms - taggedQueryTerms, err := unlynx.DDTagValues(q.name, q.getEncQueryTerms()) + timer = time.Now() + taggedQueryTerms, ddtTimers, err := unlynx.DDTagValues(q.name, q.getEncQueryTerms()) if err != nil { return } + q.addTimers("medco-connector-DDT", timer, ddtTimers) logrus.Info(q.name, ": tagged ", len(taggedQueryTerms), " elements with unlynx") // i2b2 PSM query with tagged items + timer = time.Now() panelsItemKeys, panelsIsNot, err := q.getI2b2PsmQueryTerms(taggedQueryTerms) if err != nil { return @@ -60,59 +79,71 @@ func (q *I2b2MedCoQuery) Execute(queryType I2b2MedCoQueryType) (err error) { if err != nil { return } + q.addTimers("medco-connector-i2b2-PSM", timer, nil) logrus.Info(q.name, ": got ", patientCount, " in patient set ", patientSetID, " with i2b2") // i2b2 PDO query to get the dummy flags + timer = time.Now() patientIDs, patientDummyFlags, err := i2b2.GetPatientSet(patientSetID) if err != nil { return } + q.addTimers("medco-connector-i2b2-PDO", timer, nil) logrus.Info(q.name, ": got ", len(patientIDs), " patient IDs and ", len(patientDummyFlags), " dummy flags with i2b2") // aggregate patient dummy flags + timer = time.Now() aggPatientFlags, err := unlynx.LocallyAggregateValues(patientDummyFlags) if err != nil { return } + q.addTimers("medco-connector-local-agg", timer, nil) // compute and key switch count (returns optionally global aggregate or shuffled results) + timer = time.Now() var encCount string + var ksCountTimers map[string]time.Duration if queryType.CountType == Global { logrus.Info(q.name, ": global aggregate requested") - encCount, err = unlynx.AggregateAndKeySwitchValue(q.name, aggPatientFlags, q.query.UserPublicKey) + encCount, ksCountTimers, err = unlynx.AggregateAndKeySwitchValue(q.name, aggPatientFlags, q.query.UserPublicKey) } else if queryType.Shuffled { logrus.Info(q.name, ": count per site requested, shuffle enabled") - encCount, err = unlynx.ShuffleAndKeySwitchValue(q.name, aggPatientFlags, q.query.UserPublicKey) + encCount, ksCountTimers, err = unlynx.ShuffleAndKeySwitchValue(q.name, aggPatientFlags, q.query.UserPublicKey) } else { logrus.Info(q.name, ": count per site requested, shuffle disabled") - encCount, err = unlynx.KeySwitchValue(q.name, aggPatientFlags, q.query.UserPublicKey) + encCount, ksCountTimers, err = unlynx.KeySwitchValue(q.name, aggPatientFlags, q.query.UserPublicKey) } if err != nil { return } q.queryResult.encCount = encCount - logrus.Info(q.name, ": key switched count") // optionally prepare the patient list if queryType.PatientList { logrus.Info(q.name, ": patient list requested") // mask patient IDs + timer = time.Now() maskedPatientIDs, err := q.maskPatientIDs(patientIDs, patientDummyFlags) if err != nil { return err } + logrus.Info(q.name, ": masked ", len(maskedPatientIDs), " patient IDs") + q.addTimers("medco-connector-local-patient-list-masking", timer, nil) // key switch the masked patient IDs - ksMaskedPatientIDs, err := unlynx.KeySwitchValues(q.name, maskedPatientIDs, q.query.UserPublicKey) + timer = time.Now() + ksMaskedPatientIDs, ksPatientListTimers, err := unlynx.KeySwitchValues(q.name, maskedPatientIDs, q.query.UserPublicKey) if err != nil { return err } + q.addTimers("medco-connector-unlynx-key-switch-patient-list", timer, ksPatientListTimers) q.queryResult.encPatientList = ksMaskedPatientIDs logrus.Info(q.name, ": key switched patient IDs") } + q.addTimers("medco-connector-overall", overallTimer, nil) return } diff --git a/restapi/models/query_result_element.go b/restapi/models/query_result_element.go index a547b3ca..395c807f 100644 --- a/restapi/models/query_result_element.go +++ b/restapi/models/query_result_element.go @@ -6,6 +6,8 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "strconv" + strfmt "github.com/go-openapi/strfmt" "github.com/go-openapi/errors" @@ -27,6 +29,9 @@ type QueryResultElement struct { // query type QueryType QueryType `json:"queryType,omitempty"` + + // timers + Timers []*QueryResultElementTimersItems0 `json:"timers"` } // Validate validates this query result element @@ -37,6 +42,10 @@ func (m *QueryResultElement) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateTimers(formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -59,6 +68,31 @@ func (m *QueryResultElement) validateQueryType(formats strfmt.Registry) error { return nil } +func (m *QueryResultElement) validateTimers(formats strfmt.Registry) error { + + if swag.IsZero(m.Timers) { // not required + return nil + } + + for i := 0; i < len(m.Timers); i++ { + if swag.IsZero(m.Timers[i]) { // not required + continue + } + + if m.Timers[i] != nil { + if err := m.Timers[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("timers" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + // MarshalBinary interface implementation func (m *QueryResultElement) MarshalBinary() ([]byte, error) { if m == nil { @@ -76,3 +110,37 @@ func (m *QueryResultElement) UnmarshalBinary(b []byte) error { *m = res return nil } + +// QueryResultElementTimersItems0 query result element timers items0 +// swagger:model QueryResultElementTimersItems0 +type QueryResultElementTimersItems0 struct { + + // milliseconds + Milliseconds int64 `json:"milliseconds,omitempty"` + + // name + Name string `json:"name,omitempty"` +} + +// Validate validates this query result element timers items0 +func (m *QueryResultElementTimersItems0) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *QueryResultElementTimersItems0) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *QueryResultElementTimersItems0) UnmarshalBinary(b []byte) error { + var res QueryResultElementTimersItems0 + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/restapi/server/embedded_spec.go b/restapi/server/embedded_spec.go index 51f3c504..92dbb01d 100644 --- a/restapi/server/embedded_spec.go +++ b/restapi/server/embedded_spec.go @@ -398,6 +398,21 @@ func init() { }, "queryType": { "$ref": "#/definitions/queryType" + }, + "timers": { + "type": "array", + "items": { + "type": "object", + "properties": { + "milliseconds": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + } + } + } } } }, @@ -1157,6 +1172,21 @@ func init() { }, "queryType": { "$ref": "#/definitions/queryType" + }, + "timers": { + "type": "array", + "items": { + "type": "object", + "properties": { + "milliseconds": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + } + } + } } } }, diff --git a/swagger/medco-connector-server.yml b/swagger/medco-connector-server.yml index d3e5f0aa..b9493f14 100644 --- a/swagger/medco-connector-server.yml +++ b/swagger/medco-connector-server.yml @@ -396,6 +396,16 @@ definitions: type: "array" items: type: "string" + timers: + type: "array" + items: + type: "object" + properties: + name: + type: "string" + milliseconds: + type: "integer" + format: "int64" queryStatus: type: "object" diff --git a/unlynx/client_distributed.go b/unlynx/client_distributed.go index f62f9343..40f0dbe5 100644 --- a/unlynx/client_distributed.go +++ b/unlynx/client_distributed.go @@ -10,14 +10,8 @@ import ( "time" ) -// todo: get time measurements in all functions -// tr.DDTRequestTimeCommunication = totalTime - tr.DDTRequestTimeExec -// tr.DDTParsingTime = parsingTime -// tr.DDTRequestTimeExec += tr.DDTParsingTime -// totalTime = around request - // DDTagValues makes request through unlynx to compute distributed deterministic tags of encrypted values -func DDTagValues(queryName string, values []string) (taggedValues map[string]string, err error) { +func DDTagValues(queryName string, values []string) (taggedValues map[string]string, times map[string]time.Duration, err error) { unlynxClient, cothorityRoster := newUnlynxClient() // deserialize values @@ -27,34 +21,41 @@ func DDTagValues(queryName string, values []string) (taggedValues map[string]str } // execute DDT - ddtResultsChan := make(chan []libunlynx.GroupingKey) - ddtErrChan := make(chan error) + type DDTResults struct { + Results []libunlynx.GroupingKey + Times servicesmedco.TimeResults + Err error + } + ddtResultsChan := make(chan DDTResults) + go func() { - _, ddtResults, _, ddtErr := unlynxClient.SendSurveyDDTRequestTerms( + _, ddtResults, ddtTimes, ddtErr := unlynxClient.SendSurveyDDTRequestTerms( cothorityRoster, servicesmedco.SurveyID(queryName + "_DDT"), desValues, false, false, ) - if ddtErr != nil { - ddtErrChan <- ddtErr - } else if len(ddtResults) == 0 || len(ddtResults) != len(values) { - ddtErrChan <- errors.New("unlynx inconsistent DDT results: #results=" + strconv.Itoa(len(ddtResults)) + ", #terms=" + strconv.Itoa(len(values))) - } else { - ddtResultsChan <- ddtResults - } + ddtResultsChan <- DDTResults{ddtResults, ddtTimes, ddtErr} }() select { case ddtResults := <-ddtResultsChan: - taggedValues = make(map[string]string) - for i, result := range ddtResults { - taggedValues[values[i]] = string(result) - } + err = ddtResults.Err + if err != nil { + logrus.Error("unlynx error executing DDT: ", err) + + } else if len(ddtResults.Results) == 0 || len(ddtResults.Results) != len(values) { + err = errors.New("unlynx inconsistent DDT results: #results=" + strconv.Itoa(len(ddtResults.Results)) + + ", #terms=" + strconv.Itoa(len(values))) - case err = <-ddtErrChan: - logrus.Error("unlynx error executing DDT: ", err) + } else { + times = ddtResults.Times.MapTR + taggedValues = make(map[string]string) + for i, result := range ddtResults.Results { + taggedValues[values[i]] = string(result) + } + } case <-time.After(time.Duration(util.UnlynxTimeoutSeconds) * time.Second): err = errors.New("unlynx timeout") @@ -64,13 +65,13 @@ func DDTagValues(queryName string, values []string) (taggedValues map[string]str } // KeySwitchValue makes request through unlynx to key switch a single encrypted value (convenience function) -func KeySwitchValue(queryName string, value string, targetPubKey string) (string, error) { - results, err := KeySwitchValues(queryName, []string{value}, targetPubKey) - return results[0], err +func KeySwitchValue(queryName string, value string, targetPubKey string) (string, map[string]time.Duration, error) { + results, times, err := KeySwitchValues(queryName, []string{value}, targetPubKey) + return results[0], times, err } // KeySwitchValues makes request through unlynx to key switch encrypted values -func KeySwitchValues(queryName string, values []string, targetPubKey string) (keySwitchedValues []string, err error) { +func KeySwitchValues(queryName string, values []string, targetPubKey string) (keySwitchedValues []string, times map[string]time.Duration, err error) { unlynxClient, cothorityRoster := newUnlynxClient() // deserialize values and target public key @@ -86,32 +87,37 @@ func KeySwitchValues(queryName string, values []string, targetPubKey string) (ke } // execute key switching request - ksResultsChan := make(chan libunlynx.CipherVector) - ksErrChan := make(chan error) + type KSResults struct { + Results libunlynx.CipherVector + Times servicesmedco.TimeResults + Err error + } + ksResultsChan := make(chan KSResults) + go func() { - _, ksResult, _, ksErr := unlynxClient.SendSurveyKSRequest( + _, ksResult, ksTimes, ksErr := unlynxClient.SendSurveyKSRequest( cothorityRoster, servicesmedco.SurveyID(queryName + "_KS"), desTargetKey, desValues, false, ) - if ksErr != nil { - ksErrChan <- ksErr - } else { - ksResultsChan <- ksResult - } + ksResultsChan <- KSResults{ksResult, ksTimes, ksErr} }() select { case ksResult := <-ksResultsChan: - keySwitchedValues, err = serializeCipherVector(ksResult) + err = ksResult.Err if err != nil { - logrus.Error("unlynx error serializing: ", err) - } + logrus.Error("unlynx error executing key switching: ", err) - case err = <-ksErrChan: - logrus.Error("unlynx error executing key switching: ", err) + } else { + times = ksResult.Times.MapTR + keySwitchedValues, err = serializeCipherVector(ksResult.Results) + if err != nil { + logrus.Error("unlynx error serializing: ", err) + } + } case <-time.After(time.Duration(util.UnlynxTimeoutSeconds) * time.Second): err = errors.New("unlynx timeout") @@ -121,7 +127,7 @@ func KeySwitchValues(queryName string, values []string, targetPubKey string) (ke } // ShuffleAndKeySwitchValue makes request through unlynx to shuffle and key switch one value per node -func ShuffleAndKeySwitchValue(queryName string, value string, targetPubKey string) (shuffledKsValue string, err error) { +func ShuffleAndKeySwitchValue(queryName string, value string, targetPubKey string) (shuffledKsValue string, times map[string]time.Duration, err error) { unlynxClient, cothorityRoster := newUnlynxClient() // deserialize value and target public key @@ -138,32 +144,37 @@ func ShuffleAndKeySwitchValue(queryName string, value string, targetPubKey strin } // execute shuffle and key switching request - shuffleKsResultsChan := make(chan libunlynx.CipherText) - shuffleKsErrChan := make(chan error) + type ShuffleKSResults struct { + Results libunlynx.CipherText + Times servicesmedco.TimeResults + Err error + } + shuffleKsResultsChan := make(chan ShuffleKSResults) + go func() { - _, shuffleKsResult, _, shuffleKsErr := unlynxClient.SendSurveyShuffleRequest( + _, shuffleKsResult, shuffleKsTimes, shuffleKsErr := unlynxClient.SendSurveyShuffleRequest( cothorityRoster, servicesmedco.SurveyID(queryName + "_SHUFFLE"), desTargetKey, desValue, false, ) - if shuffleKsErr != nil { - shuffleKsErrChan <- shuffleKsErr - } else { - shuffleKsResultsChan <- shuffleKsResult - } + shuffleKsResultsChan <- ShuffleKSResults{shuffleKsResult, shuffleKsTimes, shuffleKsErr} }() select { case shuffleKsResult := <-shuffleKsResultsChan: - shuffledKsValue, err = shuffleKsResult.Serialize() + err = shuffleKsResult.Err if err != nil { - logrus.Error("unlynx error serializing: ", err) - } + logrus.Error("unlynx error executing shuffle and key switching: ", err) - case err = <-shuffleKsErrChan: - logrus.Error("unlynx error executing shuffle and key switching: ", err) + } else { + times = shuffleKsResult.Times.MapTR + shuffledKsValue, err = shuffleKsResult.Results.Serialize() + if err != nil { + logrus.Error("unlynx error serializing: ", err) + } + } case <-time.After(time.Duration(util.UnlynxTimeoutSeconds) * time.Second): err = errors.New("unlynx timeout") @@ -173,7 +184,7 @@ func ShuffleAndKeySwitchValue(queryName string, value string, targetPubKey strin } // AggregateAndKeySwitchValue makes request through unlynx to aggregate and key switch one value per node -func AggregateAndKeySwitchValue(queryName string, value string, targetPubKey string) (aggValue string, err error) { +func AggregateAndKeySwitchValue(queryName string, value string, targetPubKey string) (aggValue string, times map[string]time.Duration, err error) { unlynxClient, cothorityRoster := newUnlynxClient() // deserialize value and target public key @@ -190,32 +201,37 @@ func AggregateAndKeySwitchValue(queryName string, value string, targetPubKey str } // execute shuffle and key switching request - aggKsResultsChan := make(chan libunlynx.CipherText) - aggKsErrChan := make(chan error) + type AggKSResults struct { + Results libunlynx.CipherText + Times servicesmedco.TimeResults + Err error + } + aggKsResultsChan := make(chan AggKSResults) + go func() { - _, aggKsResult, _, aggKsErr := unlynxClient.SendSurveyAggRequest( + _, aggKsResult, aggKsTimes, aggKsErr := unlynxClient.SendSurveyAggRequest( cothorityRoster, servicesmedco.SurveyID(queryName + "_AGG"), desTargetKey, desValue, false, ) - if aggKsErr != nil { - aggKsErrChan <- aggKsErr - } else { - aggKsResultsChan <- aggKsResult - } + aggKsResultsChan <- AggKSResults{aggKsResult, aggKsTimes, aggKsErr} }() select { case aggKsResult := <-aggKsResultsChan: - aggValue, err = aggKsResult.Serialize() + err = aggKsResult.Err if err != nil { - logrus.Error("unlynx error serializing: ", err) - } + logrus.Error("unlynx error executing aggregate and key switching: ", err) - case err = <-aggKsErrChan: - logrus.Error("unlynx error executing aggregate and key switching: ", err) + } else { + times = aggKsResult.Times.MapTR + aggValue, err = aggKsResult.Results.Serialize() + if err != nil { + logrus.Error("unlynx error serializing: ", err) + } + } case <-time.After(time.Duration(util.UnlynxTimeoutSeconds) * time.Second): err = errors.New("unlynx timeout") From c2086287383e520e333ead863418ec6733bdf7b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Thu, 20 Jun 2019 11:06:27 +0200 Subject: [PATCH 30/41] bug fix: matching of resource name and UUID wrong due to data race --- medco/client/query.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/medco/client/query.go b/medco/client/query.go index 7d3cb5d2..9025a6a0 100644 --- a/medco/client/query.go +++ b/medco/client/query.go @@ -82,9 +82,10 @@ func (clientQuery *Query) Execute() (nodesResult map [string]*QueryResult, err e // execute requests on all nodes for idx := range clientQuery.picsureResourceUUIDs { + idxLocal := idx go func() { - queryResult, err := clientQuery.submitToNode(idx) + queryResult, err := clientQuery.submitToNode(idxLocal) if err != nil { queryErrChan <- err } else { @@ -163,6 +164,7 @@ func (clientQuery *Query) loadResourceUUIDs() (err error) { // submitToNode sends a query to a node of the network, from the list of PIC-SURE resources func (clientQuery *Query) submitToNode(picsureResourceUUIDIdx int) (result *models.QueryResultElement, err error) { + logrus.Debug("Submitting query to resource ", clientQuery.picsureResourceNames[picsureResourceUUIDIdx]) queryParams := picsure2.NewQuerySyncParamsWithTimeout(time.Duration(utilclient.QueryTimeoutSeconds) * time.Second) queryParams.Body = picsure2.QuerySyncBody{ From f4e000f01bebd8e6c35b2c08bc5aafde3db7ea06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Thu, 20 Jun 2019 11:07:42 +0200 Subject: [PATCH 31/41] add query type implementation: locally obfuscated --- deployment/Dockerfile | 3 ++- deployment/docker-compose.yml | 1 + go.sum | 1 + medco/query_logic.go | 14 ++++++++++++++ unlynx/client_local.go | 30 +++++++++++++++++++++++++++++- util/configuration.go | 13 ++++++++++++- 6 files changed, 59 insertions(+), 3 deletions(-) diff --git a/deployment/Dockerfile b/deployment/Dockerfile index ad0199cd..1d8a1f4f 100644 --- a/deployment/Dockerfile +++ b/deployment/Dockerfile @@ -31,7 +31,8 @@ ENV I2B2_HIVE_URL=http://i2b2:8080/i2b2/services \ JWKS_URL=http://keycloak:8080/auth/realms/master/protocol/openid-connect/certs \ OIDC_JWT_ISSUER=http://keycloak:8080/auth/realms/master \ OIDC_CLIENT_ID=medco \ - OIDC_JWT_USER_ID_CLAIM=preferred_username + OIDC_JWT_USER_ID_CLAIM=preferred_username \ + MEDCO_OBFUSCATION_MIN_VARIANCE=5 EXPOSE 1999 ENTRYPOINT ["docker-entrypoint.sh", "medco-connector-server"] diff --git a/deployment/docker-compose.yml b/deployment/docker-compose.yml index 661aeb11..af285c01 100644 --- a/deployment/docker-compose.yml +++ b/deployment/docker-compose.yml @@ -20,6 +20,7 @@ services: - OIDC_JWT_ISSUER=http://keycloak:8080/auth/realms/master - OIDC_CLIENT_ID=medco - OIDC_JWT_USER_ID_CLAIM=preferred_username + - MEDCO_OBFUSCATION_MIN_VARIANCE=5 volumes: - ./configuration-profile:/medco-configuration diff --git a/go.sum b/go.sum index 96e626e6..4f768401 100644 --- a/go.sum +++ b/go.sum @@ -136,6 +136,7 @@ github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/r0fls/gostats v0.0.0-20180711082619-e793b1fda35c h1:bqGSZMgWQ18OL1dqT8UGHlHe4w+EKFWc2Ak6DFbL1Pw= github.com/r0fls/gostats v0.0.0-20180711082619-e793b1fda35c/go.mod h1:2mJY7Hx2k1GaMAmiAoyy090oY3RTSk3kkaaTieLq7wc= github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= diff --git a/medco/query_logic.go b/medco/query_logic.go index 006db5e9..4065524e 100644 --- a/medco/query_logic.go +++ b/medco/query_logic.go @@ -116,6 +116,20 @@ func (q *I2b2MedCoQuery) Execute(queryType I2b2MedCoQueryType) (err error) { if err != nil { return } + q.addTimers("medco-connector-unlynx-key-switch-count", timer, ksCountTimers) + + // optionally obfuscate the count + if queryType.Obfuscated { + logrus.Info(q.name, ": (local) obfuscation requested") + timer = time.Now() + encCount, err = unlynx.LocallyObfuscateValue(encCount, 4) // todo: fixed distribution to make dynamic + if err != nil { + return + } + q.addTimers("medco-connector-local-obfuscation", timer, nil) + } + + logrus.Info(q.name, ": processed count") q.queryResult.encCount = encCount // optionally prepare the patient list diff --git a/unlynx/client_local.go b/unlynx/client_local.go index 61f6b3a6..c2bf7a8f 100644 --- a/unlynx/client_local.go +++ b/unlynx/client_local.go @@ -1,7 +1,9 @@ package unlynx import ( + "github.com/lca1/medco-connector/util" libunlynx "github.com/lca1/unlynx/lib" + stats "github.com/r0fls/gostats" "github.com/sirupsen/logrus" ) @@ -52,6 +54,32 @@ func LocallyMultiplyScalar(encValue string, scalar int64) (res string, err error return } +// LocallyObfuscateValue adds random noise homomorphically to an encrypted value +func LocallyObfuscateValue(encValue string, obfuscationVariance int) (res string, err error) { + + if obfuscationVariance < util.MedCoObfuscationMinVariance { + obfuscationVariance = util.MedCoObfuscationMinVariance + logrus.Info("Obfuscation variance set to the minimum of ", obfuscationVariance) + } + + distribution := stats.Laplace(0, float64(obfuscationVariance)) + noise := distribution.Random() + + // encrypt the noise + encNoise, err := EncryptWithCothorityKey(int64(noise)) + if err != nil { + return + } + + // add together value and noise + res, err = LocallyAggregateValues([]string{encValue, encNoise}) + if err != nil { + return + } + + return +} + // EncryptWithCothorityKey encrypts an integer with the public key of the cothority func EncryptWithCothorityKey(value int64) (encrypted string, err error) { _, cothorityRoster := newUnlynxClient() @@ -98,4 +126,4 @@ func GenerateKeyPair() (pubKey string, privKey string, err error) { } return -} \ No newline at end of file +} diff --git a/util/configuration.go b/util/configuration.go index af919d2b..07835048 100644 --- a/util/configuration.go +++ b/util/configuration.go @@ -42,6 +42,8 @@ var OidcClientID string // OidcJwtUserIDClaim is the JWT claim containing the user ID var OidcJwtUserIDClaim string +// MedCoObfuscationMinVariance is the minimum variance passed to the random distribution for the obfuscation +var MedCoObfuscationMinVariance int func init() { SetLogLevel(os.Getenv("LOG_LEVEL")) @@ -50,8 +52,9 @@ func init() { UnlynxTimeoutSeconds = 3 * 60 // 3 minutes idx, err := strconv.ParseInt(os.Getenv("UNLYNX_GROUP_FILE_IDX"), 10, 64) - if err != nil || UnlynxGroupFileIdx < 0 { + if err != nil || idx < 0 { logrus.Warn("invalid UnlynxGroupFileIdx") + idx = 0 } UnlynxGroupFileIdx = int(idx) @@ -67,6 +70,14 @@ func init() { OidcJwtIssuer = os.Getenv("OIDC_JWT_ISSUER") OidcClientID = os.Getenv("OIDC_CLIENT_ID") OidcJwtUserIDClaim = os.Getenv("OIDC_JWT_USER_ID_CLAIM") + + obf, err := strconv.ParseInt(os.Getenv("MEDCO_OBFUSCATION_MIN_VARIANCE"), 10, 64) + if err != nil || obf < 0 { + logrus.Warn("invalid MedCoObfuscationMinVariance, defaulted") + obf = 5 + } + MedCoObfuscationMinVariance = int(obf) + } // SetLogLevel initializes the log levels of all loggers From 121eb260f55b790280fb3ceb53b77a3ce378a861 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Tue, 25 Jun 2019 17:01:32 +0200 Subject: [PATCH 32/41] add implementation of authorizations --- util/security.go | 80 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 70 insertions(+), 10 deletions(-) diff --git a/util/security.go b/util/security.go index 1e41247f..d7265086 100644 --- a/util/security.go +++ b/util/security.go @@ -62,18 +62,78 @@ func AuthorizeUser(credentials models.ResourceCredentials, user *models.User) (e } // extract user authorizations - // todo: implement the extraction + authorizedQueryTypes, err := extractAuthorizationsFromToken(&token) + if err != nil { + return + } + logrus.Info("User ", user.ID, " has authorizations for ", len(authorizedQueryTypes), " query types") + user.Authorizations = &models.UserAuthorizations{ - QueryType: []models.QueryType{ - models.QueryTypePatientList, - models.QueryTypeCountPerSite, - models.QueryTypeCountPerSiteObfuscated, - models.QueryTypeCountPerSiteShuffled, - models.QueryTypeCountPerSiteShuffledObfuscated, - models.QueryTypeCountGlobal, - models.QueryTypeCountGlobalObfuscated, - }, + QueryType: authorizedQueryTypes, + } + return +} + +// extractAuthorizationsFromToken parsed the token to extract the user's authorizations +func extractAuthorizationsFromToken(token *jwt.Token) (queryTypes []models.QueryType, err error) { + + // retrieve roles, within the keycloak pre-determined structure (this is ugly) + var extractedRoles []string + if tokenResourceAccess, ok := token.Get("resource_access"); ok { + logrus.Trace("1 OK") + if tokenResourceAccessTyped, ok := tokenResourceAccess.(map[string]interface{}); ok { + logrus.Trace("2 OK") + if clientId, ok := tokenResourceAccessTyped[OidcClientID]; ok { + logrus.Trace("3 OK") + if clientIdTyped, ok := clientId.(map[string]interface{}); ok { + logrus.Trace("4 OK") + if roles, ok := clientIdTyped["roles"]; ok { + logrus.Trace("5 OK") + if extractedRolesUntyped, ok := roles.([]interface{}); ok { + logrus.Trace("6 OK") + for _, extractedRoleUntyped := range extractedRolesUntyped { + if extractedRole, ok := extractedRoleUntyped.(string); ok { + extractedRoles = append(extractedRoles, extractedRole) + } else { + logrus.Warn("could not parse authorization", extractedRole) + } + } + } + } + } + } + } } + + if len(extractedRoles) == 0 { + err = errors.New("error retrieving roles from token, or user has no authorizations") + logrus.Error(err) + return + } + + // match roles to query types + for _, extractedRole := range extractedRoles { + switch string(extractedRole) { + case string(models.QueryTypePatientList): + queryTypes = append(queryTypes, models.QueryTypePatientList) + case string(models.QueryTypeCountPerSite): + queryTypes = append(queryTypes, models.QueryTypeCountPerSite) + case string(models.QueryTypeCountPerSiteObfuscated): + queryTypes = append(queryTypes, models.QueryTypeCountPerSiteObfuscated) + case string(models.QueryTypeCountPerSiteShuffled): + queryTypes = append(queryTypes, models.QueryTypeCountPerSiteShuffled) + case string(models.QueryTypeCountPerSiteShuffledObfuscated): + queryTypes = append(queryTypes, models.QueryTypeCountPerSiteShuffledObfuscated) + case string(models.QueryTypeCountGlobal): + queryTypes = append(queryTypes, models.QueryTypeCountGlobal) + case string(models.QueryTypeCountGlobalObfuscated): + queryTypes = append(queryTypes, models.QueryTypeCountGlobalObfuscated) + + default: + logrus.Debug("ignored role ", extractedRole) + } + } + return } From 8bd284cacff0c337b876cc70f81aadcf3e807fa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Tue, 25 Jun 2019 17:06:15 +0200 Subject: [PATCH 33/41] fix local obfuscation --- deployment/Dockerfile | 2 +- deployment/docker-compose.yml | 2 +- medco/query_logic.go | 2 +- unlynx/client_local.go | 34 ++++++++++++++++++++++------------ util/configuration.go | 10 +++++----- 5 files changed, 30 insertions(+), 20 deletions(-) diff --git a/deployment/Dockerfile b/deployment/Dockerfile index 1d8a1f4f..9d9b8641 100644 --- a/deployment/Dockerfile +++ b/deployment/Dockerfile @@ -32,7 +32,7 @@ ENV I2B2_HIVE_URL=http://i2b2:8080/i2b2/services \ OIDC_JWT_ISSUER=http://keycloak:8080/auth/realms/master \ OIDC_CLIENT_ID=medco \ OIDC_JWT_USER_ID_CLAIM=preferred_username \ - MEDCO_OBFUSCATION_MIN_VARIANCE=5 + MEDCO_OBFUSCATION_MIN=5 EXPOSE 1999 ENTRYPOINT ["docker-entrypoint.sh", "medco-connector-server"] diff --git a/deployment/docker-compose.yml b/deployment/docker-compose.yml index af285c01..581cf422 100644 --- a/deployment/docker-compose.yml +++ b/deployment/docker-compose.yml @@ -20,7 +20,7 @@ services: - OIDC_JWT_ISSUER=http://keycloak:8080/auth/realms/master - OIDC_CLIENT_ID=medco - OIDC_JWT_USER_ID_CLAIM=preferred_username - - MEDCO_OBFUSCATION_MIN_VARIANCE=5 + - MEDCO_OBFUSCATION_MIN=5 volumes: - ./configuration-profile:/medco-configuration diff --git a/medco/query_logic.go b/medco/query_logic.go index 4065524e..f8ad9826 100644 --- a/medco/query_logic.go +++ b/medco/query_logic.go @@ -122,7 +122,7 @@ func (q *I2b2MedCoQuery) Execute(queryType I2b2MedCoQueryType) (err error) { if queryType.Obfuscated { logrus.Info(q.name, ": (local) obfuscation requested") timer = time.Now() - encCount, err = unlynx.LocallyObfuscateValue(encCount, 4) // todo: fixed distribution to make dynamic + encCount, err = unlynx.LocallyObfuscateValue(encCount, 5, q.query.UserPublicKey) // todo: fixed distribution to make dynamic if err != nil { return } diff --git a/unlynx/client_local.go b/unlynx/client_local.go index c2bf7a8f..82762024 100644 --- a/unlynx/client_local.go +++ b/unlynx/client_local.go @@ -55,29 +55,24 @@ func LocallyMultiplyScalar(encValue string, scalar int64) (res string, err error } // LocallyObfuscateValue adds random noise homomorphically to an encrypted value -func LocallyObfuscateValue(encValue string, obfuscationVariance int) (res string, err error) { +func LocallyObfuscateValue(encValue string, obfuscationParam int, pubKey string) (res string, err error) { - if obfuscationVariance < util.MedCoObfuscationMinVariance { - obfuscationVariance = util.MedCoObfuscationMinVariance - logrus.Info("Obfuscation variance set to the minimum of ", obfuscationVariance) + if obfuscationParam < util.MedCoObfuscationMin { + obfuscationParam = util.MedCoObfuscationMin + logrus.Info("Obfuscation variance set to the minimum of ", obfuscationParam) } - distribution := stats.Laplace(0, float64(obfuscationVariance)) + distribution := stats.Laplace(0, float64(obfuscationParam)) noise := distribution.Random() // encrypt the noise - encNoise, err := EncryptWithCothorityKey(int64(noise)) + encNoise, err := Encrypt(int64(noise), pubKey) if err != nil { return } // add together value and noise - res, err = LocallyAggregateValues([]string{encValue, encNoise}) - if err != nil { - return - } - - return + return LocallyAggregateValues([]string{encValue, encNoise}) } // EncryptWithCothorityKey encrypts an integer with the public key of the cothority @@ -90,6 +85,21 @@ func EncryptWithCothorityKey(value int64) (encrypted string, err error) { return } +// Encrypt encrypts an integer with a public key +func Encrypt(value int64, pubKey string) (encrypted string, err error) { + pubKeyDes, err := libunlynx.DeserializePoint(pubKey) + if err != nil { + logrus.Error("unlynx failed deserializing public key: ", err) + return + } + + encrypted, err = libunlynx.EncryptInt(pubKeyDes, value).Serialize() + if err != nil { + logrus.Error("unlynx failed serializing encrypted value: ", err) + } + return +} + // Decrypt decrypts an integer with a private key func Decrypt(value string, privKey string) (decrypted int64, err error) { valueDes := libunlynx.CipherText{} diff --git a/util/configuration.go b/util/configuration.go index 07835048..53e8db56 100644 --- a/util/configuration.go +++ b/util/configuration.go @@ -42,8 +42,8 @@ var OidcClientID string // OidcJwtUserIDClaim is the JWT claim containing the user ID var OidcJwtUserIDClaim string -// MedCoObfuscationMinVariance is the minimum variance passed to the random distribution for the obfuscation -var MedCoObfuscationMinVariance int +// MedCoObfuscationMin is the minimum variance passed to the random distribution for the obfuscation +var MedCoObfuscationMin int func init() { SetLogLevel(os.Getenv("LOG_LEVEL")) @@ -71,12 +71,12 @@ func init() { OidcClientID = os.Getenv("OIDC_CLIENT_ID") OidcJwtUserIDClaim = os.Getenv("OIDC_JWT_USER_ID_CLAIM") - obf, err := strconv.ParseInt(os.Getenv("MEDCO_OBFUSCATION_MIN_VARIANCE"), 10, 64) + obf, err := strconv.ParseInt(os.Getenv("MEDCO_OBFUSCATION_MIN"), 10, 64) if err != nil || obf < 0 { - logrus.Warn("invalid MedCoObfuscationMinVariance, defaulted") + logrus.Warn("invalid MedCoObfuscationMin, defaulted") obf = 5 } - MedCoObfuscationMinVariance = int(obf) + MedCoObfuscationMin = int(obf) } From 58c83c207679a5a49eba0794b0006dc6c99c7b4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Tue, 25 Jun 2019 17:14:03 +0200 Subject: [PATCH 34/41] fix bug: null array when search query empty --- i2b2/ontology_query.go | 1 + 1 file changed, 1 insertion(+) diff --git a/i2b2/ontology_query.go b/i2b2/ontology_query.go index ce345736..0fd6f709 100644 --- a/i2b2/ontology_query.go +++ b/i2b2/ontology_query.go @@ -47,6 +47,7 @@ func GetOntologyChildren(path string) (results []*models.SearchResultElement, er // generate result from response i2b2Concepts := xmlResponse.MessageBody.(*OntRespConceptsMessageBody).Concepts + results = make([]*models.SearchResultElement, 0) for _, concept := range i2b2Concepts { results = append(results, parseI2b2Concept(concept)) } From ea94e23fa4c21040b9e5d7891491d1108e122349 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Tue, 2 Jul 2019 16:57:08 +0200 Subject: [PATCH 35/41] make unlynx and i2b2 timeouts configurable --- deployment/Dockerfile | 2 ++ deployment/docker-compose.yml | 2 ++ i2b2/common_models.go | 2 +- util/configuration.go | 20 ++++++++++++++++---- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/deployment/Dockerfile b/deployment/Dockerfile index 9d9b8641..568ac84d 100644 --- a/deployment/Dockerfile +++ b/deployment/Dockerfile @@ -25,9 +25,11 @@ ENV I2B2_HIVE_URL=http://i2b2:8080/i2b2/services \ I2B2_LOGIN_PROJECT=MedCo \ I2B2_LOGIN_USER=e2etest \ I2B2_LOGIN_PASSWORD=e2etest \ + I2B2_WAIT_TIME_SECONDS=180 \ LOG_LEVEL=5 \ UNLYNX_GROUP_FILE_PATH=/medco-configuration/group.toml \ UNLYNX_GROUP_FILE_IDX=0 \ + UNLYNX_TIMEOUT_SECONDS=180 \ JWKS_URL=http://keycloak:8080/auth/realms/master/protocol/openid-connect/certs \ OIDC_JWT_ISSUER=http://keycloak:8080/auth/realms/master \ OIDC_CLIENT_ID=medco \ diff --git a/deployment/docker-compose.yml b/deployment/docker-compose.yml index 581cf422..bec1900e 100644 --- a/deployment/docker-compose.yml +++ b/deployment/docker-compose.yml @@ -13,9 +13,11 @@ services: - I2B2_LOGIN_PROJECT=MedCo - I2B2_LOGIN_USER=e2etest - I2B2_LOGIN_PASSWORD=e2etest + - I2B2_WAIT_TIME_SECONDS=180 - LOG_LEVEL=5 - UNLYNX_GROUP_FILE_PATH=/medco-configuration/group.toml - UNLYNX_GROUP_FILE_IDX=0 + - UNLYNX_TIMEOUT_SECONDS=180 - JWKS_URL=http://keycloak:8080/auth/realms/master/protocol/openid-connect/certs - OIDC_JWT_ISSUER=http://keycloak:8080/auth/realms/master - OIDC_CLIENT_ID=medco diff --git a/i2b2/common_models.go b/i2b2/common_models.go index a448cc9d..39e26db6 100644 --- a/i2b2/common_models.go +++ b/i2b2/common_models.go @@ -45,7 +45,7 @@ func NewRequest() Request { ProjectID: util.I2b2LoginProject, }, RequestHeader: RequestHeader{ - ResultWaittimeMs: strconv.Itoa(util.I2b2TimeoutSeconds* 1000), + ResultWaittimeMs: strconv.Itoa(util.I2b2WaitTimeSeconds * 1000), }, } } diff --git a/util/configuration.go b/util/configuration.go index 53e8db56..c5a8a03d 100644 --- a/util/configuration.go +++ b/util/configuration.go @@ -28,8 +28,8 @@ var I2b2LoginProject string var I2b2LoginUser string // I2b2LoginPassword is the i2b2 login password var I2b2LoginPassword string -// I2b2TimeoutSeconds is the i2b2 timeout (seconds) -var I2b2TimeoutSeconds int +// I2b2WaitTimeSeconds is the i2b2 timeout (seconds) +var I2b2WaitTimeSeconds int // JwksURL is the URL from which the JWT signing keys are retrieved var JwksURL string @@ -49,7 +49,13 @@ func init() { SetLogLevel(os.Getenv("LOG_LEVEL")) UnlynxGroupFilePath = os.Getenv("UNLYNX_GROUP_FILE_PATH") - UnlynxTimeoutSeconds = 3 * 60 // 3 minutes + + unlynxto, err := strconv.ParseInt(os.Getenv("UNLYNX_TIMEOUT_SECONDS"), 10, 64) + if err != nil || unlynxto < 0 { + logrus.Warn("invalid UnlynxTimeoutSeconds, defaulted") + unlynxto = 3 * 60 // 3 minutes + } + UnlynxTimeoutSeconds = int(unlynxto) idx, err := strconv.ParseInt(os.Getenv("UNLYNX_GROUP_FILE_IDX"), 10, 64) if err != nil || idx < 0 { @@ -63,7 +69,13 @@ func init() { I2b2LoginProject = os.Getenv("I2B2_LOGIN_PROJECT") I2b2LoginUser = os.Getenv("I2B2_LOGIN_USER") I2b2LoginPassword = os.Getenv("I2B2_LOGIN_PASSWORD") - I2b2TimeoutSeconds = 3 * 60 // 3 minutes + + i2b2to, err := strconv.ParseInt(os.Getenv("I2B2_WAIT_TIME_SECONDS"), 10, 64) + if err != nil || i2b2to < 0 { + logrus.Warn("invalid I2b2WaitTimeSeconds, defaulted") + i2b2to = 3 * 60 // 3 minutes + } + I2b2WaitTimeSeconds = int(i2b2to) JwksURL = os.Getenv("JWKS_URL") JwksTTLSeconds = 60 * 60 // 1 hour From 86072fed5c69b0e4a133bf73d822877be8306409 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Tue, 2 Jul 2019 16:57:59 +0200 Subject: [PATCH 36/41] client timers output: sort them in order to align columns across multiple runs; set permission 777 on output file (temporary) --- medco/client/client.go | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/medco/client/client.go b/medco/client/client.go index ca6df5c5..093a177f 100644 --- a/medco/client/client.go +++ b/medco/client/client.go @@ -12,6 +12,7 @@ import ( "github.com/sirupsen/logrus" "io" "os" + "sort" "strconv" "strings" "time" @@ -80,6 +81,10 @@ func ExecuteClientQuery(token, username, password, queryType, queryString, resul if err != nil { logrus.Error("error opening file: ", err) } + err = os.Chmod(resultOutputFilePath, 0777) + if err != nil { + logrus.Error("error setting permissions on file: ", err) + } } err = printResultsCSV(nodesResult, output) return @@ -91,7 +96,7 @@ func printResultsCSV(nodesResult map[string]*QueryResult, output io.Writer) (err csvHeaders := []string{"node_name", "count", "patient_list"} csvNodesResults := make([][]string, 0) - // results lines + // CSV values: results for nodeName, queryResult := range nodesResult { csvNodesResults = append(csvNodesResults, []string{ nodeName, @@ -100,15 +105,24 @@ func printResultsCSV(nodesResult map[string]*QueryResult, output io.Writer) (err }) } - // timers name + // CSV headers: timers for _, queryResult := range nodesResult { + + // sort the timers by name for deterministic output + timerNames := make([]string, 0) for timerName := range queryResult.Times { + timerNames = append(timerNames, timerName) + } + sort.Strings(timerNames) + + // add to headers + for _, timerName := range timerNames { csvHeaders = append(csvHeaders, timerName) } break } - // timers value: iter over results, then iter over timer names from csvHeaders + // CSV values: timers: iter over results, then iter over timer names from csvHeaders for csvNodeResultsIdx, csvNodeResults := range csvNodesResults { nodeName := csvNodeResults[0] From 1242f726107af3b43ceee21981022e38281fece6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Fri, 12 Jul 2019 14:20:36 +0200 Subject: [PATCH 37/41] client: add option to bypass picsure for query --- cmd/medco-cli-client/main.go | 5 +++ medco/client/client.go | 4 +-- medco/client/query.go | 58 +++++++++++++++++++++++----------- medco/picsure2_api_handlers.go | 2 +- 4 files changed, 48 insertions(+), 21 deletions(-) diff --git a/cmd/medco-cli-client/main.go b/cmd/medco-cli-client/main.go index 96deaa08..551c2fd8 100644 --- a/cmd/medco-cli-client/main.go +++ b/cmd/medco-cli-client/main.go @@ -54,6 +54,10 @@ func main() { Usage: "Output file for the result CSV. Printed to stdout if omitted.", Value: "", }, + cli.BoolFlag{ + Name: "bypassPicsure", + Usage: "Bypass PIC-SURE and query directly the MedCo connectors", + }, } // --- app commands @@ -83,6 +87,7 @@ func main() { strings.Join(c.Args().Tail(), " "), c.String("resultFile"), c.GlobalBool("disableTLSCheck"), + c.Bool("bypassPicsure"), ) }, }, diff --git a/medco/client/client.go b/medco/client/client.go index 093a177f..7b1c3182 100644 --- a/medco/client/client.go +++ b/medco/client/client.go @@ -19,7 +19,7 @@ import ( ) // ExecuteClientQuery execute and display the results of the MedCo client query -func ExecuteClientQuery(token, username, password, queryType, queryString, resultOutputFilePath string, disableTLSCheck bool) (err error) { +func ExecuteClientQuery(token, username, password, queryType, queryString, resultOutputFilePath string, disableTLSCheck bool, bypassPicsure bool) (err error) { // get token var accessToken string @@ -62,7 +62,7 @@ func ExecuteClientQuery(token, username, password, queryType, queryString, resul } // execute query - clientQuery, err := NewQuery(accessToken, queryTypeParsed, encPanelsItemKeys, panelsIsNot, disableTLSCheck) + clientQuery, err := NewQuery(accessToken, queryTypeParsed, encPanelsItemKeys, panelsIsNot, disableTLSCheck, bypassPicsure) if err != nil { return } diff --git a/medco/client/query.go b/medco/client/query.go index 9025a6a0..b01298a3 100644 --- a/medco/client/query.go +++ b/medco/client/query.go @@ -11,22 +11,25 @@ import ( utilclient "github.com/lca1/medco-connector/util/client" "github.com/sirupsen/logrus" "net/http" + "net/url" "time" ) -// todo: times should be parsed - // Query is a MedCo client query type Query struct { - // httpMedcoClient is the HTTP client for the MedCo connectors through PIC-SURE - httpMedcoClient *client.MedcoCli + // httpMedCoClients are the HTTP clients for the MedCo connectors + httpMedCoClients []*client.MedcoCli + // httpPicsureClient is the HTTP client for the MedCo connectors through PIC-SURE + httpPicsureClient *client.MedcoCli // picsureResourceNames is the list of PIC-SURE resources names corresponding to the MedCo connector of each node picsureResourceNames []string // picsureResourceUUIDs is the list of PIC-SURE resources UUIDs corresponding to the MedCo connector of each node picsureResourceUUIDs []string // authToken is the OIDC authentication JWT authToken string + // bypassPicsure instructs to query directly directly the medco connectors + bypassPicsure bool // userPublicKey is the user public key userPublicKey string @@ -42,25 +45,26 @@ type Query struct { } // NewQuery creates a new MedCo client query -func NewQuery(authToken string, queryType models.QueryType, encPanelsItemKeys [][]string, panelsIsNot []bool, disableTLSCheck bool) (q *Query, err error) { +func NewQuery(authToken string, queryType models.QueryType, encPanelsItemKeys [][]string, panelsIsNot []bool, disableTLSCheck bool, bypassPicsure bool) (q *Query, err error) { transport := httptransport.New(utilclient.Picsure2APIHost, utilclient.Picsure2APIBasePath, []string{utilclient.Picsure2APIScheme}) transport.Transport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: disableTLSCheck} q = &Query{ - httpMedcoClient: client.New(transport, nil), + httpPicsureClient: client.New(transport, nil), picsureResourceNames: utilclient.Picsure2Resources, picsureResourceUUIDs: []string{}, - authToken: authToken, + authToken: authToken, + bypassPicsure: bypassPicsure, queryType: queryType, encPanelsItemKeys: encPanelsItemKeys, panelsIsNot: panelsIsNot, } - // retrieve resource UUIDs - err = q.loadResourceUUIDs() + // retrieve resources information + err = q.loadResources(disableTLSCheck) if err != nil { return } @@ -134,10 +138,10 @@ func (clientQuery *Query) Execute() (nodesResult map [string]*QueryResult, err e return nil, err } -// loadResourceUUIDs requests the list of PIC-SURE resources, and retrieves their UUID from the names configured -func (clientQuery *Query) loadResourceUUIDs() (err error) { +// loadResources requests the list of PIC-SURE resources, and retrieves their UUID from the names configured, and their URL +func (clientQuery *Query) loadResources(disableTLSCheck bool) (err error) { getResourcesParams := picsure2.NewGetResourcesParamsWithTimeout(30 * time.Second) - resp, err := clientQuery.httpMedcoClient.Picsure2.GetResources(getResourcesParams, httptransport.BearerToken(clientQuery.authToken)) + resp, err := clientQuery.httpPicsureClient.Picsure2.GetResources(getResourcesParams, httptransport.BearerToken(clientQuery.authToken)) if err != nil { logrus.Error("query error: ", err) return @@ -148,12 +152,23 @@ func (clientQuery *Query) loadResourceUUIDs() (err error) { for _, respResource := range resp.Payload { if resourceName == respResource.Name { clientQuery.picsureResourceUUIDs = append(clientQuery.picsureResourceUUIDs, respResource.UUID) + + resourceUrl, err := url.Parse(respResource.ResourceRSPath) + if err != nil { + logrus.Error("error parsing URL: ", err) + return err + } + + resourceTransport := httptransport.New(resourceUrl.Host, resourceUrl.Path, []string{resourceUrl.Scheme}) + resourceTransport.Transport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: disableTLSCheck} + clientQuery.httpMedCoClients = append(clientQuery.httpMedCoClients, client.New(resourceTransport, nil)) } } } // check all resources were indeed present - if len(clientQuery.picsureResourceUUIDs) != len(clientQuery.picsureResourceNames) { + if len(clientQuery.picsureResourceUUIDs) != len(clientQuery.picsureResourceNames) || + len(clientQuery.httpMedCoClients) != len(clientQuery.picsureResourceNames) { err = errors.New("some resources were not found") logrus.Error(err) return @@ -163,25 +178,32 @@ func (clientQuery *Query) loadResourceUUIDs() (err error) { } // submitToNode sends a query to a node of the network, from the list of PIC-SURE resources -func (clientQuery *Query) submitToNode(picsureResourceUUIDIdx int) (result *models.QueryResultElement, err error) { - logrus.Debug("Submitting query to resource ", clientQuery.picsureResourceNames[picsureResourceUUIDIdx]) +func (clientQuery *Query) submitToNode(picsureResourceIdx int) (result *models.QueryResultElement, err error) { + logrus.Debug("Submitting query to resource ", clientQuery.picsureResourceNames[picsureResourceIdx], + ", bypass PIC-SURE: ", clientQuery.bypassPicsure) queryParams := picsure2.NewQuerySyncParamsWithTimeout(time.Duration(utilclient.QueryTimeoutSeconds) * time.Second) queryParams.Body = picsure2.QuerySyncBody{ ResourceCredentials: &models.ResourceCredentials{ MEDCOTOKEN: clientQuery.authToken, }, - ResourceUUID: clientQuery.picsureResourceUUIDs[picsureResourceUUIDIdx], + ResourceUUID: clientQuery.picsureResourceUUIDs[picsureResourceIdx], Query: clientQuery.generateModel(), } - resp, err := clientQuery.httpMedcoClient.Picsure2.QuerySync(queryParams, httptransport.BearerToken(clientQuery.authToken)) + var response *picsure2.QuerySyncOK + if clientQuery.bypassPicsure { + response, err = clientQuery.httpMedCoClients[picsureResourceIdx].Picsure2.QuerySync(queryParams, httptransport.BearerToken(clientQuery.authToken)) + } else { + response, err = clientQuery.httpPicsureClient.Picsure2.QuerySync(queryParams, httptransport.BearerToken(clientQuery.authToken)) + } + if err != nil { logrus.Error("query error: ", err) return } - return resp.Payload, nil + return response.Payload, nil } // generateModel parses the query terms and generate the model to be sent diff --git a/medco/picsure2_api_handlers.go b/medco/picsure2_api_handlers.go index 51520cb2..f12ff5da 100644 --- a/medco/picsure2_api_handlers.go +++ b/medco/picsure2_api_handlers.go @@ -1,6 +1,6 @@ package medco -import( +import ( "github.com/go-openapi/runtime/middleware" "github.com/lca1/medco-connector/i2b2" "github.com/lca1/medco-connector/restapi/models" From af72188463140f2a67d7e3b745ab8bf15d3b24c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Fri, 12 Jul 2019 14:21:58 +0200 Subject: [PATCH 38/41] harmonize timeouts handling --- deployment/Dockerfile | 9 +++++---- deployment/client.Dockerfile | 2 +- deployment/docker-compose.yml | 7 ++++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/deployment/Dockerfile b/deployment/Dockerfile index 568ac84d..90d2ff54 100644 --- a/deployment/Dockerfile +++ b/deployment/Dockerfile @@ -17,7 +17,8 @@ COPY --from=build /go/bin/medco-connector-server /go/bin/ # swagger server configuration ENV HOST=0.0.0.0 \ - PORT=1999 + PORT=1999 \ + SERVER_HTTP_WRITE_TIMEOUT_SECONDS=600 # run-time environment ENV I2B2_HIVE_URL=http://i2b2:8080/i2b2/services \ @@ -25,11 +26,11 @@ ENV I2B2_HIVE_URL=http://i2b2:8080/i2b2/services \ I2B2_LOGIN_PROJECT=MedCo \ I2B2_LOGIN_USER=e2etest \ I2B2_LOGIN_PASSWORD=e2etest \ - I2B2_WAIT_TIME_SECONDS=180 \ + I2B2_WAIT_TIME_SECONDS=300 \ LOG_LEVEL=5 \ UNLYNX_GROUP_FILE_PATH=/medco-configuration/group.toml \ UNLYNX_GROUP_FILE_IDX=0 \ - UNLYNX_TIMEOUT_SECONDS=180 \ + UNLYNX_TIMEOUT_SECONDS=300 \ JWKS_URL=http://keycloak:8080/auth/realms/master/protocol/openid-connect/certs \ OIDC_JWT_ISSUER=http://keycloak:8080/auth/realms/master \ OIDC_CLIENT_ID=medco \ @@ -37,4 +38,4 @@ ENV I2B2_HIVE_URL=http://i2b2:8080/i2b2/services \ MEDCO_OBFUSCATION_MIN=5 EXPOSE 1999 -ENTRYPOINT ["docker-entrypoint.sh", "medco-connector-server"] +ENTRYPOINT docker-entrypoint.sh medco-connector-server --write-timeout=${SERVER_HTTP_WRITE_TIMEOUT_SECONDS}s diff --git a/deployment/client.Dockerfile b/deployment/client.Dockerfile index da134ac1..7404ad6e 100644 --- a/deployment/client.Dockerfile +++ b/deployment/client.Dockerfile @@ -20,7 +20,7 @@ ENV LOG_LEVEL=5 \ UNLYNX_GROUP_FILE_PATH=/medco-configuration/group.toml \ UNLYNX_GROUP_FILE_IDX=0 \ OIDC_CLIENT_ID=medco \ - CLIENT_QUERY_TIMEOUT_SECONDS=1200 \ + CLIENT_QUERY_TIMEOUT_SECONDS=660 \ PICSURE2_API_HOST=picsure:8080/pic-sure-api-2/PICSURE \ PICSURE2_API_BASE_PATH="" \ PICSURE2_API_SCHEME=https \ diff --git a/deployment/docker-compose.yml b/deployment/docker-compose.yml index bec1900e..a28b5ed9 100644 --- a/deployment/docker-compose.yml +++ b/deployment/docker-compose.yml @@ -8,16 +8,17 @@ services: ports: - "1999" environment: + - SERVER_HTTP_WRITE_TIMEOUT_SECONDS=600 - I2B2_HIVE_URL=http://i2b2:8080/i2b2/services - I2B2_LOGIN_DOMAIN=i2b2medco - I2B2_LOGIN_PROJECT=MedCo - I2B2_LOGIN_USER=e2etest - I2B2_LOGIN_PASSWORD=e2etest - - I2B2_WAIT_TIME_SECONDS=180 + - I2B2_WAIT_TIME_SECONDS=300 - LOG_LEVEL=5 - UNLYNX_GROUP_FILE_PATH=/medco-configuration/group.toml - UNLYNX_GROUP_FILE_IDX=0 - - UNLYNX_TIMEOUT_SECONDS=180 + - UNLYNX_TIMEOUT_SECONDS=300 - JWKS_URL=http://keycloak:8080/auth/realms/master/protocol/openid-connect/certs - OIDC_JWT_ISSUER=http://keycloak:8080/auth/realms/master - OIDC_CLIENT_ID=medco @@ -36,7 +37,7 @@ services: - UNLYNX_GROUP_FILE_PATH=/medco-configuration/group.toml - UNLYNX_GROUP_FILE_IDX=0 - OIDC_CLIENT_ID=medco - - CLIENT_QUERY_TIMEOUT_SECONDS=1200 + - CLIENT_QUERY_TIMEOUT_SECONDS=660 - PICSURE2_API_HOST=localhost - PICSURE2_API_BASE_PATH=/pic-sure-api-2/PICSURE - PICSURE2_API_SCHEME=http From f650c92d17bbf0ea2715fd08c834f0a1d201208a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Fri, 12 Jul 2019 14:22:34 +0200 Subject: [PATCH 39/41] query parser: implement option to repeat the same query term --- medco/client/client.go | 57 +++++++++++++++++++++++++++++++++--------- 1 file changed, 45 insertions(+), 12 deletions(-) diff --git a/medco/client/client.go b/medco/client/client.go index 7b1c3182..2b32987b 100644 --- a/medco/client/client.go +++ b/medco/client/client.go @@ -168,23 +168,56 @@ func parseQueryString(queryString string) (panelsItemKeys [][]int64, panelsIsNot // parse query items itemKeys := make([]int64, 0) for _, queryItem := range strings.Split(queryPanel, " OR ") { + // 3 cases: simple integer, integer to be repeated, query file - parsedInt, parsedErr := strconv.ParseInt(queryItem, 10, 64) - if parsedErr == nil { - logrus.Debug("Client query integer item: ", queryItem) + // case 1: integer to be repeated + if strings.Contains(queryItem, "^") { + logrus.Debug("Client query integer repeated item: ", queryItem) - // if a parsable integer: use as is - itemKeys = append(itemKeys, parsedInt) + elements := strings.Split(queryItem, "^") + if len(elements) != 2 { + err = errors.New("query item contains more than one ^") + logrus.Error(err) + return + } + + queryInt, queryIntErr := strconv.ParseInt(elements[0], 10, 64) + if queryIntErr != nil { + logrus.Error("could not parse query integer: ", queryIntErr) + return nil, nil, queryIntErr + } + + intMultiplier, intMultiplierErr := strconv.ParseInt(elements[1], 10, 64) + if intMultiplierErr != nil { + logrus.Error("could not parse query integer multiplier: ", intMultiplierErr) + return nil, nil, intMultiplierErr + } + + for i := 0 ; i < int(intMultiplier) ; i++ { + itemKeys = append(itemKeys, queryInt) + } } else { - logrus.Debug("Client query file item: ", queryItem) + parsedInt, parsedErr := strconv.ParseInt(queryItem, 10, 64) + + // case 2: simple integer + if parsedErr == nil { + logrus.Debug("Client query integer item: ", queryItem) + + // if a parsable integer: use as is + itemKeys = append(itemKeys, parsedInt) + + // case 3: query file + } else { + logrus.Debug("Client query file item: ", queryItem) - // else assume it is a file - itemKeysFromFile, err := loadQueryFile(queryItem) - if err != nil { - return nil, nil, err + // else assume it is a file + itemKeysFromFile, err := loadQueryFile(queryItem) + if err != nil { + return nil, nil, err + } + itemKeys = append(itemKeys, itemKeysFromFile...) } - itemKeys = append(itemKeys, itemKeysFromFile...) } } panelsItemKeys = append(panelsItemKeys, itemKeys) @@ -192,7 +225,7 @@ func parseQueryString(queryString string) (panelsItemKeys [][]int64, panelsIsNot return } -// todo: might fail if alleles of queries are too big, what to do? ignore +// todo: might fail if alleles of queries are too big, what to do? ignore or fail? // loadQueryFile load and parse a query file (either simple integer or genomic) into integers func loadQueryFile(queryFilePath string) (queryTerms []int64, err error) { logrus.Debug("Client query: loading file ", queryFilePath) From 26770ad510379ae591ea36ac9541b5e8f1817840 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Thu, 15 Aug 2019 11:34:26 +0200 Subject: [PATCH 40/41] update version number --- restapi/server/doc.go | 2 +- restapi/server/embedded_spec.go | 4 ++-- swagger/medco-cli-client.yml | 2 +- swagger/medco-connector-server.yml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/restapi/server/doc.go b/restapi/server/doc.go index 54a66906..0ca2dc0b 100644 --- a/restapi/server/doc.go +++ b/restapi/server/doc.go @@ -9,7 +9,7 @@ This is the API of the MedCo connector, that orchestrates the query at the MedCo http Host: localhost BasePath: /medco-connector - Version: 0.2.0 + Version: 0.2.1 License: EULA https://raw.githubusercontent.com/lca1/medco-connector/master/LICENSE Contact: diff --git a/restapi/server/embedded_spec.go b/restapi/server/embedded_spec.go index 92dbb01d..c05a6a96 100644 --- a/restapi/server/embedded_spec.go +++ b/restapi/server/embedded_spec.go @@ -32,7 +32,7 @@ func init() { "name": "EULA", "url": "https://raw.githubusercontent.com/lca1/medco-connector/master/LICENSE" }, - "version": "0.2.0" + "version": "0.2.1" }, "basePath": "/medco-connector", "paths": { @@ -698,7 +698,7 @@ func init() { "name": "EULA", "url": "https://raw.githubusercontent.com/lca1/medco-connector/master/LICENSE" }, - "version": "0.2.0" + "version": "0.2.1" }, "basePath": "/medco-connector", "paths": { diff --git a/swagger/medco-cli-client.yml b/swagger/medco-cli-client.yml index 3e8e8848..089f3e3b 100644 --- a/swagger/medco-cli-client.yml +++ b/swagger/medco-cli-client.yml @@ -1,7 +1,7 @@ swagger: "2.0" info: description: "This is the PIC-SURE 2 API exposed by MedCo, and used by the MedCo CLI client." - version: "0.2.0" + version: "0.2.1" title: "MedCo CLI Client (PIC-SURE 2 API)" contact: email: "medco-dev@listes.epfl.ch" diff --git a/swagger/medco-connector-server.yml b/swagger/medco-connector-server.yml index b9493f14..a0e37c83 100644 --- a/swagger/medco-connector-server.yml +++ b/swagger/medco-connector-server.yml @@ -1,7 +1,7 @@ swagger: "2.0" info: description: "This is the API of the MedCo connector, that orchestrates the query at the MedCo node. It implements the PIC-SURE 2 API." - version: "0.2.0" + version: "0.2.1" title: "MedCo Connector" contact: email: "medco-dev@listes.epfl.ch" From 15129cea010741163a635233326226e457394284 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Thu, 15 Aug 2019 11:44:18 +0200 Subject: [PATCH 41/41] update go modules --- go.mod | 5 +++-- go.sum | 22 ++-------------------- 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/go.mod b/go.mod index 6666100c..8befc28a 100644 --- a/go.mod +++ b/go.mod @@ -15,12 +15,13 @@ require ( github.com/go-openapi/validate v0.19.0 github.com/jessevdk/go-flags v1.4.0 github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect - github.com/lca1/medco-loader v0.0.0-20190607142358-eb601905cd14 - github.com/lca1/medco-unlynx v0.0.0-20190607122735-0645e9b99b36 + github.com/lca1/medco-loader v0.2.1 + github.com/lca1/medco-unlynx v0.2.1 github.com/lca1/unlynx v1.3.1 github.com/lestrrat-go/jwx v0.9.0 github.com/mailru/easyjson v0.0.0-20190403194419-1ea4449da983 // indirect github.com/pkg/errors v0.8.1 + github.com/r0fls/gostats v0.0.0-20180711082619-e793b1fda35c github.com/sirupsen/logrus v1.4.2 github.com/smartystreets/assertions v1.0.0 // indirect github.com/urfave/cli v1.20.0 diff --git a/go.sum b/go.sum index 4f768401..58781e15 100644 --- a/go.sum +++ b/go.sum @@ -26,7 +26,6 @@ github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/fanliao/go-concurrentMap v0.0.0-20141114143905-7d2d7a5ea67b h1:aHrWACMJZJ160Pl0qlH6s0/+5Kb1KYG/kEUTaZCW7QY= github.com/fanliao/go-concurrentMap v0.0.0-20141114143905-7d2d7a5ea67b/go.mod h1:DRc7ieGsJItxOsZ2lnqemj92zsSsBjBepuritZaumSE= -github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8 h1:DujepqpGd1hyOd7aW59XpK7Qymp8iy83xq74fLr21is= github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= @@ -78,8 +77,6 @@ github.com/go-openapi/validate v0.18.0 h1:PVXYcP1GkTl+XIAJnyJxOmK6CSG5Q1UcvoCvNO github.com/go-openapi/validate v0.18.0/go.mod h1:Uh4HdOzKt19xGIGm1qHf/ofbX1YQ4Y+MYsct2VUrAJ4= github.com/go-openapi/validate v0.19.0 h1:SF5vyj6PBFM6D1cw2NJIFrlS8Su2YKk6ADPPjAH70Bw= github.com/go-openapi/validate v0.19.0/go.mod h1:Uh4HdOzKt19xGIGm1qHf/ofbX1YQ4Y+MYsct2VUrAJ4= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golangplus/bytes v0.0.0-20160111154220-45c989fe5450 h1:7xqw01UYS+KCI25bMrPxwNYkSns2Db1ziQPpVq99FpE= github.com/golangplus/bytes v0.0.0-20160111154220-45c989fe5450/go.mod h1:Bk6SMAONeMXrxql8uvOKuAZSu8aM5RUGv+1C6IJaEho= github.com/golangplus/fmt v0.0.0-20150411045040-2a5d6d7d2995 h1:f5gsjBiF9tRRVomCvrkGMMWI8W1f2OBFar2c5oakAP0= @@ -95,7 +92,6 @@ github.com/gopherjs/gopherjs v0.0.0-20190430165422-3e4dfb77656c h1:7lF+Vz0LqiRid github.com/gopherjs/gopherjs v0.0.0-20190430165422-3e4dfb77656c/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= -github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= @@ -107,12 +103,10 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxv github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/pty v1.1.4/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/lca1/medco-loader v0.0.0-20190607142358-eb601905cd14/go.mod h1:llUindDQeDVOP3ggoALLYaL8mAuh6K953vesHrrrFpo= -github.com/lca1/medco-unlynx v0.0.0-20190607122735-0645e9b99b36 h1:zi204zXP+JkBc9w8KXBJEkoMqlDON8+fCniY1k0EQJc= -github.com/lca1/medco-unlynx v0.0.0-20190607122735-0645e9b99b36/go.mod h1:00I2j2isD6K3z8Xj4MIM5IOStT3rZQQtDkq59betkDo= +github.com/lca1/medco-unlynx v0.2.1 h1:JsFLOmGIcGDlCF7YWNIKbIlVdWIMdgoJwUths1TtYrg= +github.com/lca1/medco-unlynx v0.2.1/go.mod h1:+L2ocXzDCfdnUbvsxdsJM23lY1vv5BvR9g4HD682Mck= github.com/lca1/unlynx v1.3.1 h1:l/sLi4DGL9Rlvk6ySzR13VYjgbubY1tMHPyXGvd2zZU= github.com/lca1/unlynx v1.3.1/go.mod h1:HOR8K2JLrylJjIDdMdFev5rE5q6XGifs0OnH7rvreqY= github.com/lestrrat-go/jwx v0.9.0 h1:Fnd0EWzTm0kFrBPzE/PEPp9nzllES5buMkksPMjEKpM= @@ -127,9 +121,7 @@ github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh github.com/montanaflynn/stats v0.5.0 h1:2EkzeTSqBB4V4bJwWrt5gIIrZmpJBcoIRGS2kWLgzmk= github.com/montanaflynn/stats v0.5.0/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= -github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/pborman/uuid v1.2.0 h1:J7Q5mO4ysT1dv8hyrUGHb9+ooztCXu1D8MY8DZYsu3g= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= @@ -151,7 +143,6 @@ github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a h1:pa8hGb/2 github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= @@ -183,9 +174,7 @@ golang.org/x/crypto v0.0.0-20190320223903-b7391e95e576/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5 h1:58fnuSXlxZmFdJyvtTFVmVhcMLU6v5fEb/ok4wyqtNU= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628= @@ -195,9 +184,6 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190606173856-1492cefac77f h1:IWHgpgFqnL5AhBUBZSgBdjl2vkQUEzcY+JNKWfcgAU0= golang.org/x/net v0.0.0-20190606173856-1492cefac77f/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190124100055-b90733256f2e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -212,17 +198,13 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384 h1:TFlARGu6Czu1z7q93HTxcP1P+/ZFC/IKythI5RzrnRg= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190529010454-aa71c3f32488/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/satori/go.uuid.v1 v1.2.0 h1:AH9uksa7bGe9rluapecRKBCpZvxaBEyu0RepitcD0Hw= gopkg.in/satori/go.uuid.v1 v1.2.0/go.mod h1:kjjdhYBBaa5W5DYP+OcVG3fRM6VWu14hqDYST4Zvw+E= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/tylerb/graceful.v1 v1.2.15 h1:1JmOyhKqAyX3BgTXMI84LwT6FOJ4tP2N9e2kwTCM0nQ= gopkg.in/tylerb/graceful.v1 v1.2.15/go.mod h1:yBhekWvR20ACXVObSSdD3u6S9DeSylanL2PAbAC/uJ8= gopkg.in/urfave/cli.v1 v1.20.0/go.mod h1:vuBzUtMdQeixQj8LVd+/98pzhxNGQoyuPBlsXHOQNO0=