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// GettableAlert gettable alert
32//
33// swagger:model gettableAlert
34type GettableAlert struct {
35
36	// annotations
37	// Required: true
38	Annotations LabelSet `json:"annotations"`
39
40	// ends at
41	// Required: true
42	// Format: date-time
43	EndsAt *strfmt.DateTime `json:"endsAt"`
44
45	// fingerprint
46	// Required: true
47	Fingerprint *string `json:"fingerprint"`
48
49	// receivers
50	// Required: true
51	Receivers []*Receiver `json:"receivers"`
52
53	// starts at
54	// Required: true
55	// Format: date-time
56	StartsAt *strfmt.DateTime `json:"startsAt"`
57
58	// status
59	// Required: true
60	Status *AlertStatus `json:"status"`
61
62	// updated at
63	// Required: true
64	// Format: date-time
65	UpdatedAt *strfmt.DateTime `json:"updatedAt"`
66
67	Alert
68}
69
70// UnmarshalJSON unmarshals this object from a JSON structure
71func (m *GettableAlert) UnmarshalJSON(raw []byte) error {
72	// AO0
73	var dataAO0 struct {
74		Annotations LabelSet `json:"annotations"`
75
76		EndsAt *strfmt.DateTime `json:"endsAt"`
77
78		Fingerprint *string `json:"fingerprint"`
79
80		Receivers []*Receiver `json:"receivers"`
81
82		StartsAt *strfmt.DateTime `json:"startsAt"`
83
84		Status *AlertStatus `json:"status"`
85
86		UpdatedAt *strfmt.DateTime `json:"updatedAt"`
87	}
88	if err := swag.ReadJSON(raw, &dataAO0); err != nil {
89		return err
90	}
91
92	m.Annotations = dataAO0.Annotations
93
94	m.EndsAt = dataAO0.EndsAt
95
96	m.Fingerprint = dataAO0.Fingerprint
97
98	m.Receivers = dataAO0.Receivers
99
100	m.StartsAt = dataAO0.StartsAt
101
102	m.Status = dataAO0.Status
103
104	m.UpdatedAt = dataAO0.UpdatedAt
105
106	// AO1
107	var aO1 Alert
108	if err := swag.ReadJSON(raw, &aO1); err != nil {
109		return err
110	}
111	m.Alert = aO1
112
113	return nil
114}
115
116// MarshalJSON marshals this object to a JSON structure
117func (m GettableAlert) MarshalJSON() ([]byte, error) {
118	_parts := make([][]byte, 0, 2)
119
120	var dataAO0 struct {
121		Annotations LabelSet `json:"annotations"`
122
123		EndsAt *strfmt.DateTime `json:"endsAt"`
124
125		Fingerprint *string `json:"fingerprint"`
126
127		Receivers []*Receiver `json:"receivers"`
128
129		StartsAt *strfmt.DateTime `json:"startsAt"`
130
131		Status *AlertStatus `json:"status"`
132
133		UpdatedAt *strfmt.DateTime `json:"updatedAt"`
134	}
135
136	dataAO0.Annotations = m.Annotations
137
138	dataAO0.EndsAt = m.EndsAt
139
140	dataAO0.Fingerprint = m.Fingerprint
141
142	dataAO0.Receivers = m.Receivers
143
144	dataAO0.StartsAt = m.StartsAt
145
146	dataAO0.Status = m.Status
147
148	dataAO0.UpdatedAt = m.UpdatedAt
149
150	jsonDataAO0, errAO0 := swag.WriteJSON(dataAO0)
151	if errAO0 != nil {
152		return nil, errAO0
153	}
154	_parts = append(_parts, jsonDataAO0)
155
156	aO1, err := swag.WriteJSON(m.Alert)
157	if err != nil {
158		return nil, err
159	}
160	_parts = append(_parts, aO1)
161	return swag.ConcatJSON(_parts...), nil
162}
163
164// Validate validates this gettable alert
165func (m *GettableAlert) Validate(formats strfmt.Registry) error {
166	var res []error
167
168	if err := m.validateAnnotations(formats); err != nil {
169		res = append(res, err)
170	}
171
172	if err := m.validateEndsAt(formats); err != nil {
173		res = append(res, err)
174	}
175
176	if err := m.validateFingerprint(formats); err != nil {
177		res = append(res, err)
178	}
179
180	if err := m.validateReceivers(formats); err != nil {
181		res = append(res, err)
182	}
183
184	if err := m.validateStartsAt(formats); err != nil {
185		res = append(res, err)
186	}
187
188	if err := m.validateStatus(formats); err != nil {
189		res = append(res, err)
190	}
191
192	if err := m.validateUpdatedAt(formats); err != nil {
193		res = append(res, err)
194	}
195
196	// validation for a type composition with Alert
197	if err := m.Alert.Validate(formats); err != nil {
198		res = append(res, err)
199	}
200
201	if len(res) > 0 {
202		return errors.CompositeValidationError(res...)
203	}
204	return nil
205}
206
207func (m *GettableAlert) validateAnnotations(formats strfmt.Registry) error {
208
209	if err := m.Annotations.Validate(formats); err != nil {
210		if ve, ok := err.(*errors.Validation); ok {
211			return ve.ValidateName("annotations")
212		}
213		return err
214	}
215
216	return nil
217}
218
219func (m *GettableAlert) validateEndsAt(formats strfmt.Registry) error {
220
221	if err := validate.Required("endsAt", "body", m.EndsAt); err != nil {
222		return err
223	}
224
225	if err := validate.FormatOf("endsAt", "body", "date-time", m.EndsAt.String(), formats); err != nil {
226		return err
227	}
228
229	return nil
230}
231
232func (m *GettableAlert) validateFingerprint(formats strfmt.Registry) error {
233
234	if err := validate.Required("fingerprint", "body", m.Fingerprint); err != nil {
235		return err
236	}
237
238	return nil
239}
240
241func (m *GettableAlert) validateReceivers(formats strfmt.Registry) error {
242
243	if err := validate.Required("receivers", "body", m.Receivers); err != nil {
244		return err
245	}
246
247	for i := 0; i < len(m.Receivers); i++ {
248		if swag.IsZero(m.Receivers[i]) { // not required
249			continue
250		}
251
252		if m.Receivers[i] != nil {
253			if err := m.Receivers[i].Validate(formats); err != nil {
254				if ve, ok := err.(*errors.Validation); ok {
255					return ve.ValidateName("receivers" + "." + strconv.Itoa(i))
256				}
257				return err
258			}
259		}
260
261	}
262
263	return nil
264}
265
266func (m *GettableAlert) validateStartsAt(formats strfmt.Registry) error {
267
268	if err := validate.Required("startsAt", "body", m.StartsAt); err != nil {
269		return err
270	}
271
272	if err := validate.FormatOf("startsAt", "body", "date-time", m.StartsAt.String(), formats); err != nil {
273		return err
274	}
275
276	return nil
277}
278
279func (m *GettableAlert) validateStatus(formats strfmt.Registry) error {
280
281	if err := validate.Required("status", "body", m.Status); err != nil {
282		return err
283	}
284
285	if m.Status != nil {
286		if err := m.Status.Validate(formats); err != nil {
287			if ve, ok := err.(*errors.Validation); ok {
288				return ve.ValidateName("status")
289			}
290			return err
291		}
292	}
293
294	return nil
295}
296
297func (m *GettableAlert) validateUpdatedAt(formats strfmt.Registry) error {
298
299	if err := validate.Required("updatedAt", "body", m.UpdatedAt); err != nil {
300		return err
301	}
302
303	if err := validate.FormatOf("updatedAt", "body", "date-time", m.UpdatedAt.String(), formats); err != nil {
304		return err
305	}
306
307	return nil
308}
309
310// MarshalBinary interface implementation
311func (m *GettableAlert) MarshalBinary() ([]byte, error) {
312	if m == nil {
313		return nil, nil
314	}
315	return swag.WriteJSON(m)
316}
317
318// UnmarshalBinary interface implementation
319func (m *GettableAlert) UnmarshalBinary(b []byte) error {
320	var res GettableAlert
321	if err := swag.ReadJSON(b, &res); err != nil {
322		return err
323	}
324	*m = res
325	return nil
326}
327