github.com/cilium/cilium@v1.16.2/api/v1/server/restapi/ipam/post_ipam_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 "github.com/go-openapi/swag" 19 "github.com/go-openapi/validate" 20 ) 21 22 // NewPostIpamParams creates a new PostIpamParams object 23 // 24 // There are no default values defined in the spec. 25 func NewPostIpamParams() PostIpamParams { 26 27 return PostIpamParams{} 28 } 29 30 // PostIpamParams contains all the bound params for the post ipam operation 31 // typically these are obtained from a http.Request 32 // 33 // swagger:parameters PostIpam 34 type PostIpamParams struct { 35 36 // HTTP Request Object 37 HTTPRequest *http.Request `json:"-"` 38 39 /* 40 In: header 41 */ 42 Expiration *bool 43 /* 44 In: query 45 */ 46 Family *string 47 /* 48 In: query 49 */ 50 Owner *string 51 /* 52 In: query 53 */ 54 Pool *string 55 } 56 57 // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 58 // for simple values it will use straight method calls. 59 // 60 // To ensure default values, the struct must have been initialized with NewPostIpamParams() beforehand. 61 func (o *PostIpamParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 62 var res []error 63 64 o.HTTPRequest = r 65 66 qs := runtime.Values(r.URL.Query()) 67 68 if err := o.bindExpiration(r.Header[http.CanonicalHeaderKey("expiration")], true, route.Formats); err != nil { 69 res = append(res, err) 70 } 71 72 qFamily, qhkFamily, _ := qs.GetOK("family") 73 if err := o.bindFamily(qFamily, qhkFamily, route.Formats); err != nil { 74 res = append(res, err) 75 } 76 77 qOwner, qhkOwner, _ := qs.GetOK("owner") 78 if err := o.bindOwner(qOwner, qhkOwner, route.Formats); err != nil { 79 res = append(res, err) 80 } 81 82 qPool, qhkPool, _ := qs.GetOK("pool") 83 if err := o.bindPool(qPool, qhkPool, route.Formats); err != nil { 84 res = append(res, err) 85 } 86 if len(res) > 0 { 87 return errors.CompositeValidationError(res...) 88 } 89 return nil 90 } 91 92 // bindExpiration binds and validates parameter Expiration from header. 93 func (o *PostIpamParams) bindExpiration(rawData []string, hasKey bool, formats strfmt.Registry) error { 94 var raw string 95 if len(rawData) > 0 { 96 raw = rawData[len(rawData)-1] 97 } 98 99 // Required: false 100 101 if raw == "" { // empty values pass all other validations 102 return nil 103 } 104 105 value, err := swag.ConvertBool(raw) 106 if err != nil { 107 return errors.InvalidType("expiration", "header", "bool", raw) 108 } 109 o.Expiration = &value 110 111 return nil 112 } 113 114 // bindFamily binds and validates parameter Family from query. 115 func (o *PostIpamParams) bindFamily(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: false 122 // AllowEmptyValue: false 123 124 if raw == "" { // empty values pass all other validations 125 return nil 126 } 127 o.Family = &raw 128 129 if err := o.validateFamily(formats); err != nil { 130 return err 131 } 132 133 return nil 134 } 135 136 // validateFamily carries on validations for parameter Family 137 func (o *PostIpamParams) validateFamily(formats strfmt.Registry) error { 138 139 if err := validate.EnumCase("family", "query", *o.Family, []interface{}{"ipv4", "ipv6"}, true); err != nil { 140 return err 141 } 142 143 return nil 144 } 145 146 // bindOwner binds and validates parameter Owner from query. 147 func (o *PostIpamParams) bindOwner(rawData []string, hasKey bool, formats strfmt.Registry) error { 148 var raw string 149 if len(rawData) > 0 { 150 raw = rawData[len(rawData)-1] 151 } 152 153 // Required: false 154 // AllowEmptyValue: false 155 156 if raw == "" { // empty values pass all other validations 157 return nil 158 } 159 o.Owner = &raw 160 161 return nil 162 } 163 164 // bindPool binds and validates parameter Pool from query. 165 func (o *PostIpamParams) bindPool(rawData []string, hasKey bool, formats strfmt.Registry) error { 166 var raw string 167 if len(rawData) > 0 { 168 raw = rawData[len(rawData)-1] 169 } 170 171 // Required: false 172 // AllowEmptyValue: false 173 174 if raw == "" { // empty values pass all other validations 175 return nil 176 } 177 o.Pool = &raw 178 179 return nil 180 }