github.com/cloudwan/edgelq-sdk@v1.15.4/alerting/resources/v1/policy/policy.pb.object_ext.go (about) 1 // Code generated by protoc-gen-goten-object 2 // File: edgelq/alerting/proto/v1/policy.proto 3 // DO NOT EDIT!!! 4 5 package policy 6 7 import ( 8 "fmt" 9 "sort" 10 11 "google.golang.org/protobuf/proto" 12 googlefieldmaskpb "google.golang.org/protobuf/types/known/fieldmaskpb" 13 14 gotenobject "github.com/cloudwan/goten-sdk/runtime/object" 15 ) 16 17 // proto imports 18 import ( 19 rcommon "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/common" 20 document "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/document" 21 notification_channel "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/notification_channel" 22 policy_template "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/policy_template" 23 iam_project "github.com/cloudwan/edgelq-sdk/iam/resources/v1/project" 24 meta "github.com/cloudwan/goten-sdk/types/meta" 25 fieldmaskpb "google.golang.org/protobuf/types/known/fieldmaskpb" 26 ) 27 28 // ensure the imports are used 29 var ( 30 _ = new(fmt.Stringer) 31 _ = new(sort.Interface) 32 33 _ = new(proto.Message) 34 _ = googlefieldmaskpb.FieldMask{} 35 36 _ = new(gotenobject.FieldPath) 37 ) 38 39 // make sure we're using proto imports 40 var ( 41 _ = &document.Document{} 42 _ = ¬ification_channel.NotificationChannel{} 43 _ = &policy_template.PolicyTemplate{} 44 _ = &rcommon.LogCndSpec{} 45 _ = &iam_project.Project{} 46 _ = &fieldmaskpb.FieldMask{} 47 _ = &meta.Meta{} 48 ) 49 50 func (o *Policy) GotenObjectExt() {} 51 52 func (o *Policy) MakeFullFieldMask() *Policy_FieldMask { 53 return FullPolicy_FieldMask() 54 } 55 56 func (o *Policy) MakeRawFullFieldMask() gotenobject.FieldMask { 57 return FullPolicy_FieldMask() 58 } 59 60 func (o *Policy) MakeDiffFieldMask(other *Policy) *Policy_FieldMask { 61 if o == nil && other == nil { 62 return &Policy_FieldMask{} 63 } 64 if o == nil || other == nil { 65 return FullPolicy_FieldMask() 66 } 67 68 res := &Policy_FieldMask{} 69 if o.GetName().String() != other.GetName().String() { 70 res.Paths = append(res.Paths, &Policy_FieldTerminalPath{selector: Policy_FieldPathSelectorName}) 71 } 72 { 73 subMask := o.GetMetadata().MakeDiffFieldMask(other.GetMetadata()) 74 if subMask.IsFull() { 75 res.Paths = append(res.Paths, &Policy_FieldTerminalPath{selector: Policy_FieldPathSelectorMetadata}) 76 } else { 77 for _, subpath := range subMask.Paths { 78 res.Paths = append(res.Paths, &Policy_FieldSubPath{selector: Policy_FieldPathSelectorMetadata, subPath: subpath}) 79 } 80 } 81 } 82 if o.GetDisplayName() != other.GetDisplayName() { 83 res.Paths = append(res.Paths, &Policy_FieldTerminalPath{selector: Policy_FieldPathSelectorDisplayName}) 84 } 85 if o.GetDescription() != other.GetDescription() { 86 res.Paths = append(res.Paths, &Policy_FieldTerminalPath{selector: Policy_FieldPathSelectorDescription}) 87 } 88 89 if len(o.GetSupportingDocs()) == len(other.GetSupportingDocs()) { 90 for i, lValue := range o.GetSupportingDocs() { 91 rValue := other.GetSupportingDocs()[i] 92 if lValue.String() != rValue.String() { 93 res.Paths = append(res.Paths, &Policy_FieldTerminalPath{selector: Policy_FieldPathSelectorSupportingDocs}) 94 break 95 } 96 } 97 } else { 98 res.Paths = append(res.Paths, &Policy_FieldTerminalPath{selector: Policy_FieldPathSelectorSupportingDocs}) 99 } 100 { 101 subMask := o.GetSpec().MakeDiffFieldMask(other.GetSpec()) 102 if subMask.IsFull() { 103 res.Paths = append(res.Paths, &Policy_FieldTerminalPath{selector: Policy_FieldPathSelectorSpec}) 104 } else { 105 for _, subpath := range subMask.Paths { 106 res.Paths = append(res.Paths, &Policy_FieldSubPath{selector: Policy_FieldPathSelectorSpec, subPath: subpath}) 107 } 108 } 109 } 110 { 111 subMask := o.GetTemplateSource().MakeDiffFieldMask(other.GetTemplateSource()) 112 if subMask.IsFull() { 113 res.Paths = append(res.Paths, &Policy_FieldTerminalPath{selector: Policy_FieldPathSelectorTemplateSource}) 114 } else { 115 for _, subpath := range subMask.Paths { 116 res.Paths = append(res.Paths, &Policy_FieldSubPath{selector: Policy_FieldPathSelectorTemplateSource, subPath: subpath}) 117 } 118 } 119 } 120 121 if len(o.GetNotificationChannels()) == len(other.GetNotificationChannels()) { 122 for i, lValue := range o.GetNotificationChannels() { 123 rValue := other.GetNotificationChannels()[i] 124 if lValue.String() != rValue.String() { 125 res.Paths = append(res.Paths, &Policy_FieldTerminalPath{selector: Policy_FieldPathSelectorNotificationChannels}) 126 break 127 } 128 } 129 } else { 130 res.Paths = append(res.Paths, &Policy_FieldTerminalPath{selector: Policy_FieldPathSelectorNotificationChannels}) 131 } 132 return res 133 } 134 135 func (o *Policy) MakeRawDiffFieldMask(other gotenobject.GotenObjectExt) gotenobject.FieldMask { 136 return o.MakeDiffFieldMask(other.(*Policy)) 137 } 138 139 func (o *Policy) Clone() *Policy { 140 if o == nil { 141 return nil 142 } 143 result := &Policy{} 144 if o.Name == nil { 145 result.Name = nil 146 } else if data, err := o.Name.ProtoString(); err != nil { 147 panic(err) 148 } else { 149 result.Name = &Name{} 150 if err := result.Name.ParseProtoString(data); err != nil { 151 panic(err) 152 } 153 } 154 result.Metadata = o.Metadata.Clone() 155 result.DisplayName = o.DisplayName 156 result.Description = o.Description 157 result.SupportingDocs = make([]*document.Reference, len(o.SupportingDocs)) 158 for i, sourceValue := range o.SupportingDocs { 159 if sourceValue == nil { 160 result.SupportingDocs[i] = nil 161 } else if data, err := sourceValue.ProtoString(); err != nil { 162 panic(err) 163 } else { 164 result.SupportingDocs[i] = &document.Reference{} 165 if err := result.SupportingDocs[i].ParseProtoString(data); err != nil { 166 panic(err) 167 } 168 } 169 } 170 result.Spec = o.Spec.Clone() 171 result.TemplateSource = o.TemplateSource.Clone() 172 result.NotificationChannels = make([]*notification_channel.Reference, len(o.NotificationChannels)) 173 for i, sourceValue := range o.NotificationChannels { 174 if sourceValue == nil { 175 result.NotificationChannels[i] = nil 176 } else if data, err := sourceValue.ProtoString(); err != nil { 177 panic(err) 178 } else { 179 result.NotificationChannels[i] = ¬ification_channel.Reference{} 180 if err := result.NotificationChannels[i].ParseProtoString(data); err != nil { 181 panic(err) 182 } 183 } 184 } 185 return result 186 } 187 188 func (o *Policy) CloneRaw() gotenobject.GotenObjectExt { 189 return o.Clone() 190 } 191 192 func (o *Policy) Merge(source *Policy) { 193 if source.GetName() != nil { 194 if data, err := source.GetName().ProtoString(); err != nil { 195 panic(err) 196 } else { 197 o.Name = &Name{} 198 if err := o.Name.ParseProtoString(data); err != nil { 199 panic(err) 200 } 201 } 202 } else { 203 o.Name = nil 204 } 205 if source.GetMetadata() != nil { 206 if o.Metadata == nil { 207 o.Metadata = new(meta.Meta) 208 } 209 o.Metadata.Merge(source.GetMetadata()) 210 } 211 o.DisplayName = source.GetDisplayName() 212 o.Description = source.GetDescription() 213 for _, sourceValue := range source.GetSupportingDocs() { 214 exists := false 215 for _, currentValue := range o.SupportingDocs { 216 leftProtoStr, _ := currentValue.ProtoString() 217 rightProtoStr, _ := sourceValue.ProtoString() 218 if leftProtoStr == rightProtoStr { 219 exists = true 220 break 221 } 222 } 223 if !exists { 224 var newDstElement *document.Reference 225 if sourceValue != nil { 226 if data, err := sourceValue.ProtoString(); err != nil { 227 panic(err) 228 } else { 229 newDstElement = &document.Reference{} 230 if err := newDstElement.ParseProtoString(data); err != nil { 231 panic(err) 232 } 233 } 234 } 235 o.SupportingDocs = append(o.SupportingDocs, newDstElement) 236 } 237 } 238 239 if source.GetSpec() != nil { 240 if o.Spec == nil { 241 o.Spec = new(rcommon.PolicySpec) 242 } 243 o.Spec.Merge(source.GetSpec()) 244 } 245 if source.GetTemplateSource() != nil { 246 if o.TemplateSource == nil { 247 o.TemplateSource = new(Policy_TemplateSource) 248 } 249 o.TemplateSource.Merge(source.GetTemplateSource()) 250 } 251 for _, sourceValue := range source.GetNotificationChannels() { 252 exists := false 253 for _, currentValue := range o.NotificationChannels { 254 leftProtoStr, _ := currentValue.ProtoString() 255 rightProtoStr, _ := sourceValue.ProtoString() 256 if leftProtoStr == rightProtoStr { 257 exists = true 258 break 259 } 260 } 261 if !exists { 262 var newDstElement *notification_channel.Reference 263 if sourceValue != nil { 264 if data, err := sourceValue.ProtoString(); err != nil { 265 panic(err) 266 } else { 267 newDstElement = ¬ification_channel.Reference{} 268 if err := newDstElement.ParseProtoString(data); err != nil { 269 panic(err) 270 } 271 } 272 } 273 o.NotificationChannels = append(o.NotificationChannels, newDstElement) 274 } 275 } 276 277 } 278 279 func (o *Policy) MergeRaw(source gotenobject.GotenObjectExt) { 280 o.Merge(source.(*Policy)) 281 } 282 283 func (o *Policy_TemplateSource) GotenObjectExt() {} 284 285 func (o *Policy_TemplateSource) MakeFullFieldMask() *Policy_TemplateSource_FieldMask { 286 return FullPolicy_TemplateSource_FieldMask() 287 } 288 289 func (o *Policy_TemplateSource) MakeRawFullFieldMask() gotenobject.FieldMask { 290 return FullPolicy_TemplateSource_FieldMask() 291 } 292 293 func (o *Policy_TemplateSource) MakeDiffFieldMask(other *Policy_TemplateSource) *Policy_TemplateSource_FieldMask { 294 if o == nil && other == nil { 295 return &Policy_TemplateSource_FieldMask{} 296 } 297 if o == nil || other == nil { 298 return FullPolicy_TemplateSource_FieldMask() 299 } 300 301 res := &Policy_TemplateSource_FieldMask{} 302 if o.GetTemplate().String() != other.GetTemplate().String() { 303 res.Paths = append(res.Paths, &PolicyTemplateSource_FieldTerminalPath{selector: PolicyTemplateSource_FieldPathSelectorTemplate}) 304 } 305 if !proto.Equal(o.GetUpdatedFields(), other.GetUpdatedFields()) { 306 res.Paths = append(res.Paths, &PolicyTemplateSource_FieldTerminalPath{selector: PolicyTemplateSource_FieldPathSelectorUpdatedFields}) 307 } 308 return res 309 } 310 311 func (o *Policy_TemplateSource) MakeRawDiffFieldMask(other gotenobject.GotenObjectExt) gotenobject.FieldMask { 312 return o.MakeDiffFieldMask(other.(*Policy_TemplateSource)) 313 } 314 315 func (o *Policy_TemplateSource) Clone() *Policy_TemplateSource { 316 if o == nil { 317 return nil 318 } 319 result := &Policy_TemplateSource{} 320 if o.Template == nil { 321 result.Template = nil 322 } else if data, err := o.Template.ProtoString(); err != nil { 323 panic(err) 324 } else { 325 result.Template = &policy_template.Reference{} 326 if err := result.Template.ParseProtoString(data); err != nil { 327 panic(err) 328 } 329 } 330 result.UpdatedFields = proto.Clone(o.UpdatedFields).(*fieldmaskpb.FieldMask) 331 return result 332 } 333 334 func (o *Policy_TemplateSource) CloneRaw() gotenobject.GotenObjectExt { 335 return o.Clone() 336 } 337 338 func (o *Policy_TemplateSource) Merge(source *Policy_TemplateSource) { 339 if source.GetTemplate() != nil { 340 if data, err := source.GetTemplate().ProtoString(); err != nil { 341 panic(err) 342 } else { 343 o.Template = &policy_template.Reference{} 344 if err := o.Template.ParseProtoString(data); err != nil { 345 panic(err) 346 } 347 } 348 } else { 349 o.Template = nil 350 } 351 if source.GetUpdatedFields() != nil { 352 if o.UpdatedFields == nil { 353 o.UpdatedFields = new(fieldmaskpb.FieldMask) 354 } 355 proto.Merge(o.UpdatedFields, source.GetUpdatedFields()) 356 } 357 } 358 359 func (o *Policy_TemplateSource) MergeRaw(source gotenobject.GotenObjectExt) { 360 o.Merge(source.(*Policy_TemplateSource)) 361 }