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

package a_bit_of_everything

import (
	"context"
	"net/http"
	"time"

	"github.com/go-openapi/errors"
	"github.com/go-openapi/runtime"
	cr "github.com/go-openapi/runtime/client"
	"github.com/go-openapi/strfmt"

	"github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/clients/abe/models"
)

// NewABitOfEverythingServiceCreateBookParams creates a new ABitOfEverythingServiceCreateBookParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewABitOfEverythingServiceCreateBookParams() *ABitOfEverythingServiceCreateBookParams {
	return &ABitOfEverythingServiceCreateBookParams{
		timeout: cr.DefaultTimeout,
	}
}

// NewABitOfEverythingServiceCreateBookParamsWithTimeout creates a new ABitOfEverythingServiceCreateBookParams object
// with the ability to set a timeout on a request.
func NewABitOfEverythingServiceCreateBookParamsWithTimeout(timeout time.Duration) *ABitOfEverythingServiceCreateBookParams {
	return &ABitOfEverythingServiceCreateBookParams{
		timeout: timeout,
	}
}

// NewABitOfEverythingServiceCreateBookParamsWithContext creates a new ABitOfEverythingServiceCreateBookParams object
// with the ability to set a context for a request.
func NewABitOfEverythingServiceCreateBookParamsWithContext(ctx context.Context) *ABitOfEverythingServiceCreateBookParams {
	return &ABitOfEverythingServiceCreateBookParams{
		Context: ctx,
	}
}

// NewABitOfEverythingServiceCreateBookParamsWithHTTPClient creates a new ABitOfEverythingServiceCreateBookParams object
// with the ability to set a custom HTTPClient for a request.
func NewABitOfEverythingServiceCreateBookParamsWithHTTPClient(client *http.Client) *ABitOfEverythingServiceCreateBookParams {
	return &ABitOfEverythingServiceCreateBookParams{
		HTTPClient: client,
	}
}

/*
ABitOfEverythingServiceCreateBookParams contains all the parameters to send to the API endpoint

	for the a bit of everything service create book operation.

	Typically these are written to a http.Request.
*/
type ABitOfEverythingServiceCreateBookParams struct {

	/* Book.

	   The book to create.
	*/
	Book *models.ExamplepbBook

	/* BookID.

	     The ID to use for the book.

	This must start with an alphanumeric character.
	*/
	BookID *string

	/* Parent.

	     The publisher in which to create the book.

	Format: `publishers/{publisher}`

	Example: `publishers/1257894000000000000`
	*/
	Parent string

	timeout    time.Duration
	Context    context.Context
	HTTPClient *http.Client
}

// WithDefaults hydrates default values in the a bit of everything service create book params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ABitOfEverythingServiceCreateBookParams) WithDefaults() *ABitOfEverythingServiceCreateBookParams {
	o.SetDefaults()
	return o
}

// SetDefaults hydrates default values in the a bit of everything service create book params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ABitOfEverythingServiceCreateBookParams) SetDefaults() {
	// no default values defined for this parameter
}

// WithTimeout adds the timeout to the a bit of everything service create book params
func (o *ABitOfEverythingServiceCreateBookParams) WithTimeout(timeout time.Duration) *ABitOfEverythingServiceCreateBookParams {
	o.SetTimeout(timeout)
	return o
}

// SetTimeout adds the timeout to the a bit of everything service create book params
func (o *ABitOfEverythingServiceCreateBookParams) SetTimeout(timeout time.Duration) {
	o.timeout = timeout
}

// WithContext adds the context to the a bit of everything service create book params
func (o *ABitOfEverythingServiceCreateBookParams) WithContext(ctx context.Context) *ABitOfEverythingServiceCreateBookParams {
	o.SetContext(ctx)
	return o
}

// SetContext adds the context to the a bit of everything service create book params
func (o *ABitOfEverythingServiceCreateBookParams) SetContext(ctx context.Context) {
	o.Context = ctx
}

// WithHTTPClient adds the HTTPClient to the a bit of everything service create book params
func (o *ABitOfEverythingServiceCreateBookParams) WithHTTPClient(client *http.Client) *ABitOfEverythingServiceCreateBookParams {
	o.SetHTTPClient(client)
	return o
}

// SetHTTPClient adds the HTTPClient to the a bit of everything service create book params
func (o *ABitOfEverythingServiceCreateBookParams) SetHTTPClient(client *http.Client) {
	o.HTTPClient = client
}

// WithBook adds the book to the a bit of everything service create book params
func (o *ABitOfEverythingServiceCreateBookParams) WithBook(book *models.ExamplepbBook) *ABitOfEverythingServiceCreateBookParams {
	o.SetBook(book)
	return o
}

// SetBook adds the book to the a bit of everything service create book params
func (o *ABitOfEverythingServiceCreateBookParams) SetBook(book *models.ExamplepbBook) {
	o.Book = book
}

// WithBookID adds the bookID to the a bit of everything service create book params
func (o *ABitOfEverythingServiceCreateBookParams) WithBookID(bookID *string) *ABitOfEverythingServiceCreateBookParams {
	o.SetBookID(bookID)
	return o
}

// SetBookID adds the bookId to the a bit of everything service create book params
func (o *ABitOfEverythingServiceCreateBookParams) SetBookID(bookID *string) {
	o.BookID = bookID
}

// WithParent adds the parent to the a bit of everything service create book params
func (o *ABitOfEverythingServiceCreateBookParams) WithParent(parent string) *ABitOfEverythingServiceCreateBookParams {
	o.SetParent(parent)
	return o
}

// SetParent adds the parent to the a bit of everything service create book params
func (o *ABitOfEverythingServiceCreateBookParams) SetParent(parent string) {
	o.Parent = parent
}

// WriteToRequest writes these params to a swagger request
func (o *ABitOfEverythingServiceCreateBookParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {

	if err := r.SetTimeout(o.timeout); err != nil {
		return err
	}
	var res []error
	if o.Book != nil {
		if err := r.SetBodyParam(o.Book); err != nil {
			return err
		}
	}

	if o.BookID != nil {

		// query param bookId
		var qrBookID string

		if o.BookID != nil {
			qrBookID = *o.BookID
		}
		qBookID := qrBookID
		if qBookID != "" {

			if err := r.SetQueryParam("bookId", qBookID); err != nil {
				return err
			}
		}
	}

	// path param parent
	if err := r.SetPathParam("parent", o.Parent); err != nil {
		return err
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}
