github.com/cloudwan/edgelq-sdk@v1.15.4/alerting/resources/v1/ts_condition_template/ts_condition_template.pb.namebuilder.go (about) 1 // Code generated by protoc-gen-goten-resource 2 // Resource: TsConditionTemplate 3 // DO NOT EDIT!!! 4 5 package ts_condition_template 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 policy_template "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/policy_template" 16 meta "github.com/cloudwan/goten-sdk/types/meta" 17 ) 18 19 // make sure we're using proto imports 20 var ( 21 _ = &document.Document{} 22 _ = &policy_template.PolicyTemplate{} 23 _ = &rcommon.LogCndSpec{} 24 _ = &meta.Meta{} 25 ) 26 27 const ( 28 NamePattern_Project_PolicyTemplate = "projects/{project}/policyTemplates/{policy_template}/tsConditionTemplates/{ts_condition_template}" 29 ) 30 31 type NamePattern struct { 32 Pattern gotenresource.NamePattern `firestore:"pattern"` 33 } 34 35 type NameBuilder struct { 36 nameObj Name 37 } 38 39 func NewNameBuilder() *NameBuilder { 40 return &NameBuilder{ 41 nameObj: Name{ 42 TsConditionTemplateId: gotenresource.WildcardId, 43 ParentName: ParentName{ 44 NamePattern: NamePattern{ 45 // Set default pattern - just first. 46 Pattern: NamePattern_Project_PolicyTemplate, 47 }, 48 }, 49 }, 50 } 51 } 52 53 func (b *NameBuilder) Name() *Name { 54 copied := b.nameObj 55 return &copied 56 } 57 58 func (b *NameBuilder) Reference() *Reference { 59 return b.nameObj.AsReference() 60 } 61 62 func (b *NameBuilder) Parent() *ParentName { 63 copied := b.nameObj.ParentName 64 return &copied 65 } 66 67 func (b *NameBuilder) ParentReference() *ParentReference { 68 return b.nameObj.ParentName.AsReference() 69 } 70 71 func (b *NameBuilder) SetId(id string) *NameBuilder { 72 b.nameObj.TsConditionTemplateId = id 73 return b 74 } 75 76 func (b *NameBuilder) SetPolicyTemplate(parent *policy_template.Name) *NameBuilder { 77 parentName := &b.nameObj.ParentName 78 79 switch parent.Pattern { 80 case policy_template.NamePattern_Project: 81 parentName.Pattern = NamePattern_Project_PolicyTemplate 82 } 83 parentName.ProjectId = parent.ProjectId 84 parentName.PolicyTemplateId = parent.PolicyTemplateId 85 return b 86 } 87 88 func (b *NameBuilder) SetProjectId(id string) *NameBuilder { 89 parentName := &b.nameObj.ParentName 90 parentName.ProjectId = id 91 92 // Set pattern if something matches for this set of IDs 93 if parentName.ProjectId != "" && parentName.PolicyTemplateId != "" { 94 parentName.Pattern = NamePattern_Project_PolicyTemplate 95 } 96 return b 97 } 98 99 func (b *NameBuilder) SetPolicyTemplateId(id string) *NameBuilder { 100 parentName := &b.nameObj.ParentName 101 parentName.PolicyTemplateId = id 102 103 // Set pattern if something matches for this set of IDs 104 if parentName.ProjectId != "" && parentName.PolicyTemplateId != "" { 105 parentName.Pattern = NamePattern_Project_PolicyTemplate 106 } 107 return b 108 }