//                           _       _
// __      _____  __ ___   ___  __ _| |_ ___
// \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \
//  \ V  V /  __/ (_| |\ V /| | (_| | ||  __/
//   \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___|
//
//  Copyright © 2016 - 2020 SeMI Technologies B.V. All rights reserved.
//
//  CONTACT: hello@semi.technology
//

// Code generated by go-swagger; DO NOT EDIT.

package contextionary_api

// 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"

	"github.com/semi-technologies/weaviate/entities/models"
)

// NewC11yExtensionsParams creates a new C11yExtensionsParams object
// no default values defined in spec.
func NewC11yExtensionsParams() C11yExtensionsParams {

	return C11yExtensionsParams{}
}

// C11yExtensionsParams contains all the bound params for the c11y extensions operation
// typically these are obtained from a http.Request
//
// swagger:parameters c11y.extensions
type C11yExtensionsParams struct {

	// HTTP Request Object
	HTTPRequest *http.Request `json:"-"`

	/*Description and definition of the concept to extend the contextionary with
	  Required: true
	  In: body
	*/
	Extension *models.C11yExtension
}

// 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.
//
// To ensure default values, the struct must have been initialized with NewC11yExtensionsParams() beforehand.
func (o *C11yExtensionsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
	var res []error

	o.HTTPRequest = r

	if runtime.HasBody(r) {
		defer r.Body.Close()
		var body models.C11yExtension
		if err := route.Consumer.Consume(r.Body, &body); err != nil {
			if err == io.EOF {
				res = append(res, errors.Required("extension", "body", ""))
			} else {
				res = append(res, errors.NewParseError("extension", "body", "", err))
			}
		} else {
			// validate body object
			if err := body.Validate(route.Formats); err != nil {
				res = append(res, err)
			}

			if len(res) == 0 {
				o.Extension = &body
			}
		}
	} else {
		res = append(res, errors.Required("extension", "body", ""))
	}
	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}
