-
Notifications
You must be signed in to change notification settings - Fork 142
/
utils.go
124 lines (88 loc) · 3.16 KB
/
utils.go
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
package bigquery
const (
UnixDate = "Mon Jan _2 15:04:05 MST 2006"
RFC3339 = "2006-01-02T15:04:05Z07:00"
)
func createdatasetsdictnoaryconvert(option CreateDatasets, createdatasetsjsonmap map[string]interface{}) {
if option.defaultTableExpirationMs != "" {
createdatasetsjsonmap["defaultTableExpirationMs"] = option.defaultTableExpirationMs
}
if option.defaultTableExpirationMs != "" {
createdatasetsjsonmap["defaultTableExpirationMs"] = option.defaultTableExpirationMs
}
if option.defaultTableExpirationMs != "" {
createdatasetsjsonmap["description"] = option.description
}
if option.etag != "" {
createdatasetsjsonmap["etag"] = option.etag
}
if option.id != "" {
createdatasetsjsonmap["id"] = option.id
}
if option.friendlyName != "" {
createdatasetsjsonmap["friendlyName"] = option.friendlyName
}
if option.kind != "" {
createdatasetsjsonmap["kind"] = option.kind
}
if option.lastModifiedTime != "" {
createdatasetsjsonmap["lastModifiedTime"] = option.lastModifiedTime
}
if option.location != "" {
createdatasetsjsonmap["location"] = option.location
}
if option.selfLink != "" {
createdatasetsjsonmap["selfLink"] = option.selfLink
}
preparedatasetReferenceparam(option, createdatasetsjsonmap)
prepareAccessparam(option, createdatasetsjsonmap)
}
func preparedatasetReferenceparam(option CreateDatasets, createdatasetsjsonmap map[string]interface{}) {
datasetReferencejsonmap := make(map[string]interface{})
if option.datasetReference.projectID != "" {
datasetReferencejsonmap["projectId"] = option.datasetReference.projectID
}
if option.datasetReference.datasetID != "" {
datasetReferencejsonmap["datasetId"] = option.datasetReference.datasetID
}
createdatasetsjsonmap["datasetReference"] = datasetReferencejsonmap
}
func prepareAccessparam(option CreateDatasets, createdatasetsjsonmap map[string]interface{}) {
if len(option.access) != 0 {
accessarrayjsonmap := make([]map[string]interface{}, 0)
for i := 0; i < len(option.access); i++ {
accessjsonmap := make(map[string]interface{})
if option.access[i].domain != "" {
accessjsonmap["domain"] = option.access[i].domain
}
if option.access[i].groupByEmail != "" {
accessjsonmap["groupByEmail"] = option.access[i].groupByEmail
}
if option.access[i].role != "" {
accessjsonmap["role"] = option.access[i].role
}
if option.access[i].specialGroup != "" {
accessjsonmap["specialGroup"] = option.access[i].specialGroup
}
if option.access[i].userByEmail != "" {
accessjsonmap["userByEmail"] = option.access[i].userByEmail
}
v := View{}
if option.access[i].view != v {
viewjsonmap := make(map[string]interface{})
if option.access[i].view.datasetID != "" {
viewjsonmap["datasetID"] = option.access[i].view.datasetID
}
if option.access[i].view.projectID != "" {
viewjsonmap["projectID"] = option.access[i].view.projectID
}
if option.access[i].view.tableID != "" {
viewjsonmap["tableID"] = option.access[i].view.tableID
}
accessjsonmap["view"] = viewjsonmap
}
accessarrayjsonmap = append(accessarrayjsonmap, accessjsonmap)
}
createdatasetsjsonmap["access"] = accessarrayjsonmap
}
}