2019-03-07 16:18:18 +00:00
|
|
|
// 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"
|
|
|
|
|
|
|
|
strfmt "github.com/go-openapi/strfmt"
|
|
|
|
|
|
|
|
"github.com/go-openapi/errors"
|
|
|
|
"github.com/go-openapi/swag"
|
2019-04-27 10:44:12 +00:00
|
|
|
"github.com/go-openapi/validate"
|
2019-03-07 16:18:18 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// AlertGroup alert group
|
|
|
|
// swagger:model alertGroup
|
|
|
|
type AlertGroup struct {
|
|
|
|
|
|
|
|
// alerts
|
2019-04-27 10:44:12 +00:00
|
|
|
// Required: true
|
2019-03-07 16:18:18 +00:00
|
|
|
Alerts []*GettableAlert `json:"alerts"`
|
|
|
|
|
|
|
|
// labels
|
2019-04-27 10:44:12 +00:00
|
|
|
// Required: true
|
|
|
|
Labels LabelSet `json:"labels"`
|
2019-03-07 16:18:18 +00:00
|
|
|
|
|
|
|
// receiver
|
2019-04-27 10:44:12 +00:00
|
|
|
// Required: true
|
|
|
|
Receiver *Receiver `json:"receiver"`
|
2019-03-07 16:18:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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 {
|
|
|
|
|
2019-04-27 10:44:12 +00:00
|
|
|
if err := validate.Required("alerts", "body", m.Alerts); err != nil {
|
|
|
|
return err
|
2019-03-07 16:18:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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 {
|
|
|
|
|
2019-04-27 10:44:12 +00:00
|
|
|
if err := validate.Required("receiver", "body", m.Receiver); err != nil {
|
|
|
|
return err
|
2019-03-07 16:18:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|