chronograf/restapi/operations/post_sources_id_roles_param...

89 lines
2.1 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 (
"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"
)
// NewPostSourcesIDRolesParams creates a new PostSourcesIDRolesParams object
// with the default values initialized.
func NewPostSourcesIDRolesParams() PostSourcesIDRolesParams {
var ()
return PostSourcesIDRolesParams{}
}
// PostSourcesIDRolesParams contains all the bound params for the post sources ID roles operation
// typically these are obtained from a http.Request
//
// swagger:parameters PostSourcesIDRoles
type PostSourcesIDRolesParams struct {
// HTTP Request Object
HTTPRequest *http.Request
/*ID of the data source
Required: true
In: path
*/
ID string
/*Configuration options for new role
In: body
*/
Role *models.Role
}
// 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 *PostSourcesIDRolesParams) 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.Role
if err := route.Consumer.Consume(r.Body, &body); err != nil {
res = append(res, errors.NewParseError("role", "body", "", err))
} else {
if err := body.Validate(route.Formats); err != nil {
res = append(res, err)
}
if len(res) == 0 {
o.Role = &body
}
}
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *PostSourcesIDRolesParams) 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
}