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