github.com/cilium/cilium@v1.16.2/api/v1/server/restapi/endpoint/put_endpoint_id_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/strfmt" 19 "github.com/go-openapi/validate" 20 21 "github.com/cilium/cilium/api/v1/models" 22 ) 23 24 // NewPutEndpointIDParams creates a new PutEndpointIDParams object 25 // 26 // There are no default values defined in the spec. 27 func NewPutEndpointIDParams() PutEndpointIDParams { 28 29 return PutEndpointIDParams{} 30 } 31 32 // PutEndpointIDParams contains all the bound params for the put endpoint ID operation 33 // typically these are obtained from a http.Request 34 // 35 // swagger:parameters PutEndpointID 36 type PutEndpointIDParams struct { 37 38 // HTTP Request Object 39 HTTPRequest *http.Request `json:"-"` 40 41 /* 42 Required: true 43 In: body 44 */ 45 Endpoint *models.EndpointChangeRequest 46 /*String describing an endpoint with the format ``[prefix:]id``. If no prefix 47 is specified, a prefix of ``cilium-local:`` is assumed. Not all endpoints 48 will be addressable by all endpoint ID prefixes with the exception of the 49 local Cilium UUID which is assigned to all endpoints. 50 51 Supported endpoint id prefixes: 52 - cilium-local: Local Cilium endpoint UUID, e.g. cilium-local:3389595 53 - cilium-global: Global Cilium endpoint UUID, e.g. cilium-global:cluster1:nodeX:452343 54 - cni-attachment-id: CNI attachment ID, e.g. cni-attachment-id:22222:eth0 55 - container-id: Container runtime ID, e.g. container-id:22222 (deprecated, may not be unique) 56 - container-name: Container name, e.g. container-name:foobar (deprecated, may not be unique) 57 - pod-name: pod name for this container if K8s is enabled, e.g. pod-name:default:foobar (deprecated, may not be unique) 58 - cep-name: cep name for this container if K8s is enabled, e.g. pod-name:default:foobar-net1 59 - docker-endpoint: Docker libnetwork endpoint ID, e.g. docker-endpoint:4444 60 61 Required: true 62 In: path 63 */ 64 ID string 65 } 66 67 // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 68 // for simple values it will use straight method calls. 69 // 70 // To ensure default values, the struct must have been initialized with NewPutEndpointIDParams() beforehand. 71 func (o *PutEndpointIDParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 72 var res []error 73 74 o.HTTPRequest = r 75 76 if runtime.HasBody(r) { 77 defer r.Body.Close() 78 var body models.EndpointChangeRequest 79 if err := route.Consumer.Consume(r.Body, &body); err != nil { 80 if err == io.EOF { 81 res = append(res, errors.Required("endpoint", "body", "")) 82 } else { 83 res = append(res, errors.NewParseError("endpoint", "body", "", err)) 84 } 85 } else { 86 // validate body object 87 if err := body.Validate(route.Formats); err != nil { 88 res = append(res, err) 89 } 90 91 ctx := validate.WithOperationRequest(r.Context()) 92 if err := body.ContextValidate(ctx, route.Formats); err != nil { 93 res = append(res, err) 94 } 95 96 if len(res) == 0 { 97 o.Endpoint = &body 98 } 99 } 100 } else { 101 res = append(res, errors.Required("endpoint", "body", "")) 102 } 103 104 rID, rhkID, _ := route.Params.GetOK("id") 105 if err := o.bindID(rID, rhkID, route.Formats); err != nil { 106 res = append(res, err) 107 } 108 if len(res) > 0 { 109 return errors.CompositeValidationError(res...) 110 } 111 return nil 112 } 113 114 // bindID binds and validates parameter ID from path. 115 func (o *PutEndpointIDParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { 116 var raw string 117 if len(rawData) > 0 { 118 raw = rawData[len(rawData)-1] 119 } 120 121 // Required: true 122 // Parameter is provided by construction from the route 123 o.ID = raw 124 125 return nil 126 }