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 17 package silence 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 22 import ( 23 "net/http" 24 25 "github.com/go-openapi/errors" 26 "github.com/go-openapi/runtime" 27 "github.com/go-openapi/runtime/middleware" 28 "github.com/go-openapi/strfmt" 29 ) 30 31 // NewGetSilencesParams creates a new GetSilencesParams object 32 // 33 // There are no default values defined in the spec. 34 func NewGetSilencesParams() GetSilencesParams { 35 36 return GetSilencesParams{} 37 } 38 39 // GetSilencesParams contains all the bound params for the get silences operation 40 // typically these are obtained from a http.Request 41 // 42 // swagger:parameters getSilences 43 type GetSilencesParams struct { 44 45 // HTTP Request Object 46 HTTPRequest *http.Request `json:"-"` 47 48 /*A list of matchers to filter silences by 49 In: query 50 Collection Format: multi 51 */ 52 Filter []string 53 } 54 55 // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 56 // for simple values it will use straight method calls. 57 // 58 // To ensure default values, the struct must have been initialized with NewGetSilencesParams() beforehand. 59 func (o *GetSilencesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 60 var res []error 61 62 o.HTTPRequest = r 63 64 qs := runtime.Values(r.URL.Query()) 65 66 qFilter, qhkFilter, _ := qs.GetOK("filter") 67 if err := o.bindFilter(qFilter, qhkFilter, route.Formats); err != nil { 68 res = append(res, err) 69 } 70 if len(res) > 0 { 71 return errors.CompositeValidationError(res...) 72 } 73 return nil 74 } 75 76 // bindFilter binds and validates array parameter Filter from query. 77 // 78 // Arrays are parsed according to CollectionFormat: "multi" (defaults to "csv" when empty). 79 func (o *GetSilencesParams) bindFilter(rawData []string, hasKey bool, formats strfmt.Registry) error { 80 // CollectionFormat: multi 81 filterIC := rawData 82 if len(filterIC) == 0 { 83 return nil 84 } 85 86 var filterIR []string 87 for _, filterIV := range filterIC { 88 filterI := filterIV 89 90 filterIR = append(filterIR, filterI) 91 } 92 93 o.Filter = filterIR 94 95 return nil 96 } 97