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