-
Notifications
You must be signed in to change notification settings - Fork 1
/
role_binding.pb.namebuilder.go
147 lines (122 loc) · 3.58 KB
/
role_binding.pb.namebuilder.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
// Code generated by protoc-gen-goten-resource
// Resource: RoleBinding
// DO NOT EDIT!!!
package role_binding
import (
gotenresource "github.com/cloudwan/goten-sdk/runtime/resource"
)
// proto imports
import (
condition "github.com/cloudwan/edgelq-sdk/iam/resources/v1/condition"
organization "github.com/cloudwan/edgelq-sdk/iam/resources/v1/organization"
project "github.com/cloudwan/edgelq-sdk/iam/resources/v1/project"
role "github.com/cloudwan/edgelq-sdk/iam/resources/v1/role"
meta_service "github.com/cloudwan/goten-sdk/meta-service/resources/v1/service"
meta "github.com/cloudwan/goten-sdk/types/meta"
)
// make sure we're using proto imports
var (
_ = &condition.Condition{}
_ = &organization.Organization{}
_ = &project.Project{}
_ = &role.Role{}
_ = &meta_service.Service{}
_ = &meta.Meta{}
)
const (
NamePattern_Nil = "roleBindings/{role_binding}"
NamePattern_Project = "projects/{project}/roleBindings/{role_binding}"
NamePattern_Organization = "organizations/{organization}/roleBindings/{role_binding}"
NamePattern_Service = "services/{service}/roleBindings/{role_binding}"
)
type NamePattern struct {
Pattern gotenresource.NamePattern `firestore:"pattern"`
}
type NameBuilder struct {
nameObj Name
}
func NewNameBuilder() *NameBuilder {
return &NameBuilder{
nameObj: Name{
RoleBindingId: gotenresource.WildcardId,
ParentName: ParentName{
NamePattern: NamePattern{
// Set default pattern - just first.
Pattern: NamePattern_Nil,
},
},
},
}
}
func (b *NameBuilder) Name() *Name {
copied := b.nameObj
return &copied
}
func (b *NameBuilder) Reference() *Reference {
return b.nameObj.AsReference()
}
func (b *NameBuilder) Parent() *ParentName {
copied := b.nameObj.ParentName
return &copied
}
func (b *NameBuilder) ParentReference() *ParentReference {
return b.nameObj.ParentName.AsReference()
}
func (b *NameBuilder) SetId(id string) *NameBuilder {
b.nameObj.RoleBindingId = id
return b
}
func (b *NameBuilder) SetProject(parent *project.Name) *NameBuilder {
parentName := &b.nameObj.ParentName
switch parent.Pattern {
case project.NamePattern_Nil:
parentName.Pattern = NamePattern_Project
}
parentName.ProjectId = parent.ProjectId
return b
}
func (b *NameBuilder) SetOrganization(parent *organization.Name) *NameBuilder {
parentName := &b.nameObj.ParentName
switch parent.Pattern {
case organization.NamePattern_Nil:
parentName.Pattern = NamePattern_Organization
}
parentName.OrganizationId = parent.OrganizationId
return b
}
func (b *NameBuilder) SetService(parent *meta_service.Name) *NameBuilder {
parentName := &b.nameObj.ParentName
switch parent.Pattern {
case meta_service.NamePattern_Nil:
parentName.Pattern = NamePattern_Service
}
parentName.ServiceId = parent.ServiceId
return b
}
func (b *NameBuilder) SetProjectId(id string) *NameBuilder {
parentName := &b.nameObj.ParentName
parentName.ProjectId = id
// Set pattern if something matches for this set of IDs
if parentName.ProjectId != "" {
parentName.Pattern = NamePattern_Project
}
return b
}
func (b *NameBuilder) SetOrganizationId(id string) *NameBuilder {
parentName := &b.nameObj.ParentName
parentName.OrganizationId = id
// Set pattern if something matches for this set of IDs
if parentName.OrganizationId != "" {
parentName.Pattern = NamePattern_Organization
}
return b
}
func (b *NameBuilder) SetServiceId(id string) *NameBuilder {
parentName := &b.nameObj.ParentName
parentName.ServiceId = id
// Set pattern if something matches for this set of IDs
if parentName.ServiceId != "" {
parentName.Pattern = NamePattern_Service
}
return b
}