github.com/cilium/cilium@v1.16.2/api/v1/server/restapi/endpoint/delete_endpoint_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 endpoint 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 "io" 13 "net/http" 14 15 "github.com/go-openapi/errors" 16 "github.com/go-openapi/runtime" 17 "github.com/go-openapi/runtime/middleware" 18 "github.com/go-openapi/validate" 19 20 "github.com/cilium/cilium/api/v1/models" 21 ) 22 23 // NewDeleteEndpointParams creates a new DeleteEndpointParams object 24 // 25 // There are no default values defined in the spec. 26 func NewDeleteEndpointParams() DeleteEndpointParams { 27 28 return DeleteEndpointParams{} 29 } 30 31 // DeleteEndpointParams contains all the bound params for the delete endpoint operation 32 // typically these are obtained from a http.Request 33 // 34 // swagger:parameters DeleteEndpoint 35 type DeleteEndpointParams struct { 36 37 // HTTP Request Object 38 HTTPRequest *http.Request `json:"-"` 39 40 /* 41 Required: true 42 In: body 43 */ 44 Endpoint *models.EndpointBatchDeleteRequest 45 } 46 47 // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 48 // for simple values it will use straight method calls. 49 // 50 // To ensure default values, the struct must have been initialized with NewDeleteEndpointParams() beforehand. 51 func (o *DeleteEndpointParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 52 var res []error 53 54 o.HTTPRequest = r 55 56 if runtime.HasBody(r) { 57 defer r.Body.Close() 58 var body models.EndpointBatchDeleteRequest 59 if err := route.Consumer.Consume(r.Body, &body); err != nil { 60 if err == io.EOF { 61 res = append(res, errors.Required("endpoint", "body", "")) 62 } else { 63 res = append(res, errors.NewParseError("endpoint", "body", "", err)) 64 } 65 } else { 66 // validate body object 67 if err := body.Validate(route.Formats); err != nil { 68 res = append(res, err) 69 } 70 71 ctx := validate.WithOperationRequest(r.Context()) 72 if err := body.ContextValidate(ctx, route.Formats); err != nil { 73 res = append(res, err) 74 } 75 76 if len(res) == 0 { 77 o.Endpoint = &body 78 } 79 } 80 } else { 81 res = append(res, errors.Required("endpoint", "body", "")) 82 } 83 if len(res) > 0 { 84 return errors.CompositeValidationError(res...) 85 } 86 return nil 87 }