github.com/cilium/cilium@v1.16.2/api/v1/server/restapi/ipam/post_ipam_ip_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 ipam 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/strfmt" 18 ) 19 20 // NewPostIpamIPParams creates a new PostIpamIPParams object 21 // 22 // There are no default values defined in the spec. 23 func NewPostIpamIPParams() PostIpamIPParams { 24 25 return PostIpamIPParams{} 26 } 27 28 // PostIpamIPParams contains all the bound params for the post ipam IP operation 29 // typically these are obtained from a http.Request 30 // 31 // swagger:parameters PostIpamIP 32 type PostIpamIPParams struct { 33 34 // HTTP Request Object 35 HTTPRequest *http.Request `json:"-"` 36 37 /*IP address 38 Required: true 39 In: path 40 */ 41 IP string 42 /* 43 In: query 44 */ 45 Owner *string 46 /* 47 In: query 48 */ 49 Pool *string 50 } 51 52 // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 53 // for simple values it will use straight method calls. 54 // 55 // To ensure default values, the struct must have been initialized with NewPostIpamIPParams() beforehand. 56 func (o *PostIpamIPParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 57 var res []error 58 59 o.HTTPRequest = r 60 61 qs := runtime.Values(r.URL.Query()) 62 63 rIP, rhkIP, _ := route.Params.GetOK("ip") 64 if err := o.bindIP(rIP, rhkIP, route.Formats); err != nil { 65 res = append(res, err) 66 } 67 68 qOwner, qhkOwner, _ := qs.GetOK("owner") 69 if err := o.bindOwner(qOwner, qhkOwner, route.Formats); err != nil { 70 res = append(res, err) 71 } 72 73 qPool, qhkPool, _ := qs.GetOK("pool") 74 if err := o.bindPool(qPool, qhkPool, route.Formats); err != nil { 75 res = append(res, err) 76 } 77 if len(res) > 0 { 78 return errors.CompositeValidationError(res...) 79 } 80 return nil 81 } 82 83 // bindIP binds and validates parameter IP from path. 84 func (o *PostIpamIPParams) bindIP(rawData []string, hasKey bool, formats strfmt.Registry) error { 85 var raw string 86 if len(rawData) > 0 { 87 raw = rawData[len(rawData)-1] 88 } 89 90 // Required: true 91 // Parameter is provided by construction from the route 92 o.IP = raw 93 94 return nil 95 } 96 97 // bindOwner binds and validates parameter Owner from query. 98 func (o *PostIpamIPParams) bindOwner(rawData []string, hasKey bool, formats strfmt.Registry) error { 99 var raw string 100 if len(rawData) > 0 { 101 raw = rawData[len(rawData)-1] 102 } 103 104 // Required: false 105 // AllowEmptyValue: false 106 107 if raw == "" { // empty values pass all other validations 108 return nil 109 } 110 o.Owner = &raw 111 112 return nil 113 } 114 115 // bindPool binds and validates parameter Pool from query. 116 func (o *PostIpamIPParams) bindPool(rawData []string, hasKey bool, formats strfmt.Registry) error { 117 var raw string 118 if len(rawData) > 0 { 119 raw = rawData[len(rawData)-1] 120 } 121 122 // Required: false 123 // AllowEmptyValue: false 124 125 if raw == "" { // empty values pass all other validations 126 return nil 127 } 128 o.Pool = &raw 129 130 return nil 131 }