influxdb/restapi/operations/post_sources_id_proxy_param...

98 lines
2.3 KiB
Go

package operations
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"io"
"net/http"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/runtime/middleware"
strfmt "github.com/go-openapi/strfmt"
"github.com/influxdata/mrfusion/models"
)
// NewPostSourcesIDProxyParams creates a new PostSourcesIDProxyParams object
// with the default values initialized.
func NewPostSourcesIDProxyParams() PostSourcesIDProxyParams {
var ()
return PostSourcesIDProxyParams{}
}
// PostSourcesIDProxyParams contains all the bound params for the post sources ID proxy operation
// typically these are obtained from a http.Request
//
// swagger:parameters PostSourcesIDProxy
type PostSourcesIDProxyParams struct {
// HTTP Request Object
HTTPRequest *http.Request
/*ID of the data source
Required: true
In: path
*/
ID string
/*Query Parameters
Required: true
In: body
*/
Query *models.Proxy
}
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls
func (o *PostSourcesIDProxyParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
var res []error
o.HTTPRequest = r
rID, rhkID, _ := route.Params.GetOK("id")
if err := o.bindID(rID, rhkID, route.Formats); err != nil {
res = append(res, err)
}
if runtime.HasBody(r) {
defer r.Body.Close()
var body models.Proxy
if err := route.Consumer.Consume(r.Body, &body); err != nil {
if err == io.EOF {
res = append(res, errors.Required("query", "body"))
} else {
res = append(res, errors.NewParseError("query", "body", "", err))
}
} else {
if err := body.Validate(route.Formats); err != nil {
res = append(res, err)
}
if len(res) == 0 {
o.Query = &body
}
}
} else {
res = append(res, errors.Required("query", "body"))
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *PostSourcesIDProxyParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
o.ID = raw
return nil
}