1// Code generated by go-swagger; DO NOT EDIT.
2
3// Copyright Prometheus Team
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17package models
18
19// This file was generated by the swagger tool.
20// Editing this file might prove futile when you re-run the swagger generate command
21
22import (
23	"strconv"
24
25	"github.com/go-openapi/errors"
26	"github.com/go-openapi/strfmt"
27	"github.com/go-openapi/swag"
28	"github.com/go-openapi/validate"
29)
30
31// AlertGroup alert group
32//
33// swagger:model alertGroup
34type AlertGroup struct {
35
36	// alerts
37	// Required: true
38	Alerts []*GettableAlert `json:"alerts"`
39
40	// labels
41	// Required: true
42	Labels LabelSet `json:"labels"`
43
44	// receiver
45	// Required: true
46	Receiver *Receiver `json:"receiver"`
47}
48
49// Validate validates this alert group
50func (m *AlertGroup) Validate(formats strfmt.Registry) error {
51	var res []error
52
53	if err := m.validateAlerts(formats); err != nil {
54		res = append(res, err)
55	}
56
57	if err := m.validateLabels(formats); err != nil {
58		res = append(res, err)
59	}
60
61	if err := m.validateReceiver(formats); err != nil {
62		res = append(res, err)
63	}
64
65	if len(res) > 0 {
66		return errors.CompositeValidationError(res...)
67	}
68	return nil
69}
70
71func (m *AlertGroup) validateAlerts(formats strfmt.Registry) error {
72
73	if err := validate.Required("alerts", "body", m.Alerts); err != nil {
74		return err
75	}
76
77	for i := 0; i < len(m.Alerts); i++ {
78		if swag.IsZero(m.Alerts[i]) { // not required
79			continue
80		}
81
82		if m.Alerts[i] != nil {
83			if err := m.Alerts[i].Validate(formats); err != nil {
84				if ve, ok := err.(*errors.Validation); ok {
85					return ve.ValidateName("alerts" + "." + strconv.Itoa(i))
86				}
87				return err
88			}
89		}
90
91	}
92
93	return nil
94}
95
96func (m *AlertGroup) validateLabels(formats strfmt.Registry) error {
97
98	if err := m.Labels.Validate(formats); err != nil {
99		if ve, ok := err.(*errors.Validation); ok {
100			return ve.ValidateName("labels")
101		}
102		return err
103	}
104
105	return nil
106}
107
108func (m *AlertGroup) validateReceiver(formats strfmt.Registry) error {
109
110	if err := validate.Required("receiver", "body", m.Receiver); err != nil {
111		return err
112	}
113
114	if m.Receiver != nil {
115		if err := m.Receiver.Validate(formats); err != nil {
116			if ve, ok := err.(*errors.Validation); ok {
117				return ve.ValidateName("receiver")
118			}
119			return err
120		}
121	}
122
123	return nil
124}
125
126// MarshalBinary interface implementation
127func (m *AlertGroup) MarshalBinary() ([]byte, error) {
128	if m == nil {
129		return nil, nil
130	}
131	return swag.WriteJSON(m)
132}
133
134// UnmarshalBinary interface implementation
135func (m *AlertGroup) UnmarshalBinary(b []byte) error {
136	var res AlertGroup
137	if err := swag.ReadJSON(b, &res); err != nil {
138		return err
139	}
140	*m = res
141	return nil
142}
143