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 alert 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 "io" 24 "net/http" 25 26 "github.com/go-openapi/errors" 27 "github.com/go-openapi/runtime" 28 "github.com/go-openapi/runtime/middleware" 29 30 "github.com/prometheus/alertmanager/api/v2/models" 31) 32 33// NewPostAlertsParams creates a new PostAlertsParams object 34// no default values defined in spec. 35func NewPostAlertsParams() PostAlertsParams { 36 37 return PostAlertsParams{} 38} 39 40// PostAlertsParams contains all the bound params for the post alerts operation 41// typically these are obtained from a http.Request 42// 43// swagger:parameters postAlerts 44type PostAlertsParams struct { 45 46 // HTTP Request Object 47 HTTPRequest *http.Request `json:"-"` 48 49 /*The alerts to create 50 Required: true 51 In: body 52 */ 53 Alerts models.PostableAlerts 54} 55 56// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 57// for simple values it will use straight method calls. 58// 59// To ensure default values, the struct must have been initialized with NewPostAlertsParams() beforehand. 60func (o *PostAlertsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 61 var res []error 62 63 o.HTTPRequest = r 64 65 if runtime.HasBody(r) { 66 defer r.Body.Close() 67 var body models.PostableAlerts 68 if err := route.Consumer.Consume(r.Body, &body); err != nil { 69 if err == io.EOF { 70 res = append(res, errors.Required("alerts", "body", "")) 71 } else { 72 res = append(res, errors.NewParseError("alerts", "body", "", err)) 73 } 74 } else { 75 // validate body object 76 if err := body.Validate(route.Formats); err != nil { 77 res = append(res, err) 78 } 79 80 if len(res) == 0 { 81 o.Alerts = body 82 } 83 } 84 } else { 85 res = append(res, errors.Required("alerts", "body", "")) 86 } 87 if len(res) > 0 { 88 return errors.CompositeValidationError(res...) 89 } 90 return nil 91} 92