// 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/go-openapi/swag"
)

// NewABitOfEverythingServiceUpdateBookParams creates a new ABitOfEverythingServiceUpdateBookParams 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 NewABitOfEverythingServiceUpdateBookParams() *ABitOfEverythingServiceUpdateBookParams {
	return &ABitOfEverythingServiceUpdateBookParams{
		timeout: cr.DefaultTimeout,
	}
}

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

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

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

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

	for the a bit of everything service update book operation.

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

	/* AllowMissing.

	     If set to true, and the book is not found, a new book will be created.
	In this situation, `update_mask` is ignored.
	*/
	AllowMissing *bool

	/* Book.

	     The book to update.

	The book's `name` field is used to identify the book to be updated.
	Format: publishers/{publisher}/books/{book}
	*/
	Book ABitOfEverythingServiceUpdateBookBody

	/* BookName.

	     The resource name of the book.

	Format: `publishers/{publisher}/books/{book}`

	Example: `publishers/1257894000000000000/books/my-book`
	*/
	BookName string

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

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

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

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

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

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

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

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

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

// WithAllowMissing adds the allowMissing to the a bit of everything service update book params
func (o *ABitOfEverythingServiceUpdateBookParams) WithAllowMissing(allowMissing *bool) *ABitOfEverythingServiceUpdateBookParams {
	o.SetAllowMissing(allowMissing)
	return o
}

// SetAllowMissing adds the allowMissing to the a bit of everything service update book params
func (o *ABitOfEverythingServiceUpdateBookParams) SetAllowMissing(allowMissing *bool) {
	o.AllowMissing = allowMissing
}

// WithBook adds the book to the a bit of everything service update book params
func (o *ABitOfEverythingServiceUpdateBookParams) WithBook(book ABitOfEverythingServiceUpdateBookBody) *ABitOfEverythingServiceUpdateBookParams {
	o.SetBook(book)
	return o
}

// SetBook adds the book to the a bit of everything service update book params
func (o *ABitOfEverythingServiceUpdateBookParams) SetBook(book ABitOfEverythingServiceUpdateBookBody) {
	o.Book = book
}

// WithBookName adds the bookName to the a bit of everything service update book params
func (o *ABitOfEverythingServiceUpdateBookParams) WithBookName(bookName string) *ABitOfEverythingServiceUpdateBookParams {
	o.SetBookName(bookName)
	return o
}

// SetBookName adds the bookName to the a bit of everything service update book params
func (o *ABitOfEverythingServiceUpdateBookParams) SetBookName(bookName string) {
	o.BookName = bookName
}

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

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

	if o.AllowMissing != nil {

		// query param allowMissing
		var qrAllowMissing bool

		if o.AllowMissing != nil {
			qrAllowMissing = *o.AllowMissing
		}
		qAllowMissing := swag.FormatBool(qrAllowMissing)
		if qAllowMissing != "" {

			if err := r.SetQueryParam("allowMissing", qAllowMissing); err != nil {
				return err
			}
		}
	}
	if err := r.SetBodyParam(o.Book); err != nil {
		return err
	}

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

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