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// Alert alert 30// 31// swagger:model alert 32type Alert struct { 33 34 // generator URL 35 // Format: uri 36 GeneratorURL strfmt.URI `json:"generatorURL,omitempty"` 37 38 // labels 39 // Required: true 40 Labels LabelSet `json:"labels"` 41} 42 43// Validate validates this alert 44func (m *Alert) Validate(formats strfmt.Registry) error { 45 var res []error 46 47 if err := m.validateGeneratorURL(formats); err != nil { 48 res = append(res, err) 49 } 50 51 if err := m.validateLabels(formats); err != nil { 52 res = append(res, err) 53 } 54 55 if len(res) > 0 { 56 return errors.CompositeValidationError(res...) 57 } 58 return nil 59} 60 61func (m *Alert) validateGeneratorURL(formats strfmt.Registry) error { 62 63 if swag.IsZero(m.GeneratorURL) { // not required 64 return nil 65 } 66 67 if err := validate.FormatOf("generatorURL", "body", "uri", m.GeneratorURL.String(), formats); err != nil { 68 return err 69 } 70 71 return nil 72} 73 74func (m *Alert) validateLabels(formats strfmt.Registry) error { 75 76 if err := m.Labels.Validate(formats); err != nil { 77 if ve, ok := err.(*errors.Validation); ok { 78 return ve.ValidateName("labels") 79 } 80 return err 81 } 82 83 return nil 84} 85 86// MarshalBinary interface implementation 87func (m *Alert) MarshalBinary() ([]byte, error) { 88 if m == nil { 89 return nil, nil 90 } 91 return swag.WriteJSON(m) 92} 93 94// UnmarshalBinary interface implementation 95func (m *Alert) UnmarshalBinary(b []byte) error { 96 var res Alert 97 if err := swag.ReadJSON(b, &res); err != nil { 98 return err 99 } 100 *m = res 101 return nil 102} 103