github.com/kubearmor/cilium@v1.6.12/api/v1/server/restapi/policy/put_policy_parameters.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package policy 4 5 // This file was generated by the swagger tool. 6 // Editing this file might prove futile when you re-run the swagger generate command 7 8 import ( 9 "io" 10 "net/http" 11 12 "github.com/go-openapi/errors" 13 "github.com/go-openapi/runtime" 14 "github.com/go-openapi/runtime/middleware" 15 ) 16 17 // NewPutPolicyParams creates a new PutPolicyParams object 18 // no default values defined in spec. 19 func NewPutPolicyParams() PutPolicyParams { 20 21 return PutPolicyParams{} 22 } 23 24 // PutPolicyParams contains all the bound params for the put policy operation 25 // typically these are obtained from a http.Request 26 // 27 // swagger:parameters PutPolicy 28 type PutPolicyParams struct { 29 30 // HTTP Request Object 31 HTTPRequest *http.Request `json:"-"` 32 33 /*Policy rules 34 Required: true 35 In: body 36 */ 37 Policy string 38 } 39 40 // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 41 // for simple values it will use straight method calls. 42 // 43 // To ensure default values, the struct must have been initialized with NewPutPolicyParams() beforehand. 44 func (o *PutPolicyParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 45 var res []error 46 47 o.HTTPRequest = r 48 49 if runtime.HasBody(r) { 50 defer r.Body.Close() 51 var body string 52 if err := route.Consumer.Consume(r.Body, &body); err != nil { 53 if err == io.EOF { 54 res = append(res, errors.Required("policy", "body")) 55 } else { 56 res = append(res, errors.NewParseError("policy", "body", "", err)) 57 } 58 } else { 59 // no validation required on inline body 60 o.Policy = body 61 } 62 } else { 63 res = append(res, errors.Required("policy", "body")) 64 } 65 if len(res) > 0 { 66 return errors.CompositeValidationError(res...) 67 } 68 return nil 69 }