Merged in jb/openapi (pull request #22)
add openapi infra * add openapi infra Includes generated stubs and all deps * generatetolocation * basesetupoffunctionsandclient * round1controllertests * passintegrationtests * cleanupfromfullsuite * storedjson * fixjsonyaml * fixtests Approved-by: Michael McGuinness
This commit is contained in:
committed by
Michael McGuinness
parent
5ca36b0502
commit
174644b63c
@@ -0,0 +1,72 @@
|
||||
package queryservice
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"queryorchestration/internal/query"
|
||||
queryprocessor "queryorchestration/internal/queryProcessor"
|
||||
)
|
||||
|
||||
func parseQueries(queries []*query.Query) ([]Query, error) {
|
||||
outQueries := make([]Query, len(queries))
|
||||
for index, query := range queries {
|
||||
qt, err := parseQuery(query)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
outQueries[index] = *qt
|
||||
}
|
||||
|
||||
return outQueries, nil
|
||||
}
|
||||
|
||||
func parseQuery(query *query.Query) (*Query, error) {
|
||||
requiredQueries := make([]string, len(query.RequiredQueryIDs))
|
||||
for index, id := range query.RequiredQueryIDs {
|
||||
requiredQueries[index] = id.String()
|
||||
}
|
||||
|
||||
qt, err := parseQueryType(query.Type)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
q := &Query{
|
||||
Id: query.ID.String(),
|
||||
Type: qt,
|
||||
ActiveVersion: query.ActiveVersion,
|
||||
LatestVersion: query.LatestVersion,
|
||||
}
|
||||
|
||||
if query.Config != "" {
|
||||
q.Config = &query.Config
|
||||
}
|
||||
|
||||
if len(query.RequiredQueryIDs) > 0 {
|
||||
q.RequiredQueries = requiredQueries
|
||||
}
|
||||
|
||||
return q, nil
|
||||
}
|
||||
|
||||
func parseQueryType(qType queryprocessor.Type) (QueryType, error) {
|
||||
switch qType {
|
||||
case queryprocessor.TypeJsonExtractor:
|
||||
return JSONEXTRACTOR, nil
|
||||
case queryprocessor.TypeContextFull:
|
||||
return CONTEXTFULL, nil
|
||||
default:
|
||||
return "", errors.New("invalid query type")
|
||||
}
|
||||
}
|
||||
|
||||
func parseSpecQueryType(qType QueryType) (queryprocessor.Type, error) {
|
||||
switch qType {
|
||||
case JSONEXTRACTOR:
|
||||
return queryprocessor.TypeJsonExtractor, nil
|
||||
case CONTEXTFULL:
|
||||
return queryprocessor.TypeContextFull, nil
|
||||
default:
|
||||
return queryprocessor.Type(-1), errors.New("invalid query type")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user