github.com/cilium/cilium@v1.16.2/api/v1/server/restapi/bgp/get_bgp_routes_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 bgp 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 // NewGetBgpRoutesParams creates a new GetBgpRoutesParams object 23 // 24 // There are no default values defined in the spec. 25 func NewGetBgpRoutesParams() GetBgpRoutesParams { 26 27 return GetBgpRoutesParams{} 28 } 29 30 // GetBgpRoutesParams contains all the bound params for the get bgp routes operation 31 // typically these are obtained from a http.Request 32 // 33 // swagger:parameters GetBgpRoutes 34 type GetBgpRoutesParams struct { 35 36 // HTTP Request Object 37 HTTPRequest *http.Request `json:"-"` 38 39 /*Address Family Indicator (AFI) of a BGP route 40 Required: true 41 In: query 42 */ 43 Afi string 44 /*IP address specifying a BGP neighbor. 45 Has to be specified only when table type is adj-rib-in or adj-rib-out. 46 47 In: query 48 */ 49 Neighbor *string 50 /*Autonomous System Number (ASN) identifying a BGP virtual router instance. 51 If not specified, all virtual router instances are selected. 52 53 In: query 54 */ 55 RouterAsn *int64 56 /*Subsequent Address Family Indicator (SAFI) of a BGP route 57 Required: true 58 In: query 59 */ 60 Safi string 61 /*BGP Routing Information Base (RIB) table type 62 Required: true 63 In: query 64 */ 65 TableType string 66 } 67 68 // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 69 // for simple values it will use straight method calls. 70 // 71 // To ensure default values, the struct must have been initialized with NewGetBgpRoutesParams() beforehand. 72 func (o *GetBgpRoutesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 73 var res []error 74 75 o.HTTPRequest = r 76 77 qs := runtime.Values(r.URL.Query()) 78 79 qAfi, qhkAfi, _ := qs.GetOK("afi") 80 if err := o.bindAfi(qAfi, qhkAfi, route.Formats); err != nil { 81 res = append(res, err) 82 } 83 84 qNeighbor, qhkNeighbor, _ := qs.GetOK("neighbor") 85 if err := o.bindNeighbor(qNeighbor, qhkNeighbor, route.Formats); err != nil { 86 res = append(res, err) 87 } 88 89 qRouterAsn, qhkRouterAsn, _ := qs.GetOK("router_asn") 90 if err := o.bindRouterAsn(qRouterAsn, qhkRouterAsn, route.Formats); err != nil { 91 res = append(res, err) 92 } 93 94 qSafi, qhkSafi, _ := qs.GetOK("safi") 95 if err := o.bindSafi(qSafi, qhkSafi, route.Formats); err != nil { 96 res = append(res, err) 97 } 98 99 qTableType, qhkTableType, _ := qs.GetOK("table_type") 100 if err := o.bindTableType(qTableType, qhkTableType, route.Formats); err != nil { 101 res = append(res, err) 102 } 103 if len(res) > 0 { 104 return errors.CompositeValidationError(res...) 105 } 106 return nil 107 } 108 109 // bindAfi binds and validates parameter Afi from query. 110 func (o *GetBgpRoutesParams) bindAfi(rawData []string, hasKey bool, formats strfmt.Registry) error { 111 if !hasKey { 112 return errors.Required("afi", "query", rawData) 113 } 114 var raw string 115 if len(rawData) > 0 { 116 raw = rawData[len(rawData)-1] 117 } 118 119 // Required: true 120 // AllowEmptyValue: false 121 122 if err := validate.RequiredString("afi", "query", raw); err != nil { 123 return err 124 } 125 o.Afi = raw 126 127 return nil 128 } 129 130 // bindNeighbor binds and validates parameter Neighbor from query. 131 func (o *GetBgpRoutesParams) bindNeighbor(rawData []string, hasKey bool, formats strfmt.Registry) error { 132 var raw string 133 if len(rawData) > 0 { 134 raw = rawData[len(rawData)-1] 135 } 136 137 // Required: false 138 // AllowEmptyValue: false 139 140 if raw == "" { // empty values pass all other validations 141 return nil 142 } 143 o.Neighbor = &raw 144 145 return nil 146 } 147 148 // bindRouterAsn binds and validates parameter RouterAsn from query. 149 func (o *GetBgpRoutesParams) bindRouterAsn(rawData []string, hasKey bool, formats strfmt.Registry) error { 150 var raw string 151 if len(rawData) > 0 { 152 raw = rawData[len(rawData)-1] 153 } 154 155 // Required: false 156 // AllowEmptyValue: false 157 158 if raw == "" { // empty values pass all other validations 159 return nil 160 } 161 162 value, err := swag.ConvertInt64(raw) 163 if err != nil { 164 return errors.InvalidType("router_asn", "query", "int64", raw) 165 } 166 o.RouterAsn = &value 167 168 return nil 169 } 170 171 // bindSafi binds and validates parameter Safi from query. 172 func (o *GetBgpRoutesParams) bindSafi(rawData []string, hasKey bool, formats strfmt.Registry) error { 173 if !hasKey { 174 return errors.Required("safi", "query", rawData) 175 } 176 var raw string 177 if len(rawData) > 0 { 178 raw = rawData[len(rawData)-1] 179 } 180 181 // Required: true 182 // AllowEmptyValue: false 183 184 if err := validate.RequiredString("safi", "query", raw); err != nil { 185 return err 186 } 187 o.Safi = raw 188 189 return nil 190 } 191 192 // bindTableType binds and validates parameter TableType from query. 193 func (o *GetBgpRoutesParams) bindTableType(rawData []string, hasKey bool, formats strfmt.Registry) error { 194 if !hasKey { 195 return errors.Required("table_type", "query", rawData) 196 } 197 var raw string 198 if len(rawData) > 0 { 199 raw = rawData[len(rawData)-1] 200 } 201 202 // Required: true 203 // AllowEmptyValue: false 204 205 if err := validate.RequiredString("table_type", "query", raw); err != nil { 206 return err 207 } 208 o.TableType = raw 209 210 if err := o.validateTableType(formats); err != nil { 211 return err 212 } 213 214 return nil 215 } 216 217 // validateTableType carries on validations for parameter TableType 218 func (o *GetBgpRoutesParams) validateTableType(formats strfmt.Registry) error { 219 220 if err := validate.EnumCase("table_type", "query", o.TableType, []interface{}{"loc-rib", "adj-rib-in", "adj-rib-out"}, true); err != nil { 221 return err 222 } 223 224 return nil 225 }