github.com/cloudwan/edgelq-sdk@v1.15.4/alerting/resources/v1/ts_condition/ts_condition.pb.namebuilder.go (about) 1 // Code generated by protoc-gen-goten-resource 2 // Resource: TsCondition 3 // DO NOT EDIT!!! 4 5 package ts_condition 6 7 import ( 8 gotenresource "github.com/cloudwan/goten-sdk/runtime/resource" 9 ) 10 11 // proto imports 12 import ( 13 rcommon "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/common" 14 document "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/document" 15 log_condition_template "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/log_condition_template" 16 policy "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/policy" 17 meta "github.com/cloudwan/goten-sdk/types/meta" 18 fieldmaskpb "google.golang.org/protobuf/types/known/fieldmaskpb" 19 ) 20 21 // make sure we're using proto imports 22 var ( 23 _ = &document.Document{} 24 _ = &log_condition_template.LogConditionTemplate{} 25 _ = &policy.Policy{} 26 _ = &rcommon.LogCndSpec{} 27 _ = &fieldmaskpb.FieldMask{} 28 _ = &meta.Meta{} 29 ) 30 31 const ( 32 NamePattern_Project_Policy = "projects/{project}/policies/{policy}/tsConditions/{ts_condition}" 33 ) 34 35 type NamePattern struct { 36 Pattern gotenresource.NamePattern `firestore:"pattern"` 37 } 38 39 type NameBuilder struct { 40 nameObj Name 41 } 42 43 func NewNameBuilder() *NameBuilder { 44 return &NameBuilder{ 45 nameObj: Name{ 46 TsConditionId: gotenresource.WildcardId, 47 ParentName: ParentName{ 48 NamePattern: NamePattern{ 49 // Set default pattern - just first. 50 Pattern: NamePattern_Project_Policy, 51 }, 52 }, 53 }, 54 } 55 } 56 57 func (b *NameBuilder) Name() *Name { 58 copied := b.nameObj 59 return &copied 60 } 61 62 func (b *NameBuilder) Reference() *Reference { 63 return b.nameObj.AsReference() 64 } 65 66 func (b *NameBuilder) Parent() *ParentName { 67 copied := b.nameObj.ParentName 68 return &copied 69 } 70 71 func (b *NameBuilder) ParentReference() *ParentReference { 72 return b.nameObj.ParentName.AsReference() 73 } 74 75 func (b *NameBuilder) SetId(id string) *NameBuilder { 76 b.nameObj.TsConditionId = id 77 return b 78 } 79 80 func (b *NameBuilder) SetPolicy(parent *policy.Name) *NameBuilder { 81 parentName := &b.nameObj.ParentName 82 83 switch parent.Pattern { 84 case policy.NamePattern_Project: 85 parentName.Pattern = NamePattern_Project_Policy 86 } 87 parentName.ProjectId = parent.ProjectId 88 parentName.PolicyId = parent.PolicyId 89 return b 90 } 91 92 func (b *NameBuilder) SetProjectId(id string) *NameBuilder { 93 parentName := &b.nameObj.ParentName 94 parentName.ProjectId = id 95 96 // Set pattern if something matches for this set of IDs 97 if parentName.ProjectId != "" && parentName.PolicyId != "" { 98 parentName.Pattern = NamePattern_Project_Policy 99 } 100 return b 101 } 102 103 func (b *NameBuilder) SetPolicyId(id string) *NameBuilder { 104 parentName := &b.nameObj.ParentName 105 parentName.PolicyId = id 106 107 // Set pattern if something matches for this set of IDs 108 if parentName.ProjectId != "" && parentName.PolicyId != "" { 109 parentName.Pattern = NamePattern_Project_Policy 110 } 111 return b 112 }