github.com/cloudwan/edgelq-sdk@v1.15.4/monitoring/resources/v4/notification/notification.pb.namebuilder.go (about) 1 // Code generated by protoc-gen-goten-resource 2 // Resource: Notification 3 // DO NOT EDIT!!! 4 5 package notification 6 7 import ( 8 gotenresource "github.com/cloudwan/goten-sdk/runtime/resource" 9 ) 10 11 // proto imports 12 import ( 13 alert "github.com/cloudwan/edgelq-sdk/monitoring/resources/v4/alert" 14 alerting_condition "github.com/cloudwan/edgelq-sdk/monitoring/resources/v4/alerting_condition" 15 alerting_policy "github.com/cloudwan/edgelq-sdk/monitoring/resources/v4/alerting_policy" 16 common "github.com/cloudwan/edgelq-sdk/monitoring/resources/v4/common" 17 notification_channel "github.com/cloudwan/edgelq-sdk/monitoring/resources/v4/notification_channel" 18 project "github.com/cloudwan/edgelq-sdk/monitoring/resources/v4/project" 19 meta "github.com/cloudwan/goten-sdk/types/meta" 20 ) 21 22 // make sure we're using proto imports 23 var ( 24 _ = &alert.Alert{} 25 _ = &alerting_condition.AlertingCondition{} 26 _ = &alerting_policy.AlertingPolicy{} 27 _ = &common.LabelDescriptor{} 28 _ = ¬ification_channel.NotificationChannel{} 29 _ = &project.Project{} 30 _ = &meta.Meta{} 31 ) 32 33 const ( 34 NamePattern_Project_Region_AlertingPolicy = "projects/{project}/regions/{region}/alertingPolicies/{alerting_policy}/notifications/{notification}" 35 ) 36 37 type NamePattern struct { 38 Pattern gotenresource.NamePattern `firestore:"pattern"` 39 } 40 41 type NameBuilder struct { 42 nameObj Name 43 } 44 45 func NewNameBuilder() *NameBuilder { 46 return &NameBuilder{ 47 nameObj: Name{ 48 NotificationId: gotenresource.WildcardId, 49 ParentName: ParentName{ 50 NamePattern: NamePattern{ 51 // Set default pattern - just first. 52 Pattern: NamePattern_Project_Region_AlertingPolicy, 53 }, 54 }, 55 }, 56 } 57 } 58 59 func (b *NameBuilder) Name() *Name { 60 copied := b.nameObj 61 return &copied 62 } 63 64 func (b *NameBuilder) Reference() *Reference { 65 return b.nameObj.AsReference() 66 } 67 68 func (b *NameBuilder) Parent() *ParentName { 69 copied := b.nameObj.ParentName 70 return &copied 71 } 72 73 func (b *NameBuilder) ParentReference() *ParentReference { 74 return b.nameObj.ParentName.AsReference() 75 } 76 77 func (b *NameBuilder) SetId(id string) *NameBuilder { 78 b.nameObj.NotificationId = id 79 return b 80 } 81 82 func (b *NameBuilder) SetAlertingPolicy(parent *alerting_policy.Name) *NameBuilder { 83 parentName := &b.nameObj.ParentName 84 85 switch parent.Pattern { 86 case alerting_policy.NamePattern_Project_Region: 87 parentName.Pattern = NamePattern_Project_Region_AlertingPolicy 88 } 89 parentName.ProjectId = parent.ProjectId 90 parentName.RegionId = parent.RegionId 91 parentName.AlertingPolicyId = parent.AlertingPolicyId 92 return b 93 } 94 95 func (b *NameBuilder) SetProjectId(id string) *NameBuilder { 96 parentName := &b.nameObj.ParentName 97 parentName.ProjectId = id 98 99 // Set pattern if something matches for this set of IDs 100 if parentName.ProjectId != "" && parentName.RegionId != "" && parentName.AlertingPolicyId != "" { 101 parentName.Pattern = NamePattern_Project_Region_AlertingPolicy 102 } 103 return b 104 } 105 106 func (b *NameBuilder) SetRegionId(id string) *NameBuilder { 107 parentName := &b.nameObj.ParentName 108 parentName.RegionId = id 109 110 // Set pattern if something matches for this set of IDs 111 if parentName.ProjectId != "" && parentName.RegionId != "" && parentName.AlertingPolicyId != "" { 112 parentName.Pattern = NamePattern_Project_Region_AlertingPolicy 113 } 114 return b 115 } 116 117 func (b *NameBuilder) SetAlertingPolicyId(id string) *NameBuilder { 118 parentName := &b.nameObj.ParentName 119 parentName.AlertingPolicyId = id 120 121 // Set pattern if something matches for this set of IDs 122 if parentName.ProjectId != "" && parentName.RegionId != "" && parentName.AlertingPolicyId != "" { 123 parentName.Pattern = NamePattern_Project_Region_AlertingPolicy 124 } 125 return b 126 }