-
Notifications
You must be signed in to change notification settings - Fork 1
/
credentials.pb.fieldmask.go
306 lines (265 loc) · 8.81 KB
/
credentials.pb.fieldmask.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
// Code generated by protoc-gen-goten-object
// File: edgelq/common/api/credentials.proto
// DO NOT EDIT!!!
package api
import (
"encoding/json"
"strings"
firestorepb "google.golang.org/genproto/googleapis/firestore/v1"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/proto"
preflect "google.golang.org/protobuf/reflect/protoreflect"
"google.golang.org/protobuf/types/known/fieldmaskpb"
gotenobject "github.com/cloudwan/goten-sdk/runtime/object"
)
// proto imports
import (
timestamp "github.com/golang/protobuf/ptypes/timestamp"
)
// ensure the imports are used
var (
_ = json.Marshaler(nil)
_ = strings.Builder{}
_ = firestorepb.Value{}
_ = codes.NotFound
_ = status.Status{}
_ = proto.Message(nil)
_ = preflect.Message(nil)
_ = fieldmaskpb.FieldMask{}
_ = gotenobject.FieldMask(nil)
)
// make sure we're using proto imports
var (
_ = ×tamp.Timestamp{}
)
type ServiceAccount_FieldMask struct {
Paths []ServiceAccount_FieldPath
}
func FullServiceAccount_FieldMask() *ServiceAccount_FieldMask {
res := &ServiceAccount_FieldMask{}
res.Paths = append(res.Paths, &ServiceAccount_FieldTerminalPath{selector: ServiceAccount_FieldPathSelectorType})
res.Paths = append(res.Paths, &ServiceAccount_FieldTerminalPath{selector: ServiceAccount_FieldPathSelectorClientEmail})
res.Paths = append(res.Paths, &ServiceAccount_FieldTerminalPath{selector: ServiceAccount_FieldPathSelectorPrivateKeyId})
res.Paths = append(res.Paths, &ServiceAccount_FieldTerminalPath{selector: ServiceAccount_FieldPathSelectorPrivateKey})
return res
}
func (fieldMask *ServiceAccount_FieldMask) String() string {
if fieldMask == nil {
return "<nil>"
}
pathsStr := make([]string, 0, len(fieldMask.Paths))
for _, path := range fieldMask.Paths {
pathsStr = append(pathsStr, path.String())
}
return strings.Join(pathsStr, ", ")
}
// firestore encoding/decoding integration
func (fieldMask *ServiceAccount_FieldMask) EncodeFirestore() (*firestorepb.Value, error) {
if fieldMask == nil {
return &firestorepb.Value{ValueType: &firestorepb.Value_NullValue{}}, nil
}
arrayValues := make([]*firestorepb.Value, 0, len(fieldMask.Paths))
for _, path := range fieldMask.GetPaths() {
arrayValues = append(arrayValues, &firestorepb.Value{ValueType: &firestorepb.Value_StringValue{StringValue: path.String()}})
}
return &firestorepb.Value{
ValueType: &firestorepb.Value_ArrayValue{ArrayValue: &firestorepb.ArrayValue{Values: arrayValues}},
}, nil
}
func (fieldMask *ServiceAccount_FieldMask) DecodeFirestore(fpbv *firestorepb.Value) error {
for _, value := range fpbv.GetArrayValue().GetValues() {
parsedPath, err := ParseServiceAccount_FieldPath(value.GetStringValue())
if err != nil {
return err
}
fieldMask.Paths = append(fieldMask.Paths, parsedPath)
}
return nil
}
func (fieldMask *ServiceAccount_FieldMask) IsFull() bool {
if fieldMask == nil {
return false
}
presentSelectors := make([]bool, 4)
for _, path := range fieldMask.Paths {
if asFinal, ok := path.(*ServiceAccount_FieldTerminalPath); ok {
presentSelectors[int(asFinal.selector)] = true
}
}
for _, flag := range presentSelectors {
if !flag {
return false
}
}
return true
}
func (fieldMask *ServiceAccount_FieldMask) ProtoReflect() preflect.Message {
return gotenobject.MakeFieldMaskReflection(fieldMask, func(raw string) (gotenobject.FieldPath, error) {
return ParseServiceAccount_FieldPath(raw)
})
}
func (fieldMask *ServiceAccount_FieldMask) ProtoMessage() {}
func (fieldMask *ServiceAccount_FieldMask) Reset() {
if fieldMask != nil {
fieldMask.Paths = nil
}
}
func (fieldMask *ServiceAccount_FieldMask) Subtract(other *ServiceAccount_FieldMask) *ServiceAccount_FieldMask {
result := &ServiceAccount_FieldMask{}
removedSelectors := make([]bool, 4)
for _, path := range other.GetPaths() {
switch tp := path.(type) {
case *ServiceAccount_FieldTerminalPath:
removedSelectors[int(tp.selector)] = true
}
}
for _, path := range fieldMask.GetPaths() {
if !removedSelectors[int(path.Selector())] {
result.Paths = append(result.Paths, path)
}
}
if len(result.Paths) == 0 {
return nil
}
return result
}
func (fieldMask *ServiceAccount_FieldMask) SubtractRaw(other gotenobject.FieldMask) gotenobject.FieldMask {
return fieldMask.Subtract(other.(*ServiceAccount_FieldMask))
}
// FilterInputFields generates copy of field paths with output_only field paths removed
func (fieldMask *ServiceAccount_FieldMask) FilterInputFields() *ServiceAccount_FieldMask {
result := &ServiceAccount_FieldMask{}
result.Paths = append(result.Paths, fieldMask.Paths...)
return result
}
// ToFieldMask is used for proto conversions
func (fieldMask *ServiceAccount_FieldMask) ToProtoFieldMask() *fieldmaskpb.FieldMask {
protoFieldMask := &fieldmaskpb.FieldMask{}
for _, path := range fieldMask.Paths {
protoFieldMask.Paths = append(protoFieldMask.Paths, path.String())
}
return protoFieldMask
}
func (fieldMask *ServiceAccount_FieldMask) FromProtoFieldMask(protoFieldMask *fieldmaskpb.FieldMask) error {
if fieldMask == nil {
return status.Error(codes.Internal, "target field mask is nil")
}
fieldMask.Paths = make([]ServiceAccount_FieldPath, 0, len(protoFieldMask.Paths))
for _, strPath := range protoFieldMask.Paths {
path, err := ParseServiceAccount_FieldPath(strPath)
if err != nil {
return err
}
fieldMask.Paths = append(fieldMask.Paths, path)
}
return nil
}
// implement methods required by customType
func (fieldMask ServiceAccount_FieldMask) Marshal() ([]byte, error) {
protoFieldMask := fieldMask.ToProtoFieldMask()
return proto.Marshal(protoFieldMask)
}
func (fieldMask *ServiceAccount_FieldMask) Unmarshal(data []byte) error {
protoFieldMask := &fieldmaskpb.FieldMask{}
if err := proto.Unmarshal(data, protoFieldMask); err != nil {
return err
}
if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil {
return err
}
return nil
}
func (fieldMask *ServiceAccount_FieldMask) Size() int {
return proto.Size(fieldMask.ToProtoFieldMask())
}
func (fieldMask ServiceAccount_FieldMask) MarshalJSON() ([]byte, error) {
return json.Marshal(fieldMask.ToProtoFieldMask())
}
func (fieldMask *ServiceAccount_FieldMask) UnmarshalJSON(data []byte) error {
protoFieldMask := &fieldmaskpb.FieldMask{}
if err := json.Unmarshal(data, protoFieldMask); err != nil {
return err
}
if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil {
return err
}
return nil
}
func (fieldMask *ServiceAccount_FieldMask) AppendPath(path ServiceAccount_FieldPath) {
fieldMask.Paths = append(fieldMask.Paths, path)
}
func (fieldMask *ServiceAccount_FieldMask) AppendRawPath(path gotenobject.FieldPath) {
fieldMask.Paths = append(fieldMask.Paths, path.(ServiceAccount_FieldPath))
}
func (fieldMask *ServiceAccount_FieldMask) GetPaths() []ServiceAccount_FieldPath {
if fieldMask == nil {
return nil
}
return fieldMask.Paths
}
func (fieldMask *ServiceAccount_FieldMask) GetRawPaths() []gotenobject.FieldPath {
if fieldMask == nil {
return nil
}
rawPaths := make([]gotenobject.FieldPath, 0, len(fieldMask.Paths))
for _, path := range fieldMask.Paths {
rawPaths = append(rawPaths, path)
}
return rawPaths
}
func (fieldMask *ServiceAccount_FieldMask) SetFromCliFlag(raw string) error {
path, err := ParseServiceAccount_FieldPath(raw)
if err != nil {
return err
}
fieldMask.Paths = append(fieldMask.Paths, path)
return nil
}
func (fieldMask *ServiceAccount_FieldMask) Set(target, source *ServiceAccount) {
for _, path := range fieldMask.Paths {
val, _ := path.GetSingle(source)
// if val is nil, then field does not exist in source, skip
// otherwise, process (can still reflect.ValueOf(val).IsNil!)
if val != nil {
path.WithIValue(val).SetTo(&target)
}
}
}
func (fieldMask *ServiceAccount_FieldMask) SetRaw(target, source gotenobject.GotenObjectExt) {
fieldMask.Set(target.(*ServiceAccount), source.(*ServiceAccount))
}
func (fieldMask *ServiceAccount_FieldMask) Project(source *ServiceAccount) *ServiceAccount {
if source == nil {
return nil
}
if fieldMask == nil {
return source
}
result := &ServiceAccount{}
for _, p := range fieldMask.Paths {
switch tp := p.(type) {
case *ServiceAccount_FieldTerminalPath:
switch tp.selector {
case ServiceAccount_FieldPathSelectorType:
result.Type = source.Type
case ServiceAccount_FieldPathSelectorClientEmail:
result.ClientEmail = source.ClientEmail
case ServiceAccount_FieldPathSelectorPrivateKeyId:
result.PrivateKeyId = source.PrivateKeyId
case ServiceAccount_FieldPathSelectorPrivateKey:
result.PrivateKey = source.PrivateKey
}
}
}
return result
}
func (fieldMask *ServiceAccount_FieldMask) ProjectRaw(source gotenobject.GotenObjectExt) gotenobject.GotenObjectExt {
return fieldMask.Project(source.(*ServiceAccount))
}
func (fieldMask *ServiceAccount_FieldMask) PathsCount() int {
if fieldMask == nil {
return 0
}
return len(fieldMask.Paths)
}