-
Notifications
You must be signed in to change notification settings - Fork 1
/
permission.pb.fieldpath.go
523 lines (461 loc) · 16.7 KB
/
permission.pb.fieldpath.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
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
// Code generated by protoc-gen-goten-object
// File: edgelq/iam/proto/v1alpha/permission.proto
// DO NOT EDIT!!!
package permission
import (
"encoding/json"
"fmt"
"reflect"
"strings"
"time"
"github.com/iancoleman/strcase"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/reflect/protoregistry"
"google.golang.org/protobuf/types/known/fieldmaskpb"
gotenobject "github.com/cloudwan/goten-sdk/runtime/object"
)
// proto imports
import ()
// ensure the imports are used
var (
_ = new(json.Marshaler)
_ = new(fmt.Stringer)
_ = reflect.DeepEqual
_ = strings.Builder{}
_ = time.Second
_ = strcase.ToLowerCamel
_ = codes.NotFound
_ = status.Status{}
_ = protojson.UnmarshalOptions{}
_ = new(proto.Message)
_ = protoregistry.GlobalTypes
_ = fieldmaskpb.FieldMask{}
_ = new(gotenobject.FieldPath)
)
// make sure we're using proto imports
var ()
// FieldPath provides implementation to handle
// https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto
type Permission_FieldPath interface {
gotenobject.FieldPath
Selector() Permission_FieldPathSelector
Get(source *Permission) []interface{}
GetSingle(source *Permission) (interface{}, bool)
ClearValue(item *Permission)
// Those methods build corresponding Permission_FieldPathValue
// (or array of values) and holds passed value. Panics if injected type is incorrect.
WithIValue(value interface{}) Permission_FieldPathValue
WithIArrayOfValues(values interface{}) Permission_FieldPathArrayOfValues
WithIArrayItemValue(value interface{}) Permission_FieldPathArrayItemValue
}
type Permission_FieldPathSelector int32
const (
Permission_FieldPathSelectorName Permission_FieldPathSelector = 0
Permission_FieldPathSelectorTitle Permission_FieldPathSelector = 1
Permission_FieldPathSelectorDescription Permission_FieldPathSelector = 2
)
func (s Permission_FieldPathSelector) String() string {
switch s {
case Permission_FieldPathSelectorName:
return "name"
case Permission_FieldPathSelectorTitle:
return "title"
case Permission_FieldPathSelectorDescription:
return "description"
default:
panic(fmt.Sprintf("Invalid selector for Permission: %d", s))
}
}
func BuildPermission_FieldPath(fp gotenobject.RawFieldPath) (Permission_FieldPath, error) {
if len(fp) == 0 {
return nil, status.Error(codes.InvalidArgument, "empty field path for object Permission")
}
if len(fp) == 1 {
switch fp[0] {
case "name":
return &Permission_FieldTerminalPath{selector: Permission_FieldPathSelectorName}, nil
case "title":
return &Permission_FieldTerminalPath{selector: Permission_FieldPathSelectorTitle}, nil
case "description":
return &Permission_FieldTerminalPath{selector: Permission_FieldPathSelectorDescription}, nil
}
}
return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object Permission", fp)
}
func ParsePermission_FieldPath(rawField string) (Permission_FieldPath, error) {
fp, err := gotenobject.ParseRawFieldPath(rawField)
if err != nil {
return nil, err
}
return BuildPermission_FieldPath(fp)
}
func MustParsePermission_FieldPath(rawField string) Permission_FieldPath {
fp, err := ParsePermission_FieldPath(rawField)
if err != nil {
panic(err)
}
return fp
}
type Permission_FieldTerminalPath struct {
selector Permission_FieldPathSelector
}
var _ Permission_FieldPath = (*Permission_FieldTerminalPath)(nil)
func (fp *Permission_FieldTerminalPath) Selector() Permission_FieldPathSelector {
return fp.selector
}
// String returns path representation in proto convention
func (fp *Permission_FieldTerminalPath) String() string {
return fp.selector.String()
}
// JSONString returns path representation is JSON convention
func (fp *Permission_FieldTerminalPath) JSONString() string {
return strcase.ToLowerCamel(fp.String())
}
// Get returns all values pointed by specific field from source Permission
func (fp *Permission_FieldTerminalPath) Get(source *Permission) (values []interface{}) {
if source != nil {
switch fp.selector {
case Permission_FieldPathSelectorName:
if source.Name != nil {
values = append(values, source.Name)
}
case Permission_FieldPathSelectorTitle:
values = append(values, source.Title)
case Permission_FieldPathSelectorDescription:
values = append(values, source.Description)
default:
panic(fmt.Sprintf("Invalid selector for Permission: %d", fp.selector))
}
}
return
}
func (fp *Permission_FieldTerminalPath) GetRaw(source proto.Message) []interface{} {
return fp.Get(source.(*Permission))
}
// GetSingle returns value pointed by specific field of from source Permission
func (fp *Permission_FieldTerminalPath) GetSingle(source *Permission) (interface{}, bool) {
switch fp.selector {
case Permission_FieldPathSelectorName:
res := source.GetName()
return res, res != nil
case Permission_FieldPathSelectorTitle:
return source.GetTitle(), source != nil
case Permission_FieldPathSelectorDescription:
return source.GetDescription(), source != nil
default:
panic(fmt.Sprintf("Invalid selector for Permission: %d", fp.selector))
}
}
func (fp *Permission_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) {
return fp.GetSingle(source.(*Permission))
}
// GetDefault returns a default value of the field type
func (fp *Permission_FieldTerminalPath) GetDefault() interface{} {
switch fp.selector {
case Permission_FieldPathSelectorName:
return (*Name)(nil)
case Permission_FieldPathSelectorTitle:
return ""
case Permission_FieldPathSelectorDescription:
return ""
default:
panic(fmt.Sprintf("Invalid selector for Permission: %d", fp.selector))
}
}
func (fp *Permission_FieldTerminalPath) ClearValue(item *Permission) {
if item != nil {
switch fp.selector {
case Permission_FieldPathSelectorName:
item.Name = nil
case Permission_FieldPathSelectorTitle:
item.Title = ""
case Permission_FieldPathSelectorDescription:
item.Description = ""
default:
panic(fmt.Sprintf("Invalid selector for Permission: %d", fp.selector))
}
}
}
func (fp *Permission_FieldTerminalPath) ClearValueRaw(item proto.Message) {
fp.ClearValue(item.(*Permission))
}
// IsLeaf - whether field path is holds simple value
func (fp *Permission_FieldTerminalPath) IsLeaf() bool {
return fp.selector == Permission_FieldPathSelectorName ||
fp.selector == Permission_FieldPathSelectorTitle ||
fp.selector == Permission_FieldPathSelectorDescription
}
func (fp *Permission_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath {
return []gotenobject.FieldPath{fp}
}
func (fp *Permission_FieldTerminalPath) WithIValue(value interface{}) Permission_FieldPathValue {
switch fp.selector {
case Permission_FieldPathSelectorName:
return &Permission_FieldTerminalPathValue{Permission_FieldTerminalPath: *fp, value: value.(*Name)}
case Permission_FieldPathSelectorTitle:
return &Permission_FieldTerminalPathValue{Permission_FieldTerminalPath: *fp, value: value.(string)}
case Permission_FieldPathSelectorDescription:
return &Permission_FieldTerminalPathValue{Permission_FieldTerminalPath: *fp, value: value.(string)}
default:
panic(fmt.Sprintf("Invalid selector for Permission: %d", fp.selector))
}
}
func (fp *Permission_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue {
return fp.WithIValue(value)
}
func (fp *Permission_FieldTerminalPath) WithIArrayOfValues(values interface{}) Permission_FieldPathArrayOfValues {
fpaov := &Permission_FieldTerminalPathArrayOfValues{Permission_FieldTerminalPath: *fp}
switch fp.selector {
case Permission_FieldPathSelectorName:
return &Permission_FieldTerminalPathArrayOfValues{Permission_FieldTerminalPath: *fp, values: values.([]*Name)}
case Permission_FieldPathSelectorTitle:
return &Permission_FieldTerminalPathArrayOfValues{Permission_FieldTerminalPath: *fp, values: values.([]string)}
case Permission_FieldPathSelectorDescription:
return &Permission_FieldTerminalPathArrayOfValues{Permission_FieldTerminalPath: *fp, values: values.([]string)}
default:
panic(fmt.Sprintf("Invalid selector for Permission: %d", fp.selector))
}
return fpaov
}
func (fp *Permission_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues {
return fp.WithIArrayOfValues(values)
}
func (fp *Permission_FieldTerminalPath) WithIArrayItemValue(value interface{}) Permission_FieldPathArrayItemValue {
switch fp.selector {
default:
panic(fmt.Sprintf("Invalid selector for Permission: %d", fp.selector))
}
}
func (fp *Permission_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue {
return fp.WithIArrayItemValue(value)
}
// Permission_FieldPathValue allows storing values for Permission fields according to their type
type Permission_FieldPathValue interface {
Permission_FieldPath
gotenobject.FieldPathValue
SetTo(target **Permission)
CompareWith(*Permission) (cmp int, comparable bool)
}
func ParsePermission_FieldPathValue(pathStr, valueStr string) (Permission_FieldPathValue, error) {
fp, err := ParsePermission_FieldPath(pathStr)
if err != nil {
return nil, err
}
fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr)
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, "error parsing Permission field path value from %s: %v", valueStr, err)
}
return fpv.(Permission_FieldPathValue), nil
}
func MustParsePermission_FieldPathValue(pathStr, valueStr string) Permission_FieldPathValue {
fpv, err := ParsePermission_FieldPathValue(pathStr, valueStr)
if err != nil {
panic(err)
}
return fpv
}
type Permission_FieldTerminalPathValue struct {
Permission_FieldTerminalPath
value interface{}
}
var _ Permission_FieldPathValue = (*Permission_FieldTerminalPathValue)(nil)
// GetRawValue returns raw value stored under selected path for 'Permission' as interface{}
func (fpv *Permission_FieldTerminalPathValue) GetRawValue() interface{} {
return fpv.value
}
func (fpv *Permission_FieldTerminalPathValue) AsNameValue() (*Name, bool) {
res, ok := fpv.value.(*Name)
return res, ok
}
func (fpv *Permission_FieldTerminalPathValue) AsTitleValue() (string, bool) {
res, ok := fpv.value.(string)
return res, ok
}
func (fpv *Permission_FieldTerminalPathValue) AsDescriptionValue() (string, bool) {
res, ok := fpv.value.(string)
return res, ok
}
// SetTo stores value for selected field for object Permission
func (fpv *Permission_FieldTerminalPathValue) SetTo(target **Permission) {
if *target == nil {
*target = new(Permission)
}
switch fpv.selector {
case Permission_FieldPathSelectorName:
(*target).Name = fpv.value.(*Name)
case Permission_FieldPathSelectorTitle:
(*target).Title = fpv.value.(string)
case Permission_FieldPathSelectorDescription:
(*target).Description = fpv.value.(string)
default:
panic(fmt.Sprintf("Invalid selector for Permission: %d", fpv.selector))
}
}
func (fpv *Permission_FieldTerminalPathValue) SetToRaw(target proto.Message) {
typedObject := target.(*Permission)
fpv.SetTo(&typedObject)
}
// CompareWith compares value in the 'Permission_FieldTerminalPathValue' with the value under path in 'Permission'.
func (fpv *Permission_FieldTerminalPathValue) CompareWith(source *Permission) (int, bool) {
switch fpv.selector {
case Permission_FieldPathSelectorName:
leftValue := fpv.value.(*Name)
rightValue := source.GetName()
if leftValue == nil {
if rightValue != nil {
return -1, true
}
return 0, true
}
if rightValue == nil {
return 1, true
}
if leftValue.String() == rightValue.String() {
return 0, true
} else if leftValue.String() < rightValue.String() {
return -1, true
} else {
return 1, true
}
case Permission_FieldPathSelectorTitle:
leftValue := fpv.value.(string)
rightValue := source.GetTitle()
if (leftValue) == (rightValue) {
return 0, true
} else if (leftValue) < (rightValue) {
return -1, true
} else {
return 1, true
}
case Permission_FieldPathSelectorDescription:
leftValue := fpv.value.(string)
rightValue := source.GetDescription()
if (leftValue) == (rightValue) {
return 0, true
} else if (leftValue) < (rightValue) {
return -1, true
} else {
return 1, true
}
default:
panic(fmt.Sprintf("Invalid selector for Permission: %d", fpv.selector))
}
}
func (fpv *Permission_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) {
return fpv.CompareWith(source.(*Permission))
}
// Permission_FieldPathArrayItemValue allows storing single item in Path-specific values for Permission according to their type
// Present only for array (repeated) types.
type Permission_FieldPathArrayItemValue interface {
gotenobject.FieldPathArrayItemValue
Permission_FieldPath
ContainsValue(*Permission) bool
}
// ParsePermission_FieldPathArrayItemValue parses string and JSON-encoded value to its Value
func ParsePermission_FieldPathArrayItemValue(pathStr, valueStr string) (Permission_FieldPathArrayItemValue, error) {
fp, err := ParsePermission_FieldPath(pathStr)
if err != nil {
return nil, err
}
fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr)
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, "error parsing Permission field path array item value from %s: %v", valueStr, err)
}
return fpaiv.(Permission_FieldPathArrayItemValue), nil
}
func MustParsePermission_FieldPathArrayItemValue(pathStr, valueStr string) Permission_FieldPathArrayItemValue {
fpaiv, err := ParsePermission_FieldPathArrayItemValue(pathStr, valueStr)
if err != nil {
panic(err)
}
return fpaiv
}
type Permission_FieldTerminalPathArrayItemValue struct {
Permission_FieldTerminalPath
value interface{}
}
var _ Permission_FieldPathArrayItemValue = (*Permission_FieldTerminalPathArrayItemValue)(nil)
// GetRawValue returns stored element value for array in object Permission as interface{}
func (fpaiv *Permission_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} {
return fpaiv.value
}
func (fpaiv *Permission_FieldTerminalPathArrayItemValue) GetSingle(source *Permission) (interface{}, bool) {
return nil, false
}
func (fpaiv *Permission_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) {
return fpaiv.GetSingle(source.(*Permission))
}
// Contains returns a boolean indicating if value that is being held is present in given 'Permission'
func (fpaiv *Permission_FieldTerminalPathArrayItemValue) ContainsValue(source *Permission) bool {
slice := fpaiv.Permission_FieldTerminalPath.Get(source)
for _, v := range slice {
if asProtoMsg, ok := fpaiv.value.(proto.Message); ok {
if proto.Equal(asProtoMsg, v.(proto.Message)) {
return true
}
} else if reflect.DeepEqual(v, fpaiv.value) {
return true
}
}
return false
}
// Permission_FieldPathArrayOfValues allows storing slice of values for Permission fields according to their type
type Permission_FieldPathArrayOfValues interface {
gotenobject.FieldPathArrayOfValues
Permission_FieldPath
}
func ParsePermission_FieldPathArrayOfValues(pathStr, valuesStr string) (Permission_FieldPathArrayOfValues, error) {
fp, err := ParsePermission_FieldPath(pathStr)
if err != nil {
return nil, err
}
fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr)
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, "error parsing Permission field path array of values from %s: %v", valuesStr, err)
}
return fpaov.(Permission_FieldPathArrayOfValues), nil
}
func MustParsePermission_FieldPathArrayOfValues(pathStr, valuesStr string) Permission_FieldPathArrayOfValues {
fpaov, err := ParsePermission_FieldPathArrayOfValues(pathStr, valuesStr)
if err != nil {
panic(err)
}
return fpaov
}
type Permission_FieldTerminalPathArrayOfValues struct {
Permission_FieldTerminalPath
values interface{}
}
var _ Permission_FieldPathArrayOfValues = (*Permission_FieldTerminalPathArrayOfValues)(nil)
func (fpaov *Permission_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) {
switch fpaov.selector {
case Permission_FieldPathSelectorName:
for _, v := range fpaov.values.([]*Name) {
values = append(values, v)
}
case Permission_FieldPathSelectorTitle:
for _, v := range fpaov.values.([]string) {
values = append(values, v)
}
case Permission_FieldPathSelectorDescription:
for _, v := range fpaov.values.([]string) {
values = append(values, v)
}
}
return
}
func (fpaov *Permission_FieldTerminalPathArrayOfValues) AsNameArrayOfValues() ([]*Name, bool) {
res, ok := fpaov.values.([]*Name)
return res, ok
}
func (fpaov *Permission_FieldTerminalPathArrayOfValues) AsTitleArrayOfValues() ([]string, bool) {
res, ok := fpaov.values.([]string)
return res, ok
}
func (fpaov *Permission_FieldTerminalPathArrayOfValues) AsDescriptionArrayOfValues() ([]string, bool) {
res, ok := fpaov.values.([]string)
return res, ok
}