alertmanager/api/v2/models/alert_group.go

143 lines
3.1 KiB
Go

// Code generated by go-swagger; DO NOT EDIT.
// Copyright Prometheus Team
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"strconv"
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// AlertGroup alert group
//
// swagger:model alertGroup
type AlertGroup struct {
// alerts
// Required: true
Alerts []*GettableAlert `json:"alerts"`
// labels
// Required: true
Labels LabelSet `json:"labels"`
// receiver
// Required: true
Receiver *Receiver `json:"receiver"`
}
// Validate validates this alert group
func (m *AlertGroup) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateAlerts(formats); err != nil {
res = append(res, err)
}
if err := m.validateLabels(formats); err != nil {
res = append(res, err)
}
if err := m.validateReceiver(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *AlertGroup) validateAlerts(formats strfmt.Registry) error {
if err := validate.Required("alerts", "body", m.Alerts); err != nil {
return err
}
for i := 0; i < len(m.Alerts); i++ {
if swag.IsZero(m.Alerts[i]) { // not required
continue
}
if m.Alerts[i] != nil {
if err := m.Alerts[i].Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("alerts" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
func (m *AlertGroup) validateLabels(formats strfmt.Registry) error {
if err := m.Labels.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("labels")
}
return err
}
return nil
}
func (m *AlertGroup) validateReceiver(formats strfmt.Registry) error {
if err := validate.Required("receiver", "body", m.Receiver); err != nil {
return err
}
if m.Receiver != nil {
if err := m.Receiver.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("receiver")
}
return err
}
}
return nil
}
// MarshalBinary interface implementation
func (m *AlertGroup) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *AlertGroup) UnmarshalBinary(b []byte) error {
var res AlertGroup
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}