-
Notifications
You must be signed in to change notification settings - Fork 1
/
plan_assignment_request.pb.name.go
602 lines (526 loc) · 14.3 KB
/
plan_assignment_request.pb.name.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
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
// Code generated by protoc-gen-goten-resource
// Resource: PlanAssignmentRequest
// DO NOT EDIT!!!
package plan_assignment_request
import (
"fmt"
"net/url"
"reflect"
"regexp"
"strings"
"github.com/google/cel-go/common/types"
"github.com/google/cel-go/common/types/ref"
"github.com/google/cel-go/common/types/traits"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/proto"
"github.com/cloudwan/goten-sdk/runtime/goten"
gotenresource "github.com/cloudwan/goten-sdk/runtime/resource"
)
// proto imports
import (
ntt_meta "github.com/cloudwan/edgelq-sdk/common/types/meta"
iam_organization "github.com/cloudwan/edgelq-sdk/iam/resources/v1alpha2/organization"
iam_project "github.com/cloudwan/edgelq-sdk/iam/resources/v1alpha2/project"
common "github.com/cloudwan/edgelq-sdk/limits/resources/v1alpha2/common"
plan "github.com/cloudwan/edgelq-sdk/limits/resources/v1alpha2/plan"
plan_assignment "github.com/cloudwan/edgelq-sdk/limits/resources/v1alpha2/plan_assignment"
meta_service "github.com/cloudwan/edgelq-sdk/meta/resources/v1alpha2/service"
)
// ensure the imports are used
var (
_ = codes.NotFound
_ = new(fmt.Stringer)
_ = new(proto.Message)
_ = status.Status{}
_ = url.URL{}
_ = strings.Builder{}
_ = new(goten.GotenMessage)
_ = new(gotenresource.ListQuery)
)
// make sure we're using proto imports
var (
_ = &ntt_meta.Meta{}
_ = &iam_organization.Organization{}
_ = &iam_project.Project{}
_ = &common.Allowance{}
_ = &plan.Plan{}
_ = &plan_assignment.PlanAssignment{}
_ = &meta_service.Service{}
)
var planAssignmentRequest_RegexpId = regexp.MustCompile("^(?P<plan_assignment_request_id>[\\w][\\w.-]{0,127})$")
var regexPath_Project = regexp.MustCompile("^projects/(?P<project_id>-|[\\w][\\w.-]{0,127})/planAssignmentRequests/(?P<plan_assignment_request_id>-|[\\w][\\w.-]{0,127})$")
var regexPath_Organization = regexp.MustCompile("^organizations/(?P<organization_id>-|[\\w][\\w.-]{0,127})/planAssignmentRequests/(?P<plan_assignment_request_id>-|[\\w][\\w.-]{0,127})$")
func (r *PlanAssignmentRequest) MaybePopulateDefaults() error {
planAssignmentRequestInterface := interface{}(r)
if defaulter, ok := planAssignmentRequestInterface.(goten.Defaulter); ok {
return defaulter.PopulateDefaults()
}
return nil
}
func (r *PlanAssignmentRequest) GetRawName() gotenresource.Name {
return r.GetName()
}
func (r *PlanAssignmentRequest) GetResourceDescriptor() gotenresource.Descriptor {
return descriptor
}
type Name struct {
ParentName
PlanAssignmentRequestId string `firestore:"planAssignmentRequestId"`
}
func ParseName(name string) (*Name, error) {
var matches []string
if matches = regexPath_Project.FindStringSubmatch(name); matches != nil {
return NewNameBuilder().
SetProjectId(matches[1]).
SetId(matches[2]).
Name(), nil
}
if matches = regexPath_Organization.FindStringSubmatch(name); matches != nil {
return NewNameBuilder().
SetOrganizationId(matches[1]).
SetId(matches[2]).
Name(), nil
}
return nil, status.Errorf(codes.InvalidArgument, "unable to parse '%s' as PlanAssignmentRequest name", name)
}
func MustParseName(name string) *Name {
result, err := ParseName(name)
if err != nil {
panic(err)
}
return result
}
func ParseNameOrId(nameOrId string) (*Name, error) {
name, err := ParseName(nameOrId)
if err == nil {
return name, err
}
if planAssignmentRequest_RegexpId.MatchString(nameOrId) {
return &Name{PlanAssignmentRequestId: nameOrId}, nil
} else {
return nil, fmt.Errorf("unable to parse '%s' as PlanAssignmentRequest name or id", nameOrId)
}
}
func (name *Name) SetFromSegments(segments gotenresource.NameSegments) error {
if len(segments) == 0 {
return status.Errorf(codes.InvalidArgument, "No segments given for PlanAssignmentRequest name")
}
if err := name.ParentName.SetFromSegments(segments[:len(segments)-1]); err != nil {
return err
}
if segments[len(segments)-1].CollectionLowerJson != "planAssignmentRequests" {
return status.Errorf(codes.InvalidArgument, "unable to use segments %s to form PlanAssignmentRequest name", segments)
}
name.PlanAssignmentRequestId = segments[len(segments)-1].Id
return nil
}
func (name *Name) GetProjectName() *iam_project.Name {
if name == nil {
return nil
}
return name.ParentName.GetProjectName()
}
func (name *Name) GetOrganizationName() *iam_organization.Name {
if name == nil {
return nil
}
return name.ParentName.GetOrganizationName()
}
func (name *Name) IsSpecified() bool {
if name == nil || name.Pattern == "" || name.PlanAssignmentRequestId == "" {
return false
}
return name.ParentName.IsSpecified()
}
func (name *Name) IsFullyQualified() bool {
if name == nil {
return false
}
if name.ParentName.IsFullyQualified() == false {
return false
}
if name.PlanAssignmentRequestId == "" || name.PlanAssignmentRequestId == gotenresource.WildcardId {
return false
}
return true
}
func (name *Name) FullyQualifiedName() (string, error) {
if !name.IsFullyQualified() {
return "", status.Errorf(codes.InvalidArgument, "Name for PlanAssignmentRequest is not fully qualified")
}
return fmt.Sprintf("//limits.edgelq.com/%s", name.String()), nil
}
func (name *Name) String() string {
if name == nil {
return "<nil>"
}
if valueStr, err := name.ProtoString(); err != nil {
panic(err)
} else {
return valueStr
}
}
func (name *Name) AsReference() *Reference {
return &Reference{Name: *name}
}
func (name *Name) AsRawReference() gotenresource.Reference {
return name.AsReference()
}
func (name *Name) GetResourceDescriptor() gotenresource.Descriptor {
return descriptor
}
func (name *Name) GetPattern() gotenresource.NamePattern {
if name == nil {
return ""
}
return name.Pattern
}
func (name *Name) GetIdParts() map[string]string {
if name != nil {
return map[string]string{
"projectId": name.ProjectId,
"planAssignmentRequestId": name.PlanAssignmentRequestId,
"organizationId": name.OrganizationId,
}
}
return map[string]string{
"projectId": "",
"planAssignmentRequestId": "",
"organizationId": "",
}
}
func (name *Name) GetSegments() gotenresource.NameSegments {
if name == nil || name.Pattern == "" {
return nil
}
segments := name.ParentName.GetSegments()
return append(segments, gotenresource.NameSegment{
CollectionLowerJson: "planAssignmentRequests",
Id: name.PlanAssignmentRequestId,
})
}
func (name *Name) GetIParentName() gotenresource.Name {
if name == nil {
return (*ParentName)(nil)
}
return &name.ParentName
}
func (name *Name) GetIUnderlyingParentName() gotenresource.Name {
if parentName := name.GetProjectName(); parentName != nil {
return parentName
}
if parentName := name.GetOrganizationName(); parentName != nil {
return parentName
}
return nil
}
// implement methods required by protobuf-go library for string-struct conversion
func (name *Name) ProtoString() (string, error) {
if name == nil {
return "", nil
}
result := ""
parentPrefix, err := name.ParentName.ProtoString()
if err != nil {
return "", err
}
if parentPrefix != "" {
result += parentPrefix + "/"
}
result += "planAssignmentRequests/" + name.PlanAssignmentRequestId
return result, nil
}
func (name *Name) ParseProtoString(data string) error {
parsed, err := ParseName(data)
if err != nil {
return err
}
*name = *parsed
return nil
}
// GotenEqual returns true if other is of same type and paths are equal (implements goten.Equaler interface)
func (name *Name) GotenEqual(other interface{}) bool {
if other == nil {
return name == nil
}
other1, ok := other.(*Name)
if !ok {
other2, ok := other.(Name)
if ok {
other1 = &other2
} else {
return false
}
}
if other1 == nil {
return name == nil
} else if name == nil {
return false
}
if name.ParentName.GotenEqual(other1.ParentName) == false {
return false
}
if name.PlanAssignmentRequestId != other1.PlanAssignmentRequestId {
return false
}
return true
}
// Matches is same as GotenEqual, but also will accept "other" if name is wildcard.
func (name *Name) Matches(other interface{}) bool {
if other == nil {
return name == nil
}
other1, ok := other.(*Name)
if !ok {
other2, ok := other.(Name)
if ok {
other1 = &other2
} else {
return false
}
}
if other1 == nil {
return name == nil
} else if name == nil {
return false
}
if name.ParentName.Matches(other1.ParentName) == false {
return false
}
if name.PlanAssignmentRequestId != other1.PlanAssignmentRequestId {
return name.PlanAssignmentRequestId == gotenresource.WildcardId
}
return true
}
// Google CEL integration Type
var celName = types.NewTypeValue("Name", traits.ReceiverType)
func (name *Name) TypeName() string {
return ".ntt.limits.v1alpha2.PlanAssignmentRequest.Name"
}
func (name *Name) HasTrait(trait int) bool {
return trait == traits.ReceiverType
}
func (name *Name) Equal(other ref.Val) ref.Val {
return types.Bool(false)
}
func (name *Name) Value() interface{} {
return name
}
func (name *Name) Match(pattern ref.Val) ref.Val {
return types.Bool(true)
}
func (name *Name) Receive(function string, overload string, args []ref.Val) ref.Val {
switch function {
case "getId":
return types.String(name.PlanAssignmentRequestId)
case "satisfies":
rhsName, err := ParseName(string(args[0].(types.String)))
if err != nil {
return types.ValOrErr(celName, "function %s name parse error: %s", function, err)
}
return types.Bool(rhsName.Matches(name))
default:
return types.ValOrErr(celName, "no such function - %s", function)
}
}
func (name *Name) ConvertToNative(typeDesc reflect.Type) (interface{}, error) {
panic("not required")
}
func (name *Name) ConvertToType(typeVal ref.Type) ref.Val {
switch typeVal.TypeName() {
case types.StringType.TypeName():
return types.String(name.String())
default:
panic(fmt.Errorf("unable to convert %s to CEL type %s", "Name", typeVal.TypeName()))
}
}
func (name *Name) Type() ref.Type {
return celName
}
// implement CustomTypeCliValue method
func (name *Name) SetFromCliFlag(raw string) error {
parsedName, err := ParseName(raw)
if err != nil {
return err
}
*name = *parsedName
return nil
}
type Reference struct {
Name
planAssignmentRequest *PlanAssignmentRequest
}
func MakeReference(name *Name, planAssignmentRequest *PlanAssignmentRequest) (*Reference, error) {
return &Reference{
Name: *name,
planAssignmentRequest: planAssignmentRequest,
}, nil
}
func ParseReference(name string) (*Reference, error) {
parsedName, err := ParseName(name)
if err != nil {
return nil, err
}
return MakeReference(parsedName, nil)
}
func MustParseReference(name string) *Reference {
result, err := ParseReference(name)
if err != nil {
panic(err)
}
return result
}
func (ref *Reference) Resolve(resolved *PlanAssignmentRequest) {
ref.planAssignmentRequest = resolved
}
func (ref *Reference) ResolveRaw(res gotenresource.Resource) error {
if res == nil {
ref.Resolve(nil)
return nil
}
if typedRes, ok := res.(*PlanAssignmentRequest); ok {
ref.Resolve(typedRes)
return nil
}
return status.Errorf(codes.Internal, "Invalid resource type for PlanAssignmentRequest: %s", reflect.TypeOf(res).Elem().Name())
}
func (ref *Reference) Resolved() bool {
return ref.planAssignmentRequest != nil
}
func (ref *Reference) ClearCached() {
ref.planAssignmentRequest = nil
}
func (ref *Reference) GetPlanAssignmentRequest() *PlanAssignmentRequest {
return ref.planAssignmentRequest
}
func (ref *Reference) GetRawResource() gotenresource.Resource {
return ref.planAssignmentRequest
}
func (ref *Reference) IsFullyQualified() bool {
if ref == nil {
return false
}
return ref.Name.IsFullyQualified()
}
func (ref *Reference) IsSpecified() bool {
if ref == nil {
return false
}
return ref.Name.IsSpecified()
}
func (ref *Reference) FullyQualifiedName() (string, error) {
if !ref.IsFullyQualified() {
return "", status.Errorf(codes.InvalidArgument, "Name for PlanAssignmentRequest is not fully qualified")
}
return fmt.Sprintf("//limits.edgelq.com/%s", ref.String()), nil
}
func (ref *Reference) GetResourceDescriptor() gotenresource.Descriptor {
return descriptor
}
func (ref *Reference) GetPattern() gotenresource.NamePattern {
if ref == nil {
return ""
}
return ref.Pattern
}
func (ref *Reference) GetIdParts() map[string]string {
if ref != nil {
return ref.Name.GetIdParts()
}
return map[string]string{
"projectId": "",
"planAssignmentRequestId": "",
"organizationId": "",
}
}
func (ref *Reference) GetSegments() gotenresource.NameSegments {
if ref != nil {
return ref.Name.GetSegments()
}
return nil
}
func (ref *Reference) GetIParentName() gotenresource.Name {
if ref == nil {
return (*ParentName)(nil)
}
return ref.Name.GetIParentName()
}
func (ref *Reference) GetIUnderlyingParentName() gotenresource.Name {
if ref != nil {
return ref.Name.GetIUnderlyingParentName()
}
return nil
}
func (ref *Reference) String() string {
if ref == nil {
return "<nil>"
}
return ref.Name.String()
}
// implement methods required by protobuf-go library for string-struct conversion
func (ref *Reference) ProtoString() (string, error) {
if ref == nil {
return "", nil
}
return ref.Name.ProtoString()
}
func (ref *Reference) ParseProtoString(data string) error {
parsed, err := ParseReference(data)
if err != nil {
return err
}
*ref = *parsed
return nil
}
// GotenEqual returns true if other is of same type and paths are equal (implements goten.Equaler interface)
func (ref *Reference) GotenEqual(other interface{}) bool {
if other == nil {
return ref == nil
}
other1, ok := other.(*Reference)
if !ok {
other2, ok := other.(Reference)
if ok {
other1 = &other2
} else {
return false
}
}
if other1 == nil {
return ref == nil
} else if ref == nil {
return false
}
return ref.Name.GotenEqual(other1.Name)
}
// Matches is same as GotenEqual, but also will accept "other" if name is wildcard.
func (name *Reference) Matches(other interface{}) bool {
if other == nil {
return name == nil
}
other1, ok := other.(*Reference)
if !ok {
other2, ok := other.(Reference)
if ok {
other1 = &other2
} else {
return false
}
}
if other1 == nil {
return name == nil
} else if name == nil {
return false
}
return name.Name.Matches(&other1.Name)
}
// implement CustomTypeCliValue method
func (ref *Reference) SetFromCliFlag(raw string) error {
parsedRef, err := ParseReference(raw)
if err != nil {
return err
}
*ref = *parsedRef
return nil
}