-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatasets.go
More file actions
46 lines (41 loc) Β· 1.42 KB
/
datasets.go
File metadata and controls
46 lines (41 loc) Β· 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"encoding/json"
"fmt"
"log"
oreConfig "github.com/OreCast/common/config"
)
// {"create_by":"OreCast-workflow","creation_date":1696853600,"dataset":"/a/b/c","last_modification_date":1696853600,"last_modified_by":"OreCast-workflow","meta_id":"123xyz","parent":null,"processing":"glibc","site":"Cornell"}
type DBSRecord struct {
Dataset string `json:"dataset"`
MetaId string `json:"meta_id"`
Parent string `json:"parent"`
Processing string `json:"processing"`
Site string `json:"site"`
CreateBy string `json:"create_by"`
CreationDate int64 `json:"creation_date"`
LastModifiedBy string `json:"last_modified_by"`
LastModificationdate int64 `json:"last_modification_date"`
}
func getDatasets(ds string) []DBSRecord {
var datasets []DBSRecord
rurl := fmt.Sprintf("%s/datasets", oreConfig.Config.Services.DataBookkeepingURL)
if ds != "" {
rurl = fmt.Sprintf("%s/dataset/%s", oreConfig.Config.Services.DataBookkeepingURL, ds)
}
resp, err := httpGet(rurl)
if oreConfig.Config.Frontend.WebServer.Verbose > 0 {
log.Println("query DataBookkeeping service rurl", rurl, err)
}
if err != nil {
log.Println("ERROR:", err)
return datasets
}
defer resp.Body.Close()
dec := json.NewDecoder(resp.Body)
if err := dec.Decode(&datasets); err != nil {
log.Println("ERROR:", err)
return datasets
}
return datasets
}