-
Notifications
You must be signed in to change notification settings - Fork 1
/
plan_assignment.pb.namebuilder.go
148 lines (123 loc) · 3.71 KB
/
plan_assignment.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
148
// Code generated by protoc-gen-goten-resource
// Resource: PlanAssignment
// DO NOT EDIT!!!
package plan_assignment
import (
gotenresource "github.com/cloudwan/goten-sdk/runtime/resource"
)
// proto imports
import (
iam_organization "github.com/cloudwan/edgelq-sdk/iam/resources/v1/organization"
iam_project "github.com/cloudwan/edgelq-sdk/iam/resources/v1/project"
accepted_plan "github.com/cloudwan/edgelq-sdk/limits/resources/v1/accepted_plan"
common "github.com/cloudwan/edgelq-sdk/limits/resources/v1/common"
plan "github.com/cloudwan/edgelq-sdk/limits/resources/v1/plan"
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 (
_ = &iam_organization.Organization{}
_ = &iam_project.Project{}
_ = &accepted_plan.AcceptedPlan{}
_ = &common.RegionalPlanAssignment{}
_ = &plan.Plan{}
_ = &meta_service.Service{}
_ = &meta.Meta{}
)
const (
NamePattern_Service = "services/{service}/planAssignments/{plan_assignment}"
NamePattern_Project = "projects/{project}/planAssignments/{plan_assignment}"
NamePattern_Organization = "organizations/{organization}/planAssignments/{plan_assignment}"
)
type NamePattern struct {
Pattern gotenresource.NamePattern `firestore:"pattern"`
}
type NameBuilder struct {
nameObj Name
}
func NewNameBuilder() *NameBuilder {
return &NameBuilder{
nameObj: Name{
PlanAssignmentId: gotenresource.WildcardId,
ParentName: ParentName{
NamePattern: NamePattern{
// Set default pattern - just first.
Pattern: NamePattern_Service,
},
},
},
}
}
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.PlanAssignmentId = id
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) SetProject(parent *iam_project.Name) *NameBuilder {
parentName := &b.nameObj.ParentName
switch parent.Pattern {
case iam_project.NamePattern_Nil:
parentName.Pattern = NamePattern_Project
}
parentName.ProjectId = parent.ProjectId
return b
}
func (b *NameBuilder) SetOrganization(parent *iam_organization.Name) *NameBuilder {
parentName := &b.nameObj.ParentName
switch parent.Pattern {
case iam_organization.NamePattern_Nil:
parentName.Pattern = NamePattern_Organization
}
parentName.OrganizationId = parent.OrganizationId
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
}
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
}