github.com/looshlee/beatles@v0.0.0-20220727174639-742810ab631c/api/v1/server/restapi/ipam/post_ip_a_m_ip_parameters.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package ipam 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 "net/http" 10 11 "github.com/go-openapi/errors" 12 "github.com/go-openapi/runtime" 13 "github.com/go-openapi/runtime/middleware" 14 15 strfmt "github.com/go-openapi/strfmt" 16 ) 17 18 // NewPostIPAMIPParams creates a new PostIPAMIPParams object 19 // no default values defined in spec. 20 func NewPostIPAMIPParams() PostIPAMIPParams { 21 22 return PostIPAMIPParams{} 23 } 24 25 // PostIPAMIPParams contains all the bound params for the post IP a m IP operation 26 // typically these are obtained from a http.Request 27 // 28 // swagger:parameters PostIPAMIP 29 type PostIPAMIPParams struct { 30 31 // HTTP Request Object 32 HTTPRequest *http.Request `json:"-"` 33 34 /*IP address 35 Required: true 36 In: path 37 */ 38 IP string 39 /* 40 In: query 41 */ 42 Owner *string 43 } 44 45 // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 46 // for simple values it will use straight method calls. 47 // 48 // To ensure default values, the struct must have been initialized with NewPostIPAMIPParams() beforehand. 49 func (o *PostIPAMIPParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 50 var res []error 51 52 o.HTTPRequest = r 53 54 qs := runtime.Values(r.URL.Query()) 55 56 rIP, rhkIP, _ := route.Params.GetOK("ip") 57 if err := o.bindIP(rIP, rhkIP, route.Formats); err != nil { 58 res = append(res, err) 59 } 60 61 qOwner, qhkOwner, _ := qs.GetOK("owner") 62 if err := o.bindOwner(qOwner, qhkOwner, route.Formats); err != nil { 63 res = append(res, err) 64 } 65 66 if len(res) > 0 { 67 return errors.CompositeValidationError(res...) 68 } 69 return nil 70 } 71 72 // bindIP binds and validates parameter IP from path. 73 func (o *PostIPAMIPParams) bindIP(rawData []string, hasKey bool, formats strfmt.Registry) error { 74 var raw string 75 if len(rawData) > 0 { 76 raw = rawData[len(rawData)-1] 77 } 78 79 // Required: true 80 // Parameter is provided by construction from the route 81 82 o.IP = raw 83 84 return nil 85 } 86 87 // bindOwner binds and validates parameter Owner from query. 88 func (o *PostIPAMIPParams) bindOwner(rawData []string, hasKey bool, formats strfmt.Registry) error { 89 var raw string 90 if len(rawData) > 0 { 91 raw = rawData[len(rawData)-1] 92 } 93 94 // Required: false 95 // AllowEmptyValue: false 96 if raw == "" { // empty values pass all other validations 97 return nil 98 } 99 100 o.Owner = &raw 101 102 return nil 103 }