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