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)
27
28// PostableSilence postable silence
29//
30// swagger:model postableSilence
31type PostableSilence struct {
32
33	// id
34	ID string `json:"id,omitempty"`
35
36	Silence
37}
38
39// UnmarshalJSON unmarshals this object from a JSON structure
40func (m *PostableSilence) UnmarshalJSON(raw []byte) error {
41	// AO0
42	var dataAO0 struct {
43		ID string `json:"id,omitempty"`
44	}
45	if err := swag.ReadJSON(raw, &dataAO0); err != nil {
46		return err
47	}
48
49	m.ID = dataAO0.ID
50
51	// AO1
52	var aO1 Silence
53	if err := swag.ReadJSON(raw, &aO1); err != nil {
54		return err
55	}
56	m.Silence = aO1
57
58	return nil
59}
60
61// MarshalJSON marshals this object to a JSON structure
62func (m PostableSilence) MarshalJSON() ([]byte, error) {
63	_parts := make([][]byte, 0, 2)
64
65	var dataAO0 struct {
66		ID string `json:"id,omitempty"`
67	}
68
69	dataAO0.ID = m.ID
70
71	jsonDataAO0, errAO0 := swag.WriteJSON(dataAO0)
72	if errAO0 != nil {
73		return nil, errAO0
74	}
75	_parts = append(_parts, jsonDataAO0)
76
77	aO1, err := swag.WriteJSON(m.Silence)
78	if err != nil {
79		return nil, err
80	}
81	_parts = append(_parts, aO1)
82	return swag.ConcatJSON(_parts...), nil
83}
84
85// Validate validates this postable silence
86func (m *PostableSilence) Validate(formats strfmt.Registry) error {
87	var res []error
88
89	// validation for a type composition with Silence
90	if err := m.Silence.Validate(formats); err != nil {
91		res = append(res, err)
92	}
93
94	if len(res) > 0 {
95		return errors.CompositeValidationError(res...)
96	}
97	return nil
98}
99
100// MarshalBinary interface implementation
101func (m *PostableSilence) MarshalBinary() ([]byte, error) {
102	if m == nil {
103		return nil, nil
104	}
105	return swag.WriteJSON(m)
106}
107
108// UnmarshalBinary interface implementation
109func (m *PostableSilence) UnmarshalBinary(b []byte) error {
110	var res PostableSilence
111	if err := swag.ReadJSON(b, &res); err != nil {
112		return err
113	}
114	*m = res
115	return nil
116}
117