github.com/cilium/cilium@v1.16.2/api/v1/server/restapi/policy/get_policy_parameters.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 // Copyright Authors of Cilium 4 // SPDX-License-Identifier: Apache-2.0 5 6 package policy 7 8 // This file was generated by the swagger tool. 9 // Editing this file might prove futile when you re-run the swagger generate command 10 11 import ( 12 "net/http" 13 14 "github.com/go-openapi/errors" 15 "github.com/go-openapi/runtime" 16 "github.com/go-openapi/runtime/middleware" 17 "github.com/go-openapi/validate" 18 19 "github.com/cilium/cilium/api/v1/models" 20 ) 21 22 // NewGetPolicyParams creates a new GetPolicyParams object 23 // 24 // There are no default values defined in the spec. 25 func NewGetPolicyParams() GetPolicyParams { 26 27 return GetPolicyParams{} 28 } 29 30 // GetPolicyParams contains all the bound params for the get policy operation 31 // typically these are obtained from a http.Request 32 // 33 // swagger:parameters GetPolicy 34 type GetPolicyParams struct { 35 36 // HTTP Request Object 37 HTTPRequest *http.Request `json:"-"` 38 39 /* 40 In: body 41 */ 42 Labels models.Labels 43 } 44 45 // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 46 // for simple values it will use straight method calls. 47 // 48 // To ensure default values, the struct must have been initialized with NewGetPolicyParams() beforehand. 49 func (o *GetPolicyParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 50 var res []error 51 52 o.HTTPRequest = r 53 54 if runtime.HasBody(r) { 55 defer r.Body.Close() 56 var body models.Labels 57 if err := route.Consumer.Consume(r.Body, &body); err != nil { 58 res = append(res, errors.NewParseError("labels", "body", "", err)) 59 } else { 60 // validate body object 61 if err := body.Validate(route.Formats); err != nil { 62 res = append(res, err) 63 } 64 65 ctx := validate.WithOperationRequest(r.Context()) 66 if err := body.ContextValidate(ctx, route.Formats); err != nil { 67 res = append(res, err) 68 } 69 70 if len(res) == 0 { 71 o.Labels = body 72 } 73 } 74 } 75 if len(res) > 0 { 76 return errors.CompositeValidationError(res...) 77 } 78 return nil 79 }