Skip to content

Commit

Permalink
Add support for detail DAS key
Browse files Browse the repository at this point in the history
  • Loading branch information
vkuznet committed Mar 10, 2022
1 parent cb06dc9 commit 12589ce
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
13 changes: 13 additions & 0 deletions das/das.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,19 @@ func FormUrlCall(dasquery dasql.DASQuery, dasmap mongo.DASRecord) string {
if len(vals) < len(skeys) {
return "" // number of arguments should be equal or more number of spec key values
}
// replace details=True argument in DBS calls
if dasquery.Detail == false {
args = strings.Replace(args, "detail=True", "detail=False", -1)
}
// replace details=True argument in DBS calls
if strings.Contains(args, "detail") {
if v, ok := vals["detail"]; ok {
sv := fmt.Sprintf("%v", v)
if sv == "0" || sv == "false" || sv == "False" {
args = strings.Replace(args, "detail=True", "detail=False", -1)
}
}
}
if len(args) > 0 {
return base + "?" + args
}
Expand Down
14 changes: 10 additions & 4 deletions dasql/dasql.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,11 +365,17 @@ func Parse(query, inst string, daskeys []string) (DASQuery, string, string) {
}

// remove detail from spec
detail := false
if spec["detail"] != nil || len(filters) != 0 {
detail = true
delete(spec, "detail")
// by default detail is set to true for all APIs, to change this I need
// to change das maps and then change it here
detail := true
// if spec["detail"] != nil || len(filters) != 0 {
// detail = true
// delete(spec, "detail")
// }
if spec["detail"] == "-" || spec["detail"] == "false" || spec["detail"] == "False" {
detail = false
}
delete(spec, "detail")

// find out which system to use
var system string
Expand Down

0 comments on commit 12589ce

Please sign in to comment.