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	"github.com/go-openapi/errors"
24	"github.com/go-openapi/strfmt"
25	"github.com/go-openapi/swag"
26	"github.com/go-openapi/validate"
27)
28
29// GettableSilence gettable silence
30//
31// swagger:model gettableSilence
32type GettableSilence struct {
33
34	// id
35	// Required: true
36	ID *string `json:"id"`
37
38	// status
39	// Required: true
40	Status *SilenceStatus `json:"status"`
41
42	// updated at
43	// Required: true
44	// Format: date-time
45	UpdatedAt *strfmt.DateTime `json:"updatedAt"`
46
47	Silence
48}
49
50// UnmarshalJSON unmarshals this object from a JSON structure
51func (m *GettableSilence) UnmarshalJSON(raw []byte) error {
52	// AO0
53	var dataAO0 struct {
54		ID *string `json:"id"`
55
56		Status *SilenceStatus `json:"status"`
57
58		UpdatedAt *strfmt.DateTime `json:"updatedAt"`
59	}
60	if err := swag.ReadJSON(raw, &dataAO0); err != nil {
61		return err
62	}
63
64	m.ID = dataAO0.ID
65
66	m.Status = dataAO0.Status
67
68	m.UpdatedAt = dataAO0.UpdatedAt
69
70	// AO1
71	var aO1 Silence
72	if err := swag.ReadJSON(raw, &aO1); err != nil {
73		return err
74	}
75	m.Silence = aO1
76
77	return nil
78}
79
80// MarshalJSON marshals this object to a JSON structure
81func (m GettableSilence) MarshalJSON() ([]byte, error) {
82	_parts := make([][]byte, 0, 2)
83
84	var dataAO0 struct {
85		ID *string `json:"id"`
86
87		Status *SilenceStatus `json:"status"`
88
89		UpdatedAt *strfmt.DateTime `json:"updatedAt"`
90	}
91
92	dataAO0.ID = m.ID
93
94	dataAO0.Status = m.Status
95
96	dataAO0.UpdatedAt = m.UpdatedAt
97
98	jsonDataAO0, errAO0 := swag.WriteJSON(dataAO0)
99	if errAO0 != nil {
100		return nil, errAO0
101	}
102	_parts = append(_parts, jsonDataAO0)
103
104	aO1, err := swag.WriteJSON(m.Silence)
105	if err != nil {
106		return nil, err
107	}
108	_parts = append(_parts, aO1)
109	return swag.ConcatJSON(_parts...), nil
110}
111
112// Validate validates this gettable silence
113func (m *GettableSilence) Validate(formats strfmt.Registry) error {
114	var res []error
115
116	if err := m.validateID(formats); err != nil {
117		res = append(res, err)
118	}
119
120	if err := m.validateStatus(formats); err != nil {
121		res = append(res, err)
122	}
123
124	if err := m.validateUpdatedAt(formats); err != nil {
125		res = append(res, err)
126	}
127
128	// validation for a type composition with Silence
129	if err := m.Silence.Validate(formats); err != nil {
130		res = append(res, err)
131	}
132
133	if len(res) > 0 {
134		return errors.CompositeValidationError(res...)
135	}
136	return nil
137}
138
139func (m *GettableSilence) validateID(formats strfmt.Registry) error {
140
141	if err := validate.Required("id", "body", m.ID); err != nil {
142		return err
143	}
144
145	return nil
146}
147
148func (m *GettableSilence) validateStatus(formats strfmt.Registry) error {
149
150	if err := validate.Required("status", "body", m.Status); err != nil {
151		return err
152	}
153
154	if m.Status != nil {
155		if err := m.Status.Validate(formats); err != nil {
156			if ve, ok := err.(*errors.Validation); ok {
157				return ve.ValidateName("status")
158			}
159			return err
160		}
161	}
162
163	return nil
164}
165
166func (m *GettableSilence) validateUpdatedAt(formats strfmt.Registry) error {
167
168	if err := validate.Required("updatedAt", "body", m.UpdatedAt); err != nil {
169		return err
170	}
171
172	if err := validate.FormatOf("updatedAt", "body", "date-time", m.UpdatedAt.String(), formats); err != nil {
173		return err
174	}
175
176	return nil
177}
178
179// MarshalBinary interface implementation
180func (m *GettableSilence) MarshalBinary() ([]byte, error) {
181	if m == nil {
182		return nil, nil
183	}
184	return swag.WriteJSON(m)
185}
186
187// UnmarshalBinary interface implementation
188func (m *GettableSilence) UnmarshalBinary(b []byte) error {
189	var res GettableSilence
190	if err := swag.ReadJSON(b, &res); err != nil {
191		return err
192	}
193	*m = res
194	return nil
195}
196