github.com/cloudwan/edgelq-sdk@v1.15.4/monitoring/resources/v4/alerting_policy/alerting_policy.pb.object_ext.go (about) 1 // Code generated by protoc-gen-goten-object 2 // File: edgelq/monitoring/proto/v4/alerting_policy.proto 3 // DO NOT EDIT!!! 4 5 package alerting_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 notification_channel "github.com/cloudwan/edgelq-sdk/monitoring/resources/v4/notification_channel" 20 project "github.com/cloudwan/edgelq-sdk/monitoring/resources/v4/project" 21 meta "github.com/cloudwan/goten-sdk/types/meta" 22 ) 23 24 // ensure the imports are used 25 var ( 26 _ = new(fmt.Stringer) 27 _ = new(sort.Interface) 28 29 _ = new(proto.Message) 30 _ = googlefieldmaskpb.FieldMask{} 31 32 _ = new(gotenobject.FieldPath) 33 ) 34 35 // make sure we're using proto imports 36 var ( 37 _ = ¬ification_channel.NotificationChannel{} 38 _ = &project.Project{} 39 _ = &meta.Meta{} 40 ) 41 42 func (o *AlertingPolicy) GotenObjectExt() {} 43 44 func (o *AlertingPolicy) MakeFullFieldMask() *AlertingPolicy_FieldMask { 45 return FullAlertingPolicy_FieldMask() 46 } 47 48 func (o *AlertingPolicy) MakeRawFullFieldMask() gotenobject.FieldMask { 49 return FullAlertingPolicy_FieldMask() 50 } 51 52 func (o *AlertingPolicy) MakeDiffFieldMask(other *AlertingPolicy) *AlertingPolicy_FieldMask { 53 if o == nil && other == nil { 54 return &AlertingPolicy_FieldMask{} 55 } 56 if o == nil || other == nil { 57 return FullAlertingPolicy_FieldMask() 58 } 59 60 res := &AlertingPolicy_FieldMask{} 61 if o.GetName().String() != other.GetName().String() { 62 res.Paths = append(res.Paths, &AlertingPolicy_FieldTerminalPath{selector: AlertingPolicy_FieldPathSelectorName}) 63 } 64 { 65 subMask := o.GetMetadata().MakeDiffFieldMask(other.GetMetadata()) 66 if subMask.IsFull() { 67 res.Paths = append(res.Paths, &AlertingPolicy_FieldTerminalPath{selector: AlertingPolicy_FieldPathSelectorMetadata}) 68 } else { 69 for _, subpath := range subMask.Paths { 70 res.Paths = append(res.Paths, &AlertingPolicy_FieldSubPath{selector: AlertingPolicy_FieldPathSelectorMetadata, subPath: subpath}) 71 } 72 } 73 } 74 if o.GetDisplayName() != other.GetDisplayName() { 75 res.Paths = append(res.Paths, &AlertingPolicy_FieldTerminalPath{selector: AlertingPolicy_FieldPathSelectorDisplayName}) 76 } 77 if o.GetDescription() != other.GetDescription() { 78 res.Paths = append(res.Paths, &AlertingPolicy_FieldTerminalPath{selector: AlertingPolicy_FieldPathSelectorDescription}) 79 } 80 { 81 subMask := o.GetDocumentation().MakeDiffFieldMask(other.GetDocumentation()) 82 if subMask.IsFull() { 83 res.Paths = append(res.Paths, &AlertingPolicy_FieldTerminalPath{selector: AlertingPolicy_FieldPathSelectorDocumentation}) 84 } else { 85 for _, subpath := range subMask.Paths { 86 res.Paths = append(res.Paths, &AlertingPolicy_FieldSubPath{selector: AlertingPolicy_FieldPathSelectorDocumentation, subPath: subpath}) 87 } 88 } 89 } 90 { 91 subMask := o.GetSpec().MakeDiffFieldMask(other.GetSpec()) 92 if subMask.IsFull() { 93 res.Paths = append(res.Paths, &AlertingPolicy_FieldTerminalPath{selector: AlertingPolicy_FieldPathSelectorSpec}) 94 } else { 95 for _, subpath := range subMask.Paths { 96 res.Paths = append(res.Paths, &AlertingPolicy_FieldSubPath{selector: AlertingPolicy_FieldPathSelectorSpec, subPath: subpath}) 97 } 98 } 99 } 100 { 101 subMask := o.GetState().MakeDiffFieldMask(other.GetState()) 102 if subMask.IsFull() { 103 res.Paths = append(res.Paths, &AlertingPolicy_FieldTerminalPath{selector: AlertingPolicy_FieldPathSelectorState}) 104 } else { 105 for _, subpath := range subMask.Paths { 106 res.Paths = append(res.Paths, &AlertingPolicy_FieldSubPath{selector: AlertingPolicy_FieldPathSelectorState, subPath: subpath}) 107 } 108 } 109 } 110 return res 111 } 112 113 func (o *AlertingPolicy) MakeRawDiffFieldMask(other gotenobject.GotenObjectExt) gotenobject.FieldMask { 114 return o.MakeDiffFieldMask(other.(*AlertingPolicy)) 115 } 116 117 func (o *AlertingPolicy) Clone() *AlertingPolicy { 118 if o == nil { 119 return nil 120 } 121 result := &AlertingPolicy{} 122 if o.Name == nil { 123 result.Name = nil 124 } else if data, err := o.Name.ProtoString(); err != nil { 125 panic(err) 126 } else { 127 result.Name = &Name{} 128 if err := result.Name.ParseProtoString(data); err != nil { 129 panic(err) 130 } 131 } 132 result.Metadata = o.Metadata.Clone() 133 result.DisplayName = o.DisplayName 134 result.Description = o.Description 135 result.Documentation = o.Documentation.Clone() 136 result.Spec = o.Spec.Clone() 137 result.State = o.State.Clone() 138 return result 139 } 140 141 func (o *AlertingPolicy) CloneRaw() gotenobject.GotenObjectExt { 142 return o.Clone() 143 } 144 145 func (o *AlertingPolicy) Merge(source *AlertingPolicy) { 146 if source.GetName() != nil { 147 if data, err := source.GetName().ProtoString(); err != nil { 148 panic(err) 149 } else { 150 o.Name = &Name{} 151 if err := o.Name.ParseProtoString(data); err != nil { 152 panic(err) 153 } 154 } 155 } else { 156 o.Name = nil 157 } 158 if source.GetMetadata() != nil { 159 if o.Metadata == nil { 160 o.Metadata = new(meta.Meta) 161 } 162 o.Metadata.Merge(source.GetMetadata()) 163 } 164 o.DisplayName = source.GetDisplayName() 165 o.Description = source.GetDescription() 166 if source.GetDocumentation() != nil { 167 if o.Documentation == nil { 168 o.Documentation = new(AlertingPolicy_Documentation) 169 } 170 o.Documentation.Merge(source.GetDocumentation()) 171 } 172 if source.GetSpec() != nil { 173 if o.Spec == nil { 174 o.Spec = new(AlertingPolicy_Spec) 175 } 176 o.Spec.Merge(source.GetSpec()) 177 } 178 if source.GetState() != nil { 179 if o.State == nil { 180 o.State = new(AlertingPolicy_State) 181 } 182 o.State.Merge(source.GetState()) 183 } 184 } 185 186 func (o *AlertingPolicy) MergeRaw(source gotenobject.GotenObjectExt) { 187 o.Merge(source.(*AlertingPolicy)) 188 } 189 190 func (o *AlertingPolicy_Documentation) GotenObjectExt() {} 191 192 func (o *AlertingPolicy_Documentation) MakeFullFieldMask() *AlertingPolicy_Documentation_FieldMask { 193 return FullAlertingPolicy_Documentation_FieldMask() 194 } 195 196 func (o *AlertingPolicy_Documentation) MakeRawFullFieldMask() gotenobject.FieldMask { 197 return FullAlertingPolicy_Documentation_FieldMask() 198 } 199 200 func (o *AlertingPolicy_Documentation) MakeDiffFieldMask(other *AlertingPolicy_Documentation) *AlertingPolicy_Documentation_FieldMask { 201 if o == nil && other == nil { 202 return &AlertingPolicy_Documentation_FieldMask{} 203 } 204 if o == nil || other == nil { 205 return FullAlertingPolicy_Documentation_FieldMask() 206 } 207 208 res := &AlertingPolicy_Documentation_FieldMask{} 209 if o.GetContent() != other.GetContent() { 210 res.Paths = append(res.Paths, &AlertingPolicyDocumentation_FieldTerminalPath{selector: AlertingPolicyDocumentation_FieldPathSelectorContent}) 211 } 212 if o.GetMimeType() != other.GetMimeType() { 213 res.Paths = append(res.Paths, &AlertingPolicyDocumentation_FieldTerminalPath{selector: AlertingPolicyDocumentation_FieldPathSelectorMimeType}) 214 } 215 return res 216 } 217 218 func (o *AlertingPolicy_Documentation) MakeRawDiffFieldMask(other gotenobject.GotenObjectExt) gotenobject.FieldMask { 219 return o.MakeDiffFieldMask(other.(*AlertingPolicy_Documentation)) 220 } 221 222 func (o *AlertingPolicy_Documentation) Clone() *AlertingPolicy_Documentation { 223 if o == nil { 224 return nil 225 } 226 result := &AlertingPolicy_Documentation{} 227 result.Content = o.Content 228 result.MimeType = o.MimeType 229 return result 230 } 231 232 func (o *AlertingPolicy_Documentation) CloneRaw() gotenobject.GotenObjectExt { 233 return o.Clone() 234 } 235 236 func (o *AlertingPolicy_Documentation) Merge(source *AlertingPolicy_Documentation) { 237 o.Content = source.GetContent() 238 o.MimeType = source.GetMimeType() 239 } 240 241 func (o *AlertingPolicy_Documentation) MergeRaw(source gotenobject.GotenObjectExt) { 242 o.Merge(source.(*AlertingPolicy_Documentation)) 243 } 244 245 func (o *AlertingPolicy_Spec) GotenObjectExt() {} 246 247 func (o *AlertingPolicy_Spec) MakeFullFieldMask() *AlertingPolicy_Spec_FieldMask { 248 return FullAlertingPolicy_Spec_FieldMask() 249 } 250 251 func (o *AlertingPolicy_Spec) MakeRawFullFieldMask() gotenobject.FieldMask { 252 return FullAlertingPolicy_Spec_FieldMask() 253 } 254 255 func (o *AlertingPolicy_Spec) MakeDiffFieldMask(other *AlertingPolicy_Spec) *AlertingPolicy_Spec_FieldMask { 256 if o == nil && other == nil { 257 return &AlertingPolicy_Spec_FieldMask{} 258 } 259 if o == nil || other == nil { 260 return FullAlertingPolicy_Spec_FieldMask() 261 } 262 263 res := &AlertingPolicy_Spec_FieldMask{} 264 if o.GetEnabled() != other.GetEnabled() { 265 res.Paths = append(res.Paths, &AlertingPolicySpec_FieldTerminalPath{selector: AlertingPolicySpec_FieldPathSelectorEnabled}) 266 } 267 if o.GetConditionCombiner() != other.GetConditionCombiner() { 268 res.Paths = append(res.Paths, &AlertingPolicySpec_FieldTerminalPath{selector: AlertingPolicySpec_FieldPathSelectorConditionCombiner}) 269 } 270 { 271 subMask := o.GetNotification().MakeDiffFieldMask(other.GetNotification()) 272 if subMask.IsFull() { 273 res.Paths = append(res.Paths, &AlertingPolicySpec_FieldTerminalPath{selector: AlertingPolicySpec_FieldPathSelectorNotification}) 274 } else { 275 for _, subpath := range subMask.Paths { 276 res.Paths = append(res.Paths, &AlertingPolicySpec_FieldSubPath{selector: AlertingPolicySpec_FieldPathSelectorNotification, subPath: subpath}) 277 } 278 } 279 } 280 return res 281 } 282 283 func (o *AlertingPolicy_Spec) MakeRawDiffFieldMask(other gotenobject.GotenObjectExt) gotenobject.FieldMask { 284 return o.MakeDiffFieldMask(other.(*AlertingPolicy_Spec)) 285 } 286 287 func (o *AlertingPolicy_Spec) Clone() *AlertingPolicy_Spec { 288 if o == nil { 289 return nil 290 } 291 result := &AlertingPolicy_Spec{} 292 result.Enabled = o.Enabled 293 result.ConditionCombiner = o.ConditionCombiner 294 result.Notification = o.Notification.Clone() 295 return result 296 } 297 298 func (o *AlertingPolicy_Spec) CloneRaw() gotenobject.GotenObjectExt { 299 return o.Clone() 300 } 301 302 func (o *AlertingPolicy_Spec) Merge(source *AlertingPolicy_Spec) { 303 o.Enabled = source.GetEnabled() 304 o.ConditionCombiner = source.GetConditionCombiner() 305 if source.GetNotification() != nil { 306 if o.Notification == nil { 307 o.Notification = new(AlertingPolicy_Spec_Notification) 308 } 309 o.Notification.Merge(source.GetNotification()) 310 } 311 } 312 313 func (o *AlertingPolicy_Spec) MergeRaw(source gotenobject.GotenObjectExt) { 314 o.Merge(source.(*AlertingPolicy_Spec)) 315 } 316 317 func (o *AlertingPolicy_State) GotenObjectExt() {} 318 319 func (o *AlertingPolicy_State) MakeFullFieldMask() *AlertingPolicy_State_FieldMask { 320 return FullAlertingPolicy_State_FieldMask() 321 } 322 323 func (o *AlertingPolicy_State) MakeRawFullFieldMask() gotenobject.FieldMask { 324 return FullAlertingPolicy_State_FieldMask() 325 } 326 327 func (o *AlertingPolicy_State) MakeDiffFieldMask(other *AlertingPolicy_State) *AlertingPolicy_State_FieldMask { 328 if o == nil && other == nil { 329 return &AlertingPolicy_State_FieldMask{} 330 } 331 if o == nil || other == nil { 332 return FullAlertingPolicy_State_FieldMask() 333 } 334 335 res := &AlertingPolicy_State_FieldMask{} 336 if o.GetActiveAlertsCount() != other.GetActiveAlertsCount() { 337 res.Paths = append(res.Paths, &AlertingPolicyState_FieldTerminalPath{selector: AlertingPolicyState_FieldPathSelectorActiveAlertsCount}) 338 } 339 return res 340 } 341 342 func (o *AlertingPolicy_State) MakeRawDiffFieldMask(other gotenobject.GotenObjectExt) gotenobject.FieldMask { 343 return o.MakeDiffFieldMask(other.(*AlertingPolicy_State)) 344 } 345 346 func (o *AlertingPolicy_State) Clone() *AlertingPolicy_State { 347 if o == nil { 348 return nil 349 } 350 result := &AlertingPolicy_State{} 351 result.ActiveAlertsCount = o.ActiveAlertsCount 352 return result 353 } 354 355 func (o *AlertingPolicy_State) CloneRaw() gotenobject.GotenObjectExt { 356 return o.Clone() 357 } 358 359 func (o *AlertingPolicy_State) Merge(source *AlertingPolicy_State) { 360 o.ActiveAlertsCount = source.GetActiveAlertsCount() 361 } 362 363 func (o *AlertingPolicy_State) MergeRaw(source gotenobject.GotenObjectExt) { 364 o.Merge(source.(*AlertingPolicy_State)) 365 } 366 367 func (o *AlertingPolicy_Spec_Notification) GotenObjectExt() {} 368 369 func (o *AlertingPolicy_Spec_Notification) MakeFullFieldMask() *AlertingPolicy_Spec_Notification_FieldMask { 370 return FullAlertingPolicy_Spec_Notification_FieldMask() 371 } 372 373 func (o *AlertingPolicy_Spec_Notification) MakeRawFullFieldMask() gotenobject.FieldMask { 374 return FullAlertingPolicy_Spec_Notification_FieldMask() 375 } 376 377 func (o *AlertingPolicy_Spec_Notification) MakeDiffFieldMask(other *AlertingPolicy_Spec_Notification) *AlertingPolicy_Spec_Notification_FieldMask { 378 if o == nil && other == nil { 379 return &AlertingPolicy_Spec_Notification_FieldMask{} 380 } 381 if o == nil || other == nil { 382 return FullAlertingPolicy_Spec_Notification_FieldMask() 383 } 384 385 res := &AlertingPolicy_Spec_Notification_FieldMask{} 386 if o.GetEnabled() != other.GetEnabled() { 387 res.Paths = append(res.Paths, &AlertingPolicySpecNotification_FieldTerminalPath{selector: AlertingPolicySpecNotification_FieldPathSelectorEnabled}) 388 } 389 390 if len(o.GetChannels()) == len(other.GetChannels()) { 391 for i, lValue := range o.GetChannels() { 392 rValue := other.GetChannels()[i] 393 if lValue.String() != rValue.String() { 394 res.Paths = append(res.Paths, &AlertingPolicySpecNotification_FieldTerminalPath{selector: AlertingPolicySpecNotification_FieldPathSelectorChannels}) 395 break 396 } 397 } 398 } else { 399 res.Paths = append(res.Paths, &AlertingPolicySpecNotification_FieldTerminalPath{selector: AlertingPolicySpecNotification_FieldPathSelectorChannels}) 400 } 401 return res 402 } 403 404 func (o *AlertingPolicy_Spec_Notification) MakeRawDiffFieldMask(other gotenobject.GotenObjectExt) gotenobject.FieldMask { 405 return o.MakeDiffFieldMask(other.(*AlertingPolicy_Spec_Notification)) 406 } 407 408 func (o *AlertingPolicy_Spec_Notification) Clone() *AlertingPolicy_Spec_Notification { 409 if o == nil { 410 return nil 411 } 412 result := &AlertingPolicy_Spec_Notification{} 413 result.Enabled = o.Enabled 414 result.Channels = make([]*notification_channel.Reference, len(o.Channels)) 415 for i, sourceValue := range o.Channels { 416 if sourceValue == nil { 417 result.Channels[i] = nil 418 } else if data, err := sourceValue.ProtoString(); err != nil { 419 panic(err) 420 } else { 421 result.Channels[i] = ¬ification_channel.Reference{} 422 if err := result.Channels[i].ParseProtoString(data); err != nil { 423 panic(err) 424 } 425 } 426 } 427 return result 428 } 429 430 func (o *AlertingPolicy_Spec_Notification) CloneRaw() gotenobject.GotenObjectExt { 431 return o.Clone() 432 } 433 434 func (o *AlertingPolicy_Spec_Notification) Merge(source *AlertingPolicy_Spec_Notification) { 435 o.Enabled = source.GetEnabled() 436 for _, sourceValue := range source.GetChannels() { 437 exists := false 438 for _, currentValue := range o.Channels { 439 leftProtoStr, _ := currentValue.ProtoString() 440 rightProtoStr, _ := sourceValue.ProtoString() 441 if leftProtoStr == rightProtoStr { 442 exists = true 443 break 444 } 445 } 446 if !exists { 447 var newDstElement *notification_channel.Reference 448 if sourceValue != nil { 449 if data, err := sourceValue.ProtoString(); err != nil { 450 panic(err) 451 } else { 452 newDstElement = ¬ification_channel.Reference{} 453 if err := newDstElement.ParseProtoString(data); err != nil { 454 panic(err) 455 } 456 } 457 } 458 o.Channels = append(o.Channels, newDstElement) 459 } 460 } 461 462 } 463 464 func (o *AlertingPolicy_Spec_Notification) MergeRaw(source gotenobject.GotenObjectExt) { 465 o.Merge(source.(*AlertingPolicy_Spec_Notification)) 466 }